ESP8266: flashing the lua firmware and running some code

After you setup your ESP8266 module as described here you can go on and write Arduino code that talks to the ESP8266 or even flash new firmware directly on the device. Someone has put together a firmware which allows you to send lua code to the module and run it through the serial console. This is a nice way to get started with programming the module directly instead of using an Arduino intermediary. This post describes how you can flash a new firmware on the module.

Getting the wiring right

Make sure you already have the wires setup as described in the previous post. Now the module needs to be put in a ready-to-flash-firmware state. 
  1. Add a wire between GPIO0 pin and the Ground pin (GND)
  2. Now reset the module be quickly connecting the RST pin to the GND pin (in my case the blue LED flashes quickly)

Getting the flash tool ready

In order to write new firmware to the module you’ll need to use a tool, the serial console isn’t helpful in this case.
  1. Download the from here
  2. Make it executable and run it with ./ –help. On my Mac OS X machine I got an error, that the serial library is nowhere to be found. Because of this I had to
    1. brew install python
    2. pip install pyserial
    3. make sure that you will use the python installed by brew
  3. Download the lua firmware from here (the nodemcu_512k.bin file)
  4. Find out the port your FTDI controller or your Seeeduino is connected to. In my case I used the Arduino IDE to find the port and make sure no console is currently connected to the Arduino
  5. Replace tty.usbserial-A901LKQM with your actual com-port --port /dev/tty.usbserial-A901LKQM write_flash 0x000000 nodemcu_512k.bin
  6. Remove the connection between GPIO0 and GND
  7. Reset the module again by connecting RST quickly to GND
Related:  New Feature: Copy items to another feed

Running Lua examples on the module

  1. Open a serial console and connect it with your Arduino or FTDI controller. I opened the console in the Arduino IDE and set the baud rate to 9600
  2. Run enter this Lua code into the console (you may have to enter it line by line):
  3. Run more examples from here

Update 2015-01-04

I had some problems with the stability of the ESP8266 chip. It would reboot randomly and quite soon I suspected the power supply. After I switched from the Seeeduino 3.3V power to this power supply, those problems went away:


Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!