Library for using the Wifi module ESP8266, first version with basic commands, soon new commands will be added
Dependents: PIR_Sensor_wifi myESP8266forLOstFound Motin_Activated_Temperature_Humidity_BluetoothHC-06_ESP8266_IOT 1Project3_Robot1_Final ... more
Library updated in Dec 28, 2014. Now the ESP baudrate is passed as a parameter in the constructor. Also, some new functions were added. Here is an example code:
ESP8266 example code
#include "mbed.h" #include <string> #include "ESP8266.h" // Objects Serial pc(USBTX, USBRX); ESP8266 esp(PTE0, PTE1, 115200); // Global variables char snd[255], rcv[1000]; // Strings for sending and receiving commands / data / replies int main() { pc.baud(115200); pc.printf("START\r\n"); wait(3); pc.printf("Reset ESP\r\n"); esp.Reset(); esp.RcvReply(rcv, 400); pc.printf("%s", rcv); wait(2); pc.printf("Sending AT\r\n"); strcpy(snd, "AT"); esp.SendCMD(snd); esp.RcvReply(rcv, 400); pc.printf("%s", rcv); wait(2); pc.printf("Set mode to AP\r\n"); esp.SetMode(1); esp.RcvReply(rcv, 1000); pc.printf("%s", rcv); pc.printf("Receiving Wifi List\r\n"); esp.GetList(rcv); pc.printf("%s", rcv); pc.printf("Connecting to AP\r\n"); esp.Join("MyAP", "MyPasswd"); // Replace MyAP and MyPasswd with your SSID and password esp.RcvReply(rcv, 1000); pc.printf("%s", rcv); wait(8); pc.printf("Getting IP\r\n"); esp.GetIP(rcv); pc.printf("%s", rcv); pc.printf("Setting multiple connections\r\n"); esp.SetMultiple(); esp.RcvReply(rcv, 1000); pc.printf("%s", rcv); pc.printf("Getting Connection Status\r\n"); esp.GetConnStatus(rcv); pc.printf("%s", rcv); pc.printf("Start server mode on port 80\r\n"); esp.StartServerMode(80); esp.RcvReply(rcv, 1000); pc.printf("%s", rcv); wait(4); pc.printf("Close server mode\r\n"); esp.CloseServerMode(); esp.RcvReply(rcv, 1000); pc.printf("THE END"); while(1); }
History
Added functions: Get connection status, Start server mode, Close server mode; now the ESP serial baudrate is passed as a parameter in the constructor
2014-12-28, by quevedo [Sun, 28 Dec 2014 21:58:49 +0000] rev 2
Added functions: Get connection status, Start server mode, Close server mode; now the ESP serial baudrate is passed as a parameter in the constructor
Added functions: SetMode (STA, AP, or both), Quit(quits the AP connection), and SetSingle / SetMultiple for single and multiple connections
2014-12-17, by quevedo [Wed, 17 Dec 2014 13:54:34 +0000] rev 1
Added functions: SetMode (STA, AP, or both), Quit(quits the AP connection), and SetSingle / SetMultiple for single and multiple connections
First version, only basic commands
2014-12-16, by quevedo [Tue, 16 Dec 2014 01:08:47 +0000] rev 0
First version, only basic commands