Post topics, source code that relate to the Arduino Platform

User avatar
By jmaurin
#40145
martinayotte wrote:Simply use the following piece of code in Setup() :

Code: Select all  const char* ssid     = "YourWifiAPRouter";
  const char* password = "xxxxxxxxxxxxxxx";
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password); 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");


This code is to run directly in ESP, right?
Is there any good lib like this one to work in ARDUINO, communicating with ESP by serial? I sawe a lot of libs, but almost all are old and didn't work with latest versions of ESP.
User avatar
By joem
#58031 can i ask for the code? i'm planning to set up a controller via wifi without internet. the controller uses push buttons. i'm using esp 11 wifi shield. the controller serves as AP and the other two arduinos as stations. i want to control them both at the same time, but i know it will communicate one at a time. it is ok because will take around only millisec and it is not obvious to my display! big thanks sir. or you can email the code deocampojoemar@gmail.com Your help is much appreciated!
User avatar
By JuanTelo
#64281
ricg wrote:Instead of connecting this device to your access point you can instead configure the esp8266 as an access point and as a server. This allows connecting your pc to the esp provided AP and sending and receiving data from it. One advantage of this approach is that you don't have to hardcode your AP's password in your arduino sketch. It also allows multiple connections at the same time including connecting other esp devices.

Attached is example code that allows connecting a browser to 192.168.4.1:8000 and receiving a string counting the number of refreshes. This could be changed to sending temperature or other data or switching a device on and off, etc..
Procedure:
1. This sketch is configured to setup the esp as an AP on boot up.


2. you can then connect your PC to AP "esp826605", provided it has wireless access.
3. start up a terminal and ping 192.168.4.1 this is the default IP of all esp devices.
The ping will tell you if your accessing the esp AP. You can also type ipconfig to see what IP adr the esp AP assigned to your PC.
4. Now you should be able to launch a browser and connect to 192.168.4.1:8000
if you successfully connect you will see the following string displayed on the browser page.
Counter Value = 1
Each time you refresh the count will increment.

Additionally, you can use this sketch to time a round trip sent from another esp to this AP which sends it back to the sender.
i was getting average times of about 150ms for the round trip.
if anyone is interested in seeing that code, let me know and i will upload it.


Is it possible if I ask for the code you're using? I'm new to wireless communication and I want to send data from an FSR (force) sensor from the analogic port of the NodeMCU Lua (esp8266) to somewhere where I could get the information using any device connected to the acess point created by the esp8266 module. You can contact my through my e-mail: juantelo95@gmail.com. I'm learning this on my own and i'm having difficulties with creating the acess point.