Scott Ensign posted an update 2 years, 8 months ago
I’m connecting an ESP8266 V1.0 with a Mayfly. Can anyone suggest a simple sketch that scans for available wifi networks (and displaying them by printing to the terminal) and displays confirmation of the connection with my wifi by printing something to the terminal? Ultimately, I’d like to send sensor data to Monitor My Watershed, but the first step is confirming that I am reaching the internet.
Well, the *easiest* way would be to take the ESP bee off the mayfly and connect it to a UartSBee and then talk to the bee directly using AT commands and a serial port.
If you’d rather keep it attached to the Mayfly, you can use the basic example for the StreamDebugger (https://github.com/vshymanskyy/StreamDebugger) library to communicate with the ESP.
The list of ESP commands is available here: https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf
First, make sure the ESP is responding by sending just “AT” and waiting to get and “OK” back.
To see all the wireless networks available, send “AT+CWLAP” and you should get back a “+CWLAP:” followed by a list of access points.
To set some access point as the default (saved to memory) you use “AT+CWJAP_DEF=,” (ie, ‘ AT+CWJAP_DEF=”abc”,”0123456789″ ‘)
Then you can check if you’re actually connected by sending “AT+CIPSTATUS” which will return “+CIPSTATUS:#” where:
‣ 2: The ESP8266 Station is connected to an AP and its IP is obtained.
‣ 3: The ESP8266 Station has created a TCP or UDP transmission.
‣ 4: The TCP or UDP transmission of ESP8266 Station is disconnected.
‣ 5: The ESP8266 Station does NOT connect to an AP.
If you only want to connect to the access point one time (and not save it to flash) use AT+CWJAP_CUR instead of AT+CWJAP_DEF.
Um.. and it’s also possible that the esp I gave you had a botched firmware upgrade. If you’re not getting connected, come and demand a better one from me.