Wireless sensor firmware based on MicroPython.
For an overview of the wireless module usage from a user's view, see the Notion manual.
Make sure to use Visual Studio Code for the best development experience.
# Install the required tools
pipenv install
pipenv shell
# Configure VS-Code auto-completion for micropython
micropy stubs add esp32-micropython-1.12.0
micropy
You will need to create a local version of config.py
(cp src/config.example.py src/config.py
) and change some settings.
Name | Description |
---|---|
MQTT_BROKER | IP address of the MQTT broker |
ESSID | Name of WiFi network to connect to |
PASSWORD | WiFi password |
The ESP32 needs to be flashed with the base micropython firmware. This only needs to be done once. See the MicroPython ESP32 Getting Started guide for detailed instructions. At this point, version v1.13 of micropython (esp32-idf3-20200902-v1.13.bin
) is required to run the modules. You can download the firmware here.
The upload.sh
file in middle_module
folder can be used to upload all relevant files on the ESP32.
# Change this to the serial port of the ESP32
./upload.sh --port /dev/ttyUSB0
If using picocom
:
- Open terminal and connect the ESP32 to your computer
- Run
picocom <insert_device_port_number> -b 115200
. This would runboot.py
and thenmain.py
. - Use
mosquitto
to interact with ESP32 (see this) - If you find that the board is not publishing to the
mqtt
topic or is not running, try the next few steps. - Use
Control-C
to open REPL - To explicitly run a file, say
main.py
on the board useimport main.py
orimport main
, depending on your ESP32 version. Note: This only works once in apicocom
session, after that you'll need to closepicocom
and repeat from step 5.
Use Control-A
and then Control-X
to terminate picocom
.