Wednesday, 22 July 2015

My adventure with ESP8266 (2/2): flash it!

Introduction 
The first part is here and it is about:
  • hardware
  • software
  • firmwares
  • nodemcu
It contains important information to understand this part.

Wirings
This table show how to connect the hardware together:


Pay attention to GPIO0, you need it connected only for flashing.

Flashing!
It's time to flash the device with a new firmware using esptool.
I decided to flash a nodemcu firmware.
Connect the GPIO0 to GND and than power on the device.
On my installation on OSX I did this command to flash the device:

python esptool.py -p /dev/tty.usbserial write_flash 0x00000 nodemcu_21072015.bin

If everything is ok, you should see this message:


Power off the esp8266 than remove the GPIO0 connection and than power on the chip again.

Talk with ESP8266
Now, it's time to talk with the chip.
I use kermit with this .kermrc configuration:

set carrier-watch off
set line /dev/tty.usbserial
set speed 9600

than you can press "c" to connect and typing print ("hello"); you should see the device responding hello back.
Now you can test some commands.

If you have downloaded the luatool, you can write your programs in a text file with lua extension and upload on the board with

python luatool.py --port /dev/tty.usbserial --src main.lua --dest main.lua --baud 9600

Lua files
Now, you can connect to the esp8266 and type dofile("main.lua"); to run the program.

If the file you are loading on the device, it is called init.lua the esp8266 at every boot will load it: pay attention, a bad init script can block the device forever... The only solution in this case is a re-flash of the device.

If you have any question, feel free to ask in the comments section.
If you like the article please share it! :)

my wirings :)