How cool would it be to add WiFi support to any projects or IoT? Why not using WiFi with a microcontroller which has only few KBytes of RAM and FLASH. For less than US$5? Dreams came true, and intrigued by an article at Hack-A-Day, I searched a supplier for that ESP8266 module. And this evening I have found the four ESP8266 modules I have ordered for $4.50 each from ElectroDragon in my mailbox. Of course I did not want to wait for the week-end, so I hooked it up to my FRDM-KL25Z board.
I already love a very similar module, the nRF24L01+ (see “Tutorial: Nordic Semiconductor nRF24L01+ with the Freescale FRDM-K64F Board“). The ESP8266 looks is similar from the size and connection header, but instead of SPI it uses UART mode with AT commands. So it is much more like one of the HC-06 Bluetooth modules (see “Getting Bluetooth Working with JY-MCU BT_BOARD V1.06“).
Main features of the module (from http://www.electrodragon.com/w/Wi07c):
- 2.4 GHz WiFi 802.11 b, g and n
- Supports WPA/WPA2 security mode
- 14 mm x 24 mm module size
- AP (Access Point), STA (standalone) and AP+STA modes
- Simple AT commands to join router, run TCP client and TCP server
- Built-in TCP/IP Protocol stack
- PCB antenna
There are only a few pins needed for connecting it to a microcontroller, and by default the module features a serial UART interface:
The module is all using 3.3V logic levels.
- Vcc: 3.3V, up to 300 mA
- GND: Ground
- Tx: UART Tx of the module, to be connected to the microcontroller Rx of the microcontroller
- Rx: UART Rx of the module, to be connected to the microcontroller Tx of the microcontroller
- RST: Reset/Restart, pull to GND to restart
- CH_PD: Chip enable, used for flash boot and updating the module
- GPIO0: pulled low for update mode
- GPIO2: not sure yet???
The processor on the board is a Tensilica Xtensa LX3 32bit, clocked at 80 MHz, and it has an SPI flash on the module/board. There is now even a gcc port/environment for it (see http://www.esp8266.com/viewtopic.php?f=9&t=224), so if I want, I can write and update code for that module :-). So with this, I can run the module standalone, and even do not need another microcontroller. Very neat!
But to get a first response from the module, there were several problems to solve:
- Data sheet is in Chinese. Luckily, there are already some Google Translation version in the community (see links below)
- Many posts and articles mention a baud rate of 57600. But the issue is that newer modules use 115200, and of course mine was using 115200 🙂
- The module is rather power-hungry, some articles talk about 80 mA or even up to 260 mA (!!!!). To protect my FRDM board, I’m using a 3.3V DC-DC converter.
- Some posts indicate that only Vcc (3.3V), GND, Tx and RX need to be connected. Until I found a post indicating that all the other pins need to be pulled up at Vcc too.
And finally, the module responded to my AT command: I send “AT\r\n”, and it responds with “AT\r\n\r\nOK\r\n”, hurray! 🙂
So I’m not communicating with the world yet. But at least the microcontroller can talk to the module. To be continued…..
- Hack-A-Day article: http://hackaday.com/2014/08/26/new-chip-alert-the-esp8266-wifi-module-its-5/
- Hack-A-Day project: http://hackaday.io/project/2879-ESP8266-WiFi-Module-Library
- ESP8266 Forum: http://www.esp8266.com/
- AT command overview: http://www.electrodragon.com/w/Wi07c
- NURDs page on ESP8266: https://nurdspace.nl/ESP8266
- First impressions on the ESP8266 module: http://rayshobby.net/?p=9734
- Using the ESP8266 module: http://www.instructables.com/id/Using-the-ESP8266-module/?ALLSTEPS
- GCC for ESP8266: http://hackaday.com/2014/10/02/gcc-for-the-esp8266-wifi-module/
- Module at iteadstudio: http://imall.iteadstudio.com/im140905002.html
Happy WiFi’ng 🙂