Recently stumbled across an interesting open source project ESP-Link. Its main purpose is to network-enable a non-network microcontroller (MCU) such as Arduino Uno, Pro mini or Nano using ESP8266. The author termed it as "Transparent Bridge". The ESP and MCU communicate via the serial link and there is a companion Arduino library EL-Client for the MCU to connect up the network using MQTT, REST, TCP and UDP.
I have put together an ESP-01 and an Arduino Pro Mini for this experiment. I have chosen a 3.3 version Pro mini so that I do not need to do any voltage level shifting between the I/O pins. In order to have a stable voltage source, the ESP8266 is powered by Pro Mini and the Pro Mini "RAW" pin is connected to a 5v USB power source. The RAW pin can take voltage up to 12V. The reset pin of Pro Mini is connected to GPIO 0 of ESP-01. This enables the ESP-01 to reset the Pro Mini.
I have linked up an APDS 9960 sensor to it and periodically send the luminosity and RGB colour level to an MQTT server. APDS 9960 is a very interesting sensor, it is a luminosity, colour, proximity and gesture sensor (All in one). The source code can be downloaded from GitHub.
Flashing the ESPThe flashing parameters for ESP-01 are:
After successful flashing the ESP, it will start up as AP mode. I need to join the computer to 192.168.4.1 to configure the ESP to join to my home network.
esptool --port com26 --baud 230400 write_flash -fm qio -fs detect -ff 40m 0x0 boot_v1.6.bin 0x1000 user1.bin 0xfc000 esp_init_data_default.bin 0xfe000 blank.bin
OTAThere are many methods of OTA mentioned in the documentation. The one I am using is avr-link which can upload the Arduino compiled sketch to the MCU. To do this, compile the Arduino sketch as normal and upload the .hex file using avr-link. In the Arduino output directory, there are 2 .hex files, "samplesketch.ino.with_bootloader.hex" and "samplesketch.ino.hex", upload the file without the bootloader.
e.g avr-link flash --esp 192.168.0.50 --file samplesketch.ino.hex -v
Wrapped up ThoughtsThis is an interesting concept from a technical standpoint but there are many competing solutions such as ESP32 family that can do more on a single board and lower cost. On the other hand, if you have invested in many of the Arduino shields, this is a viable alternative to network enables the existing microcontrollers.
Update: I have another setup using the integrated ESP8266 and Mega2560 board using the similar setup without messy wiring between ESP8266 and the microcontroller.