Introduction to Remote Programming of Arduino UNO via WiFi with ESP8266
In the expansive universe of IoT and embedded systems, the ability to remotely manage, monitor, and update devices is paramount. This capability not only enhances the flexibility and scalability of IoT networks but also ensures that devices, once deployed in the field, can be managed and updated without physical interaction.
This article will guide you through the methodology of remotely programming an Arduino UNO using ESP8266 modules, specifically focusing on NodeMCU and ESP01, utilizing the ESP-Link firmware. This firmware acts as a bridge, enabling WiFi and serial communication, thereby changing the way we interact with microcontroller boards like the Arduino UNO through ESP8266.
ESP8266: NodeMCU and ESP01 as a WiFi Bridge for Arduino UNO
The ESP8266, available in various forms like NodeMCU and ESP01, has become a staple in the IoT domain due to its affordability and ease of use with the Arduino IDE. While it can function as a standalone microcontroller with WiFi capabilities, in the context of this guide, we will utilize it as a WiFi bridge to enable remote programming of the Arduino UNO.
ESP8266 NodeMCU Pinout
NodeMCU is an open-source IoT platform that uses the ESP8266 WiFi module and is compatible with the Arduino IDE.
- VCC: Powers the module with 3.3V.
- GND: Ground pin.
- D0-D8: GPIO pins usable for various serial communication.
- RX and TX: Serial communication.
- RST: Reset pin.
- A0: Analog input.
- 3V3: 3.3V output.
- VIN: Voltage input.
ESP8266 ESP01 Pinout
ESP01 is a minimalistic variant of ESP8266 with fewer GPIO pins but maintaining core WiFi functionality.
- VCC: 3.3V power supply.
- GND: Ground pin.
- TX and RX: Serial communication.
- CH_PD: Enable pin.
- GPIO0 and GPIO2: General-purpose I/O pins.
- RST: Reset pin.
Here the devices WeMos D1 mini - NodeMCU V2 V2.1 V3 - esp01 - esp01 programmer
Utilizing ESP-Link Firmware for Remote Programming of Arduino UNO
The ESP-Link firmware is designed to enable the ESP8266 module to act as a transparent serial bridge for any microcontroller, thereby facilitating WiFi control and communication. This firmware allows the ESP8266 to communicate over WiFi and enables remote programming of the Arduino UNO, which is crucial for managing and updating devices deployed in various locations.
You can retrieve the latest version of ESP-LINK firmware from here. After the download, uncompress It, and download the Flash Download Tool from Espressif.
Wiring
For the NodeMCU, It’s simple: you must only connect the USB; for the ESP-01, you can follow the extensive guide here, or try these simple steps.
Get an FTDI from the link below.
Here the FTDI USB to TTL CH340G - USB to TTL FT232RL
So you must connect the device to the ESP-01 like so.
Now, to program, use the jumper of programming mode and click the reset button.
Flash the device
In the firmware folder, you can find these files
File description
boot_v1.6.bin
Description: This is the bootloader file responsible for initializing the hardware and loading the main firmware. It is the first code that runs when the device starts up. The version number (v1.7 in this case) indicates the bootloader’s version.
user1.bin
Description: This is the main application firmware, containing the compiled source code and assets required for the device’s specific functions. It gets loaded by the bootloader and takes over the main operation of the device. The “user1” designation generally indicates that this is the primary application space; in some configurations, a “user2.bin” could also exist for backup or alternate firmware.
esp_init_data_default.bin
Description: This file contains default initialization data for the ESP device. It is typically used to set default system configurations, including settings for the RF module, Wi-Fi parameters, and other hardware-related values.
blank.bin
Description: This file is usually filled with empty (zero) data and is used to clear or reset specific sectors of the flash memory. This is useful when upgrading firmware or ensuring that no residual data remains in these memory areas.
The firmware adapts to the flash chip’s size using information stored in the boot sector (address 0). This is the standard way that the esp8266 SDK detects the flash size. This means you need to set this properly when you flash the bootloader. If you use esptool.py you can do it using the -ff and -fs options. See the end of this page for instructions on installing esptool.py.
Addresses of 32mbit Flash Memory (4MB)
Devices like NodeMCU, WeMos D1 mini, and others use these settings.
Address | File Name | Size (MB) |
---|---|---|
0x00000 | boot_v1.6.bin | 0.5 |
0x01000 | user1.bin | 3.5 |
0x3FC000 | esp_init_data_default.bin | 0.1 |
0x3FE000 | blank.bin | 0.1 |
Here is an example of an
upload with esptool.py
:
esptool.py --port /dev/ttyUSB0 --baud 230400 write_flash -fs 32m -ff 80m \
0x00000 boot_v1.6.bin 0x1000 user1.bin \
0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
Addresses of 16mbit Flash Memory (2MB)
Some devices, like the updated DT-06, can use these settings.
Address | File Name | Size (MB) |
---|---|---|
0x00000 | boot_v1.6.bin | 0.5 |
0x01000 | user1.bin | 1.8 |
0x1FC000 | esp_init_data_default.bin | 0.1 |
0x1FE000 | blank.bin | 0.1 |
Addresses of 8mbit Flash Memory (1MB)
ESP-01S and some versions of DT-06 use these settings.
Address | File Name | Size (MB) |
---|---|---|
0x00000 | boot_v1.6.bin | 0.5 |
0x01000 | user1.bin | 0.9 |
0xFC000 | esp_init_data_default.bin | 0.1 |
0xFE000 | blank.bin | 0.1 |
Addresses of 4mbit Flash Memory (512Kb)
Original DT-06, ESP-01, and other little devices need these settings.
Address | File Name | Size (MB) |
---|---|---|
0x00000 | boot_v1.6.bin | 0.5 |
0x01000 | user1.bin | 0.4 |
0x7C000 | esp_init_data_default.bin | 0.1 |
0x7E000 | blank.bin | 0.1 |
With the Flash download tool, it’s quite simple. When you start Flash Download Tool you must select esp8266 and then start to configure It.
Here is an example of a configuration for the NodeMCU
First of all, I execute an ERASE
.
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 115200
Changed.
crc_efuse_4bit: 0
crc_calc_4bit: 6
Then, I proceed to the flash.
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 115200
Changed.
NO XMC flash detected!
crc_efuse_4bit: 0
crc_calc_4bit: 6
Flash will be erased from 0x00000000 to 0x00000fff...
Flash will be erased from 0x00001000 to 0x00051fff...
Flash will be erased from 0x003fc000 to 0x003fcfff...
Flash will be erased from 0x003fe000 to 0x0044efff...
Compressed 3856 bytes to 2763...
Compressed 330756 bytes to 244619...
Compressed 128 bytes to 75...
Compressed 330756 bytes to 244619...
is stub and send flash finish
After resetting, we can go to configure the device.
ESP-LINK configuration
Setting up the ESP-Link firmware on the ESP8266 module is a straightforward process, but for those unfamiliar, it can seem daunting. The firmware provides a user-friendly interface to configure the ESP8266, turning it into a versatile WiFi bridge. The following step-by-step guide, accompanied by screenshots for each phase, aims to simplify this process, ensuring a smooth and error-free setup for users of all levels of expertise.
Connecting to ESP Network
In this screenshot, you can see a list of available WiFi networks on a device. Prominently displayed is the ESP_XXXXXX network. This represents the Access Point (AP) mode of the ESP8266, which becomes active after the installation of the esp-link firmware. The user is advised to select this specific network to initiate the configuration process.
Main ESP-Link Page
Upon accessing the IP 192.168.4.1, the screenshot displays the main interface of the esp-link page. The central portion of the screen shows the current WiFi state. At the top, there’s a noticeable message stating that the device cannot perform scanning while in AP mode. This message serves as a reminder of the device’s current operational mode.
Navigating to WiFi Station Settings
This screenshot showcases the main esp-link page but with an expanded left-side menu. Among the various options, the WiFi station link is highlighted, indicating that the user has clicked or is about to click on it to access the WiFi station settings.
Switching to STA+AP Mode
The focus of this screenshot is the WiFi Station configuration interface. A prominent link labeled Switch to STA+AP mode is displayed. This option allows users to enable both the Station (STA) and Access Point (AP) modes simultaneously. The user is prompted to click this link to proceed.
Selecting a WiFi Network
In this phase, the screenshot reveals a list of available WiFi networks within the WiFi Station configuration screen. Users are guided to select their preferred network from this list. Adjacent to each network name is a field to input the network’s password. After entering the password, there’s a connect button to establish the connection.
Returning to the Main Page with DHCP IP
After connecting to a WiFi network, the screenshot returns the user to the main esp-link page at 192.168.4.1. The AP mode remains active, but now there’s an additional piece of information: the IP address assigned by the DHCP server. This IP is crucial for subsequent steps.
WiFi Station Screen with Connection Guidance
This screenshot of the WiFi Station screen provides users with clear instructions. A message informs users that if their device is on the same network, they should navigate directly to the IP address provided by the DHCP. If not, the first step is to connect to the network with the specified SSID.
Setting a Static IP
The final screenshot guides users on setting a static IP for their device. After connecting via the DHCP-assigned IP and accessing the WiFi station settings, users can scroll down to find an option to set a static IP. This feature ensures the device will always have the same IP address, making it easier to connect in the future.
Pin assignment
For the different devices, I use different configurations. Remember that the useful pin is the Reset to allow the program process.
Here is the configuration for ESP-01.
Here is the configuration for the NodeMCU.
Wiring Arduino for remote programming
As specified, with respect to debugging, we need an additional pin for programming, and It must be connected to the Reset pin of Arduino UNO.
Here is for ESP-01
Here is for NodeMCU
But remember that the logic of the Arduino UNO is 5v, so for long-running applications, inserting a logic-level converter is better.
Here the logic lever converter I use Aliexpress
Instead of logic lever convert, you can add a 10k resistor to reset and a voltage divider to the esp8266 Rx pin.
Create a virtual COM port
Now, we have an interface that communicates via WiFi to our device, but how do we connect to It? A versatile and beautiful system is to generate a virtual COM port.
One of the most used programs is “HW VSP3 – Virtual Serial Port”, you can download from this page, download the single one because the multi is a payment product.
After downloading, install It.
Click the Login
button and write admin as password.
You need to retrieve all the parameters from the ESP-LINK web interface.
In the Virtual Serial Port tab, choose the COM port number and insert the IP address and port 23. After that, click the button Create COM
.
Wait a moment; if It’s okay in the Device Manager, you can find your new Port.
Debug and upload the code
Now, if we connect our Arduino IDE to the Serial COM port 25, we can transmit and receive the Serial via WiFi.
Now we can try to upload, and finally, here is the result.
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\renzo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM25
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.21s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\renzo\AppData\Local\Temp\arduino\sketches\B3D8EDADAC2319C86E5C9AEF5B5AB344/sketch_oct2a.ino.hex"
avrdude: writing flash (2052 bytes):
Writing | ################################################## | 100% 7.80s
avrdude: 2052 bytes of flash written
avrdude done. Thank you.
Thanks
- Arduino Remote/wireless Programming
- BMP280, DHT11 and DHT22, DHT12, Dallas Temperature ds18b20, Thermistor
- ATtiny Programmer Board (ArduinoUNO As ISP)
- Send email with esp8266 and Arduino (Library v1.x)
- How to use SD card with esp8266 and Arduino
- Ebyte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and new Arduino shield
- Manage JSON file with Arduino, esp32 and esp8266
- How to interface Arduino, esp8266 or esp32 to RS-485
- Send emails with attachments (v2.x library): Arduino Ethernet
- WebSocket
- Arduino AVR: compiled binary (.hex) from command line and GUI tool
- Arduino: fast external SPI Flash memory
- GY-291 ADXL345 i2c spi accelerometer with interrupt for esp32, esp8266, stm32 and Arduino
- i2c Arduino: how to create network, parameters and address scanner
- GY-273 QMC5883L clone HMC5883L magnetometer for Arduino, esp8266 and esp32
- WiFi remote debugging of an Arduino with DT-06
- Program Arduino UNO Remotely via WiFi with DT-06 ESP-Link Firmware
- Introduction to Remote Programming of Arduino UNO via WiFi with ESP8266
esp-link is not only wireless serial bridge, this post covers about 1%, 3.2.x version has got lot of fixes and features.
Hi Bartlomiej,
It’s a very complete framework for IoT development.
Thanks for your clarification, Renzo