ESP-WROOM-02 flashing and applications

From Take-Air Wiki
Jump to navigation Jump to search

The onboard ESP-WROOM-02 module can be programmed with any custom firmware to provide highly flexible 2.4GHz WiFi functionality. The module can for example be used to provide a data interface to the Jetson module over wifi, or to provide a WiFi beacon that transmits flight characteristics to comply with French drone laws, see e.g. https://github.com/khancyr/droneID_FR.

ESP firmware flashing

The module is connected over UART to the Jetson module. In normal operation this UART interface can be used to communicate between the Jetson and the ESP, but it is also used for flashing new firmware to the ESP. To do so, follow the instructions below.

Flashing instructions

Esptool is required for flashing, follow the instructions below to install it:

  1. Connect to the Jetson module over ssh (or using remote desktop if it is set up)
  2. Make sure the user has access to the serial ports (replace <username> by your username):
    sudo usermod -aG dialout <username>
  3. Reboot:
    sudo reboot
  4. Connect again to the Jetson module.
  5. Stop and disable the service already using the serial port:
    sudo systemctl stop nvgetty
    sudo systemctl disable nvgetty
  6. You may update the packages (if you don't, it might return an error on the next installation step on a fresh install):
    sudo apt update
  7. Install pip for Python3:
    sudo apt install python3-pip
  8. Install virtualenv (tool to create isolated Python environments):
    sudo pip3 install virtualenv
  9. Download the script for automatic flashing is available, download it using:
    cd ~; git clone https://github.com/TakeAirRobotics/OpenOC2_ESPFlash.git
  10. Create a virtual environment using python3 in the project folder:
    cd OpenOC2_ESPFlash
    virtualenv -p python3 env
  11. Enable the virtual environment:
    source env/bin/activate
  12. Install esptool (https://github.com/espressif/esptool) using pip:
    pip install esptool
  13. Flash the ESP using the demo code (it can be replaced by the name of your binary).
    ./OOC2_ESPFlash.sh OpenOC2-ESPDemo.bin
  14. Follow the onscreen instructions. You will be asked to close and open jumper J9 which can be found on the Jetson side of the board, near the ESP module.
  15. When completed, the access point "Open.OC 2" should appear on WiFi capable devices:

ESP WIFI.png

Troubleshooting

  • If the access point "Open.OC 2" does not show up but there is an access point named "ESP-02E96A" (or similar), it is likely that the default firmware is still running and that the module didn't get flashed.