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 Wi-Fi functionality. The module can for example be used to provide a data interface to the Jetson module over Wi-Fi, or to provide a Wi-Fi beacon that transmits flight characteristics to comply with French drone laws, see e.g. https://github.com/khancyr/droneID_FR.

ESP firmware flashing

The ESP-WROOM-02 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

  1. Connect to the Jetson module over ssh (or using remote desktop if it is set up)
  2. Allow the user to access to serial ports(replace <<USERNAME>> by your username):
    sudo usermod -aG dialout <<USERNAME>>
  3. Reboot:
    sudo reboot
  4. Connect again to the Jetson module.
  5. Make sure that the user has access to the gpios (by default) and to the serial ports. To do so, type groups in the terminal, it should return a list which includes gpio and dialout.
  6. Stop and disable the service nvgetty already using the serial port:
    sudo systemctl stop nvgetty
    sudo systemctl disable nvgetty
  7. 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
  8. Install pip for Python3:
    sudo apt install python3-pip
  9. Install virtualenv (tool to create isolated Python environments):
    sudo pip3 install virtualenv
  10. Download the script for automatic flashing is available, download it using:
    cd ~; git clone https://github.com/TakeAirRobotics/OpenOC2_ESPFlash.git
  11. Create a virtual environment using Python3 in the project folder:
    cd OpenOC2_ESPFlash
    virtualenv -p python3 env
  12. Enable the virtual environment:
    source env/bin/activate
    The name of the current virtual environment will appear on the left of the prompt (e.g. (env)) to let you know that it’s active.
  13. Install esptool (https://github.com/espressif/esptool) using pip:
    pip install esptool
  14. Flash the ESP using the demo code (it can be replaced by the name of your binary).
    ./OOC2_ESPFlash.sh OpenOC2-ESPDemo.bin
  15. 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.
  16. When completed, the access point "Open.OC 2" should appear on Wi-Fi capable devices:
    ESP WIFI.png
  17. To exit the Python virtual environment:
    deactivate

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.