Software Serial Esp8266 Programming
- Software Serial. Chat here about code. This from Github ESP8266/Arduino - Read me Serial. I need to flash program ESP8285 ICs for production[] READ MORE.
- Jan 1, 2015 - Basic serial communication with ESP8266 // Uses serial monitor for communication. Start the software serial for communication with the ESP8266. Put your program in too it but when I power up my ESP8266 module it start.
Nov 16, 2016 - To program settings on the ESP8266, we'll first need to connect it to a serial terminal on a computer through which we can send it special.
I bought the NodeMcu Lua ESP8266 ESP-12E + WiFi Motor Drive Expansion Board from a supplier in China. They arrived within two weeks. It was cost effective to buy the ESP8266-12E board with the Motor Drive Expansion Board. I paid $11.64 for the pair. More about the programming of the Motor Drive Expansion Board in a later instructable.
For the purpose of this instructable you only need the NodeMcu Lua ESP8266 ESP-12E WIFI Development Board. There are several benefits of using this development board rather than the module, the chief among them is - being able to use it right out of the box. It comes with the necessary circuitry to manage the voltages. The on-board USB to UART makes interfacing with computers a lot simpler.
The ESP8266-12E boards arrived in an anti-static bags. There was no USB cable. This board has a micro USB connector. I tried connecting the micro USB cable that came with my android charger. That did not work because it is not a data cable. I had some spare micro USB data cables sitting around and found one that worked.
ESP8266: Wire & Configure
Before attempting to use ESP8266 Module with a microcontroller like Arduino it is a good idea to test and get familiar with it by using a USB-to-Serial converter. With the converter AT commands can be issued directly to the module. Since some functions are not available on older firmware versions it is advisable to flash ESP8266 Wi-Fi module firmware to the latest version before proceeding to configure it.
Wire ESP8266 & FTDI Programmer
ESP8266 chip comes in several different packages. ESP-07 package is SMD and requires additional connections to be made. With ESP-07 pin GPIO15 need to be connected to Ground. A 10k resistor in series can be used but in practice is not needed and does not cause any noticeable effects. Before connecting power make absolutely sure that the FTDI Programmer provides 3.3V and not 5V as it could destroy the ESP8266 module. To put the module into flash mode GPIO0 pin also need to be connected to ground.
Schematic of ESP8266 module in ESP-07 package connected to an FTDI programmer.
Sending RS-232 / Serial Commands
FTDI programmer or other USB-to-Serial adapter connect the ESP8266 module to a computer. To access and interpret the data being received and to send data a terminal emulator is needed.
Putty is a popular option on Windows. It has in-built Serial terminal but does not work with older ESP8266 firmware versions. With latest ESP8266 firmware it works reliably but lack some convenient features. Putty is a good option as it can be used for many other tasks such managing Unix based operating systems remotely.
A standalone option for Windows is termite. Unlike Putty it does one thing only and does it well. It is simple and works reliably even with older ESP8266 firmware versions.
Check ESP8266 Firmware Version
Show the module firmware version.
Snow leopard download. The output should be the AT firmware version along with the date and time it was compiled and the date the firmware was issued.
Save Power by Putting ESP8266 to Sleep
Put the module into deep-sleep mode.
The only parameter specifies the length of time that the module should sleep for and is specified in milliseconds (ms). A value of 1000
will put the module to sleep for 1 second. The module will not respond to the usual AT commands while in sleep mode so care should be taken not to very large values or the module may need to be power cycled to regain access to it.
Set ESP8266 Operating Mode
Set the operating mode of the module.
STA mode is short for Station while AP is an acronym for Access Point and AP+STA is a combination of both modes. Station mode allows the module to behave as only a client and connect to an access point – commonly a router. Access point mode allows other clients including ESP8266 module in STA mode to connect to it. AP+STA mode allows both modes of operation simultaneously. This means the module can connect to clients and clients can connect to the module at the same time. With this mode a bridge can be formed allowing the module to relay network packets from any device type to any other device type such as AP to AP.
Esp8266 12e Projects
Once the mode has been set, configure ESP8266 Wi-Fi module as an access point and/or configure ESP8266 Wi-Fi module as a station / client.
Toggle ESP8266 Command Echo
Optionally disable AT command echo.
Default setting is ATE1
which will return the AT command entered before outputting the response.
Set ESP8266 Baud Rate
Baud rate determines how fast the serial data is transmitted. Software serial library on Arduino is limited and can become unreliable at higher baud rates. Since older firmware versions have 115200 baud rate by default and do not have the ability to change it it is necessary to flash ESP8266 module firmware to a newer version to be able to use it with software serial library.
Check the current baud rate.
Check possible valid baud rate range.
Set the baud rate.
Reset the module to make sure the changes take effect.