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.
- Add a wire between GPIO0 pin and the Ground pin (GND)
- 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.
- Download the esptool.py from here.
- Make it executable and run it with ./esptool.py –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
brew install python
pip install pyserial
- make sure that you will use the python installed by brew
- Download the lua firmware from here (the nodemcu_512k.bin file)
- 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
- Replace tty.usbserial-A901LKQM with your actual com-port
esptool.py --port /dev/tty.usbserial-A901LKQM write_flash 0x000000 nodemcu_512k.bin
- Remove the connection between GPIO0 and GND
- Reset the module again by connecting RST quickly to GND
Running Lua examples on the module
- 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
- Run enter this Lua code into the console (you may have to enter it line by line):
print(wifi.sta.getip()) --0.0.0.0 wifi.setmode(wifi.STATION) wifi.sta.config("SSID","password") print(wifi.sta.getip()) --192.168.18.110
- Run more examples from here
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:
Did you like this post? Consider supporting me with a virtual coffee or beer.