Skip to content

Programming ESP8266

Juraj Andrassy edited this page Mar 15, 2018 · 14 revisions

ESP8266 is supported in Arduino IDE with Arduino esp8266 core. It means that arduino sketch can be uploaded into ESP8266.

Install esp8266 packages

Arduino UNO WiFi Dev Ed is supported from version 2.4 of the esp8266 core for Arduino IDE. To install it using boards manager, follow the instructions.

Additionally, you can install the Arduino ESP8266 filesystem uploader IDE plugin

boards.txt patch

Default setting in boards.txt (in esp8266 package) for the 'Arduino' boards is:

arduino-esp8266.serial.disableDTR=true
arduino-esp8266.serial.disableRTS=true

Remove or comment this lines for convenient restarting of the board.

Location of the boards.txt on Windows is in users home folder, in a hidden folder AppData. Example `C:\Users\Duro\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1'.

For Mac and Linux location of Arduino15 folder read this forum post.

Board selection and options

In tools menu select board options. For Uno WiFi choose Arduino from the ESP8266 section of the Boards menu and next choose Model UNO WiFi.

esp8266 usage options:

  • CPU frequency option - recommended 80 MHz; 160 MHz produces more heat and has a higher power consumption
  • LwIP version - recommended v1.4; with 2.0 LwIP the Atmega sketch OTA upload fails, which indicates instability
  • Debug options: Disable and None; Serial output can be used with EspProxy to debug libraries used by esp sketch
  • Optimal flash size selection is "4M (1M SPIFFS)"
  • Erase flash: "Sketch only" recommended; choose "All flash content" after changing LwIP or SDK*
  • Upload speed: 115200 baud to match setting in EspProxy

From now on always check the selected board in the right bottom corner of the IDE window. For ATmega sketch it should show "Arduino UNO WiFi on ...", for the ESP sketch "Arduino, UNO WiFi, 80 MHz, 4M (1MB SPIFFS), v1.4 , Disabled, None, 115200 on ...".

"Erase flash" option is new in esp8266 Arduino package 2.4.1. To preserve SPIFFS and WiFi credentials use option "Sketch only". If changing from prebuild firmware, changing LwIP option or after a new version of esp8266 Arduino core package use "All flash content" to erase all parameters set be Espressif SDK. Erasing all SDK parameters can help if you experience WiFi connection stability issues.

Upload

Before using the Upload button with your ESP sketch, first Upload the EspProxy sketch into ATmega.

The EspProxy sketch detects uploading to esp from IDE and puts the ESP into bootloader mode. After the uploading the EspProxy returns to normal mode and bridges the Serial port of esp to USB for use of Serial Monitor with Serial of the esp.

Firmata with Uno WiFi

Firmata is a system for accessing pins and interfaces of a microcontroller (MCU) from a computer (or other MCU). Library FirmataMaster is for esp8266 and enables control of an attached MCU with Firmata.

Example UnoWiFiFirmata.ino from Uno WiFi Serial1 library, shows how to modify a Firmata sketch to work with Serial1 and combine it with EspProxy features to upload sketches into esp from IDE without thinking about how is it connected and without caring about flashing mode.

Clone this wiki locally