This is an old revision of the document!
Table of Contents
Espressif Systems ESP8266
The Espressif Systems ESP8266 is used in cheap WiFi modules. It embeds an Xtensa LX3 CPU. ESP8266 boards named ESP-XX come with at least 1/2 megabyte of SPI flash for program storage.
Pinout
ESP-01
U0TXD 2 1 GND CHIP_EN 4 3 GPIO2 EXT_RSTB 6 5 GPIO0 VDD 8 7 U0RXD Component side with antenna to right
Power
A well regulated power supply is suggested. An LD1117 3V3 has been tested and works well.
3V3 ---------- VDD 3V3 ---10K---- CHIP_EN GND ---------- GND
AT firmware update
The default AT firmware can be updated using ESPTool.
To program the chip, keep GPIO0 low and reset the device on EXT_RSTB.
wget "https://wiki.kewl.org/downloads/v0.9.2.2 AT Firmware.bin" esptool.py --port /dev/ttyUSB0 write_flash 0x000000 "v0.9.2.2 AT Firmware.bin" Connecting... Erasing flash... Writing at 0x0007ef00... (100 %) Leaving...
AT console
The updated AT firmware uses 9600 baud by default, the original is 115200.
3V3 UART ESP-XX ======== ====== RX -- 470R -- U0TXD TX -- 470R -- U0RXD GND ---------- GND
picocom -b 9600 --omap crcrlf /dev/ttyUSB0 AT+RST ... [System Ready, Vendor:www.ai-thinker.com] AT+GMR 0018000902 OK AT+CWMODE=1 OK AT+CWLAP +CWLAP ...
The commands above reset the device, set its mode of operation and scan for access points.
NodeMcu
NodeMcu is a LUA interpreter than runs on the ESP-XX chip. It can be used to communicate over the network and control the GPIOs.
We will use ESPTool to install NodeMcu for esp8266.
git clone https://github.com/nodemcu/nodemcu-firmware git reset --hard fb967dd8a2c8282e146626642bf24e8c90cdbcd0 cd nodemcu-firmware/pre_build/0.9.5 esptool.py --port /dev/ttyUSB0 write_flash 0x000000 nodemcu_20150127.bin esptool.py v2.0-beta2 Connecting.... Detecting chip type... ESP8266 Uploading stub... Running stub... Stub running... Attaching SPI flash... Configuring flash size... Auto-detected Flash size: 512KB Flash params set to 0x0000 Compressed 395836 bytes to 267867... Wrote 395836 bytes (267867 compressed) at 0x00000000 in 23.5 seconds (effective 134.7 kbit/s)... Hash of data verified. Leaving... Hard resetting...
Build 20150212 firmware can be found in pre_build/latest/nodemcu_latest.bin
NodeMcu console
A regular console at 9600 baud is used to communicate with NodeMcu. The same connection scheme as per the AT console (above) is used.
picocom -b 9600 /dev/ttyUSB0 NodeMCU 0.9.5 build 20150127 powered by Lua 5.1.4 lua: cannot open init.lua > gpio.mode(3, gpio.OUTPUT) > gpio.write(3, gpio.HIGH) > gpio.write(3, gpio.LOW)
In the above we set GPIO0 to an output, set it high, then set it low.
NodeMcu pins
pin | GPIO | ESP-01 |
---|---|---|
0 | 16 | |
1 | 5 | |
2 | 4 | |
3 | 0 | 5 |
4 | 2 | 3 |
5 | 14 | |
6 | 12 | |
7 | 13 | |
8 | 15 | |
9 | 3 | |
10 | 1 | |
11 | 9 | |
12 | 10 |
Although the ESP-01 only has 2 GPIOs, NodeMcu has I2C support and a circuit such as this can extend its capabilities.