ESP32 (MicroPython)

The following examples show how to connect GUI-O application with ESP32 in various communication modes using MicroPython.

Setup MicroPython environment

The examples are based on ESP32-WROOM-32 board and PyCharm Community Edition IDE (Integrated Development Environment) with MicroPython plugin

Note that any other ESP32 board can also be used. Also note that any other IDE that supports ESP32 & MicroPython can be used.

Step 1: Install MicroPython on ESP32

./esptool --chip esp32 --port <port> erase_flash

NOTE #1: Replace <port> in the command with the actual port where the ESP32 is connected. On Windows, this might be something like COM4 (or something like /dev/ttyUSB0 on Linux).

NOTE #2: If the command is not recognized on Linux, make the tool executable (for all users):

chmod a+x esptool

./esptool --chip esp32 --port <port> --baud 460800 write_flash -z 0x1000 <.bin_file>

Step 2: Setup PyCharm IDE

ESP32 & MicroPython & GUI-O basic examples

The following examples show basic interaction between GUI-O application and ESP32 module in various communication modes using MicroPython.

ESP32 Bluetooth LE

Step 1: Run the Python script

NOTE: In case of any missing libraries, just click on "Fix" button and PyCharm will automatically install them.

NOTE: All debug messages during program execution can be observed using any serial console terminal (baud rate 115200 bps).

Step 2: Using GUI-O application to interact with ESP32

ESP32 MQTT (supports SSL/TLS)

IMPORTANT NOTE: This example assumes that MicroPython environment has already been set up and a new PyCharm project was created.

Step 1: Create tokens for MQTT communication

Step 2: Modify and run the Python script

NOTE: In case of any missing libraries, just click on "Fix" button and PyCharm will automatically install them.

NOTE: All debug messages during program execution can be observed using any serial console terminal (baud rate 115200 bps).

Step 3: Using GUI-O application to interact with ESP32

ESP32 USB

IMPORTANT NOTE: This example assumes that MicroPython environment has already been set up and a new PyCharm project was created.

IMPORTANT NOTE: The programming port on ESP32 cannot be used for communication with GUI-O application. Therefore, an additional USB to serial converter should be used (e.g., TTL-232R-3V3). This example assumes that USB to serial converter is connected to ESP32 UART2.

In order to connect ESP32 to your Android device, a simple adapter cable is needed (as shown in the image). Also note that not all Android devices support USB OTG functionality.

Step 1: Run the Python script

NOTE: In case of any missing libraries, just click on "Fix" button and PyCharm will automatically install them.

NOTE: All debug messages during program execution can be observed using any serial console terminal (baud rate 115200 bps).

Step 2: Using GUI-O application to interact with ESP32

ESP32 Ethernet

Step 1: Run the Python script

NOTE: In case of any missing libraries, just click on "Fix" button and PyCharm will automatically install them.

NOTE: All debug messages during program execution can be observed using any serial console terminal (baud rate 115200 bps).

Step 2: Using GUI-O application to interact with ESP32

NOTE: Make sure that your Android device is connected to the same WiFi network as ESP32 device.

Connect . Create . Control

Connect . Create . Control

YouTube channel
Facebook