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…..
Links:
- 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 🙂
Please keep us posted on how you go with this module. I recently noticed a similar module (if not the same) at http://imall.iteadstudio.com/im140905002.html and the price made it look quite attractive.
LikeLike
Yes, that’s the same module! Thanks for the link, as it contains some more data sheet information I have not seen yet.
LikeLike
Great find Erich. Was starting to look for a solution for a school project I put together and have to manage, this one is going to grow. Thanks for the post and the fact it will work.
LikeLike
Yes, this ESP8266 seems to get viral all over the place. It perfectly hits a common need, and compared to other solutions it costs only a fraction of it. Yes, I will not be usable to host a complex and very fast web server. But it is a cheap and simple way how to implement small sensor gateway to the internet.
LikeLike
Got one of these too, managed to get as far as getting an IP address from AP using AT commands, whenever i tried to open a port as either client or server got some errors :(.
Have now built the tool chain, and using that built the IoT example code, ready and waiting to flash it, but the module is out in my garage and I’m off to bed now, a bit of fun for tomorrow evening.
LikeLike
I got stuck due other priorities. I have updated the sources to handle the return strings in a more elegant way. I plan to continue to work on it on the coming week-end.
LikeLike
Pingback: Tutorial: Web Server with the ESP8266 WiFi Module | MCU on Eclipse
Pingback: Apresentando o módulo ESP8266 - Embarcados - Sua fonte de informações sobre Sistemas Embarcados
Pingback: Apresentando o Módulo ESP8266 | André Curvello
Pingback: ESP8266 - podłączenie i aktualizacja firmware Ostatnio na blog... | Sputnik