On a recent trip to Chicago a friend gave me a small pack of 4 x ESP01 boards each of which contains an ESP8266. These were surplus to his requirements, I was intrigued by how small they were and seemingly quite capable too. They are tiny 3.3v boards with built in WiFi and by default have 2 usable GPIO's. There is a small hack to get 2 more GPIO's but currently I have no need for more than 2.

There are various firmwares for these devices they can run Arduino/Sketch, NodeMCU, Ai Thinker, Expressif etc, but I settled on MicroPython because I'm farmiliar with Python and the learning curve would be easier.

My friends programmer was hosed, so I odered a new one from China but there was 3 week delivery window. I was desperate to get going with these little powerhouses so I went about making my own programmer using a USB => TTL converter that I already had as a stop gap. Exhibit A:

There are various programmers, some with 0 buttons, some with 1 button, some with 2 buttons. As you can see the one I made has 2 buttons "R" Reset, and "F" Flash. To get the board in programming mode while connected to the computer, with the 2 button programmer you need to press and hold the Reset button then press and hold the Flash button, release the Reset button but keep holding the Flash button (I should have used a SPST switch here). With a one button programmer simply switch to "PROG" then plug it in to the computer.

You can find the latest image for MicroPython here make sure it is in the same directory you are executing the commands from.

Once in Programming Mode you first need to Erase the board, note I'm using a Mac but I guess the commands are similar for Windows.

esptool.py --port /dev/cu.usbserial erase_flash

Then once erased you need to release the flash button, then repeat the procedure to put it back in programming mode; or if using the 1 button programmer remove and re-plug the USB. Then to send the firmware (adjusting the image name accordingly):

esptool.py --port /dev/cu.usbserial --baud 460800 write_flash --flash_size=detect 0 esp8266-20180511-v1.9.4.bin

Once you have the MicroPython firmware flashed, you can release the Flash button and then press the Reset button to reboot the device, or unplug the one button programmer, switch it back to UART mode and plug it back in.

Your options from here are varied, you can use a terminal program to talk to the board over serial (gets you a Python prompt), you can use the WebREPL scripts on a web server to get a remote Python prompt etc. After various tinkerings I found the uPyCraft program which works on both Mac and Windows and gives an easy way to transfer files to and from the device:


From here its all about the MicroPython code, which while very similar to Python doesn't have all the same modules avaliable. A good resource for getting started with MicroPython on the ESP8266 is located here.