This section is not part of the Grow Tent project.
Some parts of the grow tent project can be useful in other fields. In this case, wirelessly read and write the Serial port (3.3V or 5V TX/RX ) of any device using ESP-link.
The ESP-01S module adds WiFi access to an Arduino, allowing it to send data using REST API, or send/receive MQTT messages with the help of the ESP-link firmware.
Note: Since ESP-01S only has 8Mbit (1MB) flash storage it cannot act as a web server and host a User Interface for the Arduino. You need to have a Home Assistant server on your local network to host the UI. If you would like to host the UI straight from ESP-link check out the Mega2560 WiFi board or upgrade the ESP-01S flash chip to 32Mbit (4MB).
To upload the ESP-link firmware to the ESP8266 SoC we can use any Arduino board as a USB to Serial converter as long as the 5V logic level of the Arduino RX and TX pins are converted to 3.3V using a Logic level converter. Do not connect the TX and RX pins directly as the ESP chip does not tolerate 5V!
Update: ESP8266 does tolerate 5V on its IO pins according to Teo Swee Ann, founder and CEO of Espressif Systems:
"When we say 5 V tolerant, we are only referring to the IOs. So some users mistook this to make that they can power the chip entirely off the 5 V supply. The correct usage is to use 5V open for these 5V tolerant pins, and only via only drain configuration."
Based on Blinkmaker's Restore or Upgrade Firmware on ESP8266 (ESP-01) Module Using Arduino UNO guide.
Correction: The logic level converter in the above diagram is not needed, the bypass capacitors are optional.
There are a few special pins to highlight:
Arduino RESET: Connected to Ground during the entire flashing process. Disables the Arduino Mega2560 chip to prevent it from disrupting the USB-ESP communication
ESP RST: Normally not connected. Connect it to Ground for a few seconds to reset the ESP chip.
ESP IO0: Enables Download mode if it is connected to Ground when to ESP chip starts/resets. It can stay connected to Ground throughout the entire download process.
You also need to download three things:
ESP-link firmware: Get the later release ( esp-link-v3.2.47-g9c6530d.tgz).
Flash Download Tools (ESP8266 & ESP32 & ESP32-S2): V3.8.8 or later.
The files are also available under the Gbox420 GitHub repository's ESP-link folder.
Reset the ESP chip by temporarily touching the ESP RST wire to Ground after making sure the Arduino Mega2560 is disabled, the wiring is correct, and the ESP IO0 pin is connected to Ground. This should boot the ESP chip into Download mode.
Start the ESP download tool as Administrator and select the Arduino's COM port. Click Start without any further changes, the tool should detect the ESP module and display its properties under the DETECTED INFO section:
Load the ESP-01S files in the ESP8266 Download tool under the SPIDownload tab. Set the CrystalFreq and Flash size based on the DETECTED INFO. Set the SPI MODE to DOUT
Memory addresses for each file:
Boot_v1.7.bin @ 0x00000 - Bootloader
User1.bin @ 0x01000 - ESP link firmware
Esp_init_data_default_v08.bin @ 0xFC000
Blank.bin @ 0xFE000
Click the Start button and wait for the download process to finish:
Once the download is finished disconnect the IO0 from Ground. Open the Arduino IDE Serial Monitor and set the baud rate to 74880, then reset the ESP chip by connecting the RST pin to Ground for 1 second. The serial output should show the boot sequence of the ESP-link firmware:
After the initial boot the Serial output's baud rate will switch to 115200. Reset the ESP module after changing the baud rate in the serial monitor to view the rest of the ESP-link log output:
At this point, the ESP chip should start broadcasting a WiFi network called ESP_XXXXXX for the initial configuration of ESP-link. If you see the WiFi hot spot, change the wiring to the final layout:
Connect the RX and TX pins to the Arduino Serial 3 (TX3, RX3). This will separate the serial output of the Arduino and the ESP chip. Both will be visible on the ESP-link webpage.
Connect the Arduino RESET pin to the ESP IO0 pin through the logic level converter. This way the Arduino can be reset from the ESP-link web page (µC Concole tab - Reset µC button)
Proceed to the ESP-link setup section to configure the ESP-link features required for the Gbox420 sketch. Once you make it to the ESP-link's Home page, change the pin assignment Presets to esp-01:
On the Debug log tab make sure to disable the UART debug log by clicking the off button to free up resources. Only re-enable this feature if you need to debug REST API or MQTT messages and make sure to disable it once you finish working with it.
You can telnet to port 23 or 2323 of the ESP-link IP address and read the Arduino serial output: telnet XXX.XXX.XXX.XXX 23