1. Getting EMIT ready for firmware development - ControlBits/EMIT GitHub Wiki
The processing power of the EMIT IoT development board, is provided by a low-cost, 30-Pin ESP32 DEVKITv1 module that includes the popular Espressif ESP32-WROOM-32 wireless IoT module with integrated dual-mode Wi-Fi and Bluetooth antenna.
Firmware for the ESP32 can be developed in MicroPython or C++. This guide is focused on developing firmware for EMIT using MicroPython.
When working with MicroPython on the ESP32 we only really have two IDEs to choose from:
- Thonny
- uPyCraft
The Thonny IDE is available for Windows, Mac & Linux so is easily accessible to everyone, it is also the only IDE being actively developed; so for this development guide, we'll be using Thonny.
1.1 Download and install the Thonny IDE
The first thing you'll need to do is download and install the Thonny IDE from the Thonny website: https://thonny.org/
Thonny provide detailed installation guides for each operating system; just choose and follow the guide that matches your operating system:
1.2 Download MicroPython for the ESP32
Next we need to download MicroPython for the ESP32 from the MicroPython download directory: https://MicroPython.org/download/esp32
There are multiple versions of MicroPython available, for this guide, we recommend using the latest 'Stable' version of ESP-IDF v3.x. (the non-SPIRAM version).
1.3 Flash MicroPython onto EMIT's ESP32
OK, now you've downloaded MicroPython, let's flash it onto EMIT's ESP32. Thankfully, Thonny makes this easy!
Carefully plug the ESP32-DEVKITv1 module into the EMIT PCB, ensuring that all of the DEVKITv1 modules pins align to the socket strips in EMIT. The USB connector should be at the bottom edge of the EMIT board as shown below:
Connect a USB cable between the ESP32-DEVKITv1 module and your PC/Laptop.
Open the Thonny IDE and select 'Tools' -> 'Options' from the main menu. This will display the options dialog box:
In the options dialog, select 'MicroPython (ESP32)' in the first interpreter drop-down.
Then select the Port that is connected to your ESP32-DEVKITv1 module's USB connector from the second drop-down. HINT: The DEVKITv1 has an onboard CP2102 USB to UART converter which should make it easier to identify the correct port from the drop-down.
Finally, click the large 'Open the dialog for installing and upgrading MicroPython on your device' button, to show the next dialog box.
Ensure that the correct Port is shown in the first drop-down. Then, click the Firmware 'Browse' button and select the MicroPython Firmware you downloaded in Step 2 (above).
Make sure the 'Erase flash before installing' checkbox has been checked.
To start the MicroPython upload to the ESP32, carry out the following sequence:
- Press and HOLD the 'BOOT' button on the ESP32-DEVKITv1 module
- Click the Install button on the Thonny Install dialog box
- Release the BOOT button
A new 'Installing firmware' dialog box should appear. This dialog will let you know the progress of the installation process; starting with erasing the flash, installing the firmware and resetting the device.
Eventually, the Installing firmware dialog box will confirm that installation has been completed ... Success!!!
Click 'OK' to close the dialog, then click 'Close' on the Install ESP32 with esptool dialog. Finally, close the Thonny Options by clicking 'OK'.
Then click the 'STOP' button on Thonny to STOP and RESTART Thonny's backend. If everything worked successfully, the ESP32 module should respond with a brief message in the Shell window:
This message confirms the version of MicroPython that is now running on EMIT's ESP32.
Congratulations! you're now ready to move on to: 2. Writing and uploading firmware to EMIT