This post summarizes the steps to program an ESP8266 with an own program written with Arduino IDE. I used the ESP8266 for example in the project MANU – 3D printed robot hand.

Installation of Arduino IDE

First, the latest version of the Arduino IDE needs to be downloaded and installed from here.

Arduino IDE

Installation of ESP8266 Arduino Core

To program the ESP8266 with the Arduino IDE, you need to install the board information first in Arduino IDE. To do that follow following instructions:

  • Start Arduino and open the Preferences window.
  • Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into the Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and find esp8266 platform.
  • Select the version you need from a drop-down box.
  • Click the install button.
  • Don’t forget to select your ESP8266 board from Tools > Board menu after installation.

You find this guide also here: Installing — ESP8266 Arduino Core 3.0.0-15-g325619a4 documentation (arduino-esp8266.readthedocs.io)


Installation of ESP8266FS

You can save files on the filesystem of the ESP8266 Board. To upload files to this file system you can use the tool ESP8266FS. ESP8266FS is a tool that integrates into the Arduino IDE. It adds a menu item to the Tools menu for uploading the contents of the sketch data directory into the ESP8266 flash file system.

  • Download the tool: Download ESP8266FS-0.3.0.zip from GitHub
  • In your Arduino sketchbook directory, create a tools directory if it doesn’t exist yet
  • Unpack the tool into the tools directory (the path will look like <home_dir>/Arduino/tools/ESP8266FS/tool/esp8266fs.jar)
  • Restart Arduino IDE
  • Open a sketch (or create a new one and save it)
  • Go to sketch directory (choose Sketch > Show Sketch Folder)
  • Create a directory named data and any files you want in the file system there
  • Make sure you have selected a board, port, and closed Serial Monitor
  • Select Tools > ESP8266 Sketch Data Upload. This should start uploading the files into the ESP8266 flash file system. When done, the IDE status bar will display SPIFFS Image Uploaded message. 

You find this guide also here: Filesystem — ESP8266 Arduino Core 3.0.0-15-g325619a4 documentation (arduino-esp8266.readthedocs.io)


Hardware setup for flashing

As the ESP8266 do not have a USB Port you need to use some additional components for flashing:

  • ESP8266 Module
  • FTDI Adapter FT232RL USB to TTL Serial for 3,3V and 5V
  • Own build adapter PCB
Own build adapter PCB to flash ESP8266
Schematic of own build adapter PCB.
Instead of little buttons/switches I used simple jumpers in the real PCB for the CHIP_EN and bootloader mode pins.

Upload a program to ESP8266

  • Mount the jumpers on the PCB to activate bootloader mode and enable the chip.
  • Connect your ESP8266 Board via the FTDI Module to your computer (see chapter Hardware setup).
  • Open your program in the Arduino IDE.
  • Select Tools->Board->Generic ESP8266 Module.
  • Set the Upload speed to 115200.
  • Make sure the right Port is selected.
  • Click on the upload button in the Arduino IDE to upload the program to the ESP8266 Module.
Board setup in Arduino IDE

After upload you can remove the bootloader mode jumper on the PCB and press the reset button to get out of the bootloader mode.


Code – Examples

You find some code examples here:

Flash firmware to ESP8266 (.bin files)

This is what I did to flash my ESP8266 – 01 from my windows pc
– Wire it up like this
– Install python 2.7 download here
– Install pyserial download here
– Download to the esptool.py from here save it in the pyton installation folder
– Build and download your nodemcu_latest.bin from here and save it in the python installation folder

– Edit esptool.py so that:
ESP_RAM_BLOCK = 0x180
ESP_FLASH_BLOCK = 0x40

– Open cmd and go to the python folder and type in this (change the COM7 to whatever your FTDI is)
esptool.py -p COM7 write_flash 0x000000 nodemcu_latest.bin

References

ESP8266 und ESP8285 Module Anleitung (stefanfrings.de) -> more information about ESP8266 (pinning, schematics, variants, AT firmware, ….)

ESP8266 Over The Air (OTA) Programming In Arduino IDE – 3 Steps (lastminuteengineers.com) -> guide/information about OTA update of ESP8266

ESP AT firmware: https://www.espressif.com/en/support/download/at

ESP firmware: https://github.com/Edragon/esp_firmware

Good Tool to write lua code and send AT commands: https://github.com/4refr0nt/ESPlorer

Share this post
Categories: Arduino

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *