5 An
ESP8266 library
for Arduino providing an easy-to-use way to manipulate
ESP8266.
9 Source can be download at <https:
17 Online API documentation can be reached at <http:
19 Offline API documentation can be found under directory
24 On the home page of API documentation, the tabs of Examples, Classes and Modules
25 will be useful
for Arduino lovers.
29 bool kick (
void) : Verify
ESP8266 whether live or not.
31 bool restart (void) : Restart
ESP8266 by
"AT+RST".
33 String getVersion (void) : Get the version of AT Command Set.
35 bool setOprToStation (void) : Set operation mode to staion.
37 bool setOprToSoftAP (void) : Set operation mode to softap.
39 bool setOprToStationSoftAP (void) : Set operation mode to station + softap.
41 String getAPList (void) : Search available AP list and return it.
43 bool joinAP (String ssid, String pwd) : Join in AP.
45 bool leaveAP (void) : Leave AP joined before.
47 bool setSoftAPParam (String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4) : Set SoftAP parameters.
49 String getJoinedDeviceIP (void) : Get the IP list of devices connected to SoftAP.
51 String getIPStatus (void) : Get the current status of connection(UDP and TCP).
53 String getLocalIP (void) : Get the IP address of
ESP8266.
55 bool enableMUX (void) : Enable IP MUX(multiple connection mode).
57 bool disableMUX (void) : Disable IP MUX(single connection mode).
59 bool createTCP (String addr, uint32_t port) : Create TCP connection in single mode.
61 bool releaseTCP (void) : Release TCP connection in single mode.
63 bool registerUDP (String addr, uint32_t port) : Register UDP port number in single mode.
65 bool unregisterUDP (void) : Unregister UDP port number in single mode.
67 bool createTCP (uint8_t mux_id, String addr, uint32_t port) : Create TCP connection in multiple mode.
69 bool releaseTCP (uint8_t mux_id) : Release TCP connection in multiple mode.
71 bool registerUDP (uint8_t mux_id, String addr, uint32_t port) : Register UDP port number in multiple mode.
73 bool unregisterUDP (uint8_t mux_id) : Unregister UDP port number in multiple mode.
75 bool setTCPServerTimeout (uint32_t timeout=180) : Set the timeout of TCP Server.
77 bool startServer (uint32_t port=333) : Start Server(Only in multiple mode).
79 bool stopServer (void) : Stop Server(Only in multiple mode).
81 bool startTCPServer (uint32_t port=333) : Start TCP Server(Only in multiple mode).
83 bool stopTCPServer (void) : Stop TCP Server(Only in multiple mode).
85 bool send (const uint8_t *buffer, uint32_t len) : Send data based on TCP or UDP builded already in single mode.
87 bool send (uint8_t mux_id, const uint8_t *buffer, uint32_t len) : Send data based on one of TCP or UDP builded already in multiple mode.
89 uint32_t recv (uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from TCP or UDP builded already in single mode.
91 uint32_t recv (uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from one of TCP or UDP builded already in multiple mode.
93 uint32_t recv (uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from all of TCP or UDP builded already in multiple mode.
98 - RAM: not less than 2KBytes
99 - Serial: one serial (HardwareSerial or SoftwareSerial) at least
101 # Suppported Mainboards
103 - Arduino UNO and its derivatives
104 - Arduino MEGA and its derivatives
105 - [Iteaduino UNO](http:
108 # Select the version of
ESP8266 AT Firmware
110 At present, this library supports
ESP8266 AT 0.18 version and 0.22 version. You
111 can select one of them to fit your module by modifing this line in `
ESP8266.h`:
115 If you want to select 0.22 version, it should be like below after modification:
120 # Using SoftwareSerial
122 If you want to use SoftwareSerial to communicate with
ESP8266, you need to modify
127 After modification, it should be:
129 #define ESP8266_USE_SOFTWARE_SERIAL
132 # Hardware Connection
134 WeeESP8266 library only needs an uart for hardware connection. All communications
135 are done via uart. In each example, you must specify the uart used by mainboard
136 to communicate with
ESP8266 flashed AT firmware.
138 ## MEGA and WBoard Pro
140 For MEGA and WBoard Pro, `Serial1` will be used if you create an object (named wifi)
141 of class
ESP8266 in your code like this:
146 The connection should be like these:
156 To use SoftwareSerial, `mySerial` will be used
if you create an object (named wifi)
157 of
class ESP8266 in your code like this:
160 #include <SoftwareSerial.h>
162 SoftwareSerial mySerial(3, 2);
165 The connection should be like these:
175 The size of data from
ESP8266 is too big for arduino sometimes, so the library can't
176 receive the whole buffer because the size of the hardware serial buffer which is
177 defined in HardwareSerial.h is too small.
179 Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`.
180 See the follow line in the HardwareSerial.h file.
182 #define SERIAL_BUFFER_SIZE 64
184 The default size of the buffer is 64. Change it into a bigger number, like 256 or more.
187 -------------------------------------------------------------------------------
191 -------------------------------------------------------------------------------
Provide an easy-to-use way to manipulate ESP8266.
#define USER_SEL_VERSION
You can modify the macro to choose a different version.