I’ve been playing around with these chips for a little bit and I figured I’d share some gotchas I’ve had with using them.
For those not aware, the ESP8266 is a <$5 wifi module with a built in TCP/IP stack and wireless that can be commanded over serial with its default firmware, adding wifi features to an arduino on the cheap. It operates at most on 3.3v and can run off two AA batteries.
There are also new customized firmwares that allow you to directly program the 32-bit processor onboard like nodemcu, micropython and esp8266webserver. You can also write your own firmware for it in C using the manufacturer provided full SDK for the chip.
I’ve mostly played with nodemcu so my posts will probably focus around that. nodemcu is a custom firmware for the esp8266 that allows you to write code in lua to run on it. It currently supports using all of the wifi, IP and GPIO functions on the chip and is a fairly robust option. You can also save your lua code onto the chip to run at startup every time.
Flashing nodemcu can be done with an ftdi programmer at 3.3v and there is a very good tutorial on this at http://importhack.wordpress.com/2014/11/22/how-to-use-ep8266-esp-01-as-a-sensor-web-client/
Note however the following roadblocks:
FTDI
FTDI has released a version of their drivers that will detect and brick non-genuine FTDI clones. This means you may have ended up with an FTDI programmer that stops working when you plug it into a windows PC as this version of the FTDI driver is pushed by Windows Update. You will want to install version 2.10.00 which is available on FTDI’s site under 'No longer supported"
If you happen to install the 2.12.00 drivers accidentally, you will need to download the CDM Uninstaller tool from http://www.ftdichip.com/Support/Utilities.htm and then run CDMUninstallerGUI.exe from within the zip.
Hit Add and then ‘Remove Devices’ and this will uninstall the drivers that cause bricking. You should then install the 2.10.00 VCP drivers as above.
If your device is still not working (On windows, linux OR mac) follow the instructions In this Video which requires downloading MProg from the utilities page at http://www.ftdichip.com/Support/Utilities.htm
ESP-01 Pinout
In the blog post I linked it shows the following wiring setup:
I spent ages pissing around trying to program this until I realised that to be programmed you need the following:
- CH_PD to be connected to VCC (or the 3.3v pin on the ftdi programmer)
- GPIO0 to be connected to the GND (or the GND pin on the FTDI programmer)
Then, once it’s programmed you need to have CH_PD to be connected to VCC (3.3v) permanently otherwise it won’t respond to any serial commands. I’m not sure why this is and am following up the docs to find out why.
Once Programmed
You can now do cool shit on nodemcu in lua, like hosting webservers, posting to thingispeak GPIO values, turning on and off leds remotely.
Just make sure you read up on nodemcu and the esp8266 forums as there are guides on saving the lua code you input into a file that the esp8266 runs on boot.
Hello world