Coded by Kyriakos Giannakis - Flare
I recently purchased a Heltec V4 board and wanted to flash MicroPython and see if I can get it working on a simple LoRa TX/RX.
In this repo, I'll be documenting the full way to get MicroPython working on this board and add various examples on the different functionalities.
- Install
esptoolandmpremote:pip install -r requirements.txt - Get yourself a copy of the latest MicroPython build for the ESP32 S3 (download the latest
.binfile): https://micropython.org/download/ESP32_GENERIC_S3/
- Connect the heltec to your PC via usb and find the serial port it uses. This varies depending on the OS you're using.
- Erase the flash:
esptool -p COM6 erase_flash - Write the uPython bin:
esptool --baud 460800 write_flash 0 'D:\Downs\ESP32_GENERIC_S3-20251209-v1.27.0.bin' - (Optional: do this if you've booted in flashing mode, to boot in normal mode) Unplug and replug the USB cable.
- Connect mpremote to the device to verify everything's working:
$ mpremote connect list
(You should see your device listed)
$ mpremote connect COM6 # (replace with your port)
(You should see a micropython REPL)- Congrats, you've successfully flashed micropython!
In order to get everything to work (the OLED display and the LoRa modem), you need to install some libraries from micropython-lib. Luckily, this is easily done
using mpremote mip:
$ mpremote mip install lora-sync lora-sx126x ssd1306# Required: boot.py initializes your OLED display and adds a method to easily initialize your modem
$ mpremote fs cp ./boot.py :boot.py
# Now copy as needed. For example, if you want to test LoRa TX, copy lora_tx.py as main.py
$ mpremote fs cp ./lora_tx.py :main.py
# Alternatively, you can run the code using mpremote, without copying:
# $ mpremote run ./lora_tx.pyIf you find that your controller is unresponsive and doesn't want to connect to serial and/or mpremote, you can try rebooting the controller in PRG mode:
- Unplug the USB cable
- Hold the PRG button
- While holding, plug in the USB cable, keep holding PRG
- Tap RST
- Release PRG
- The device should be in flashing mode. Go to Step 2.
- TX Example
- RX Example
- Encryption Example
- Deep Sleep
Contributions are welcome to add/fix code. Hit me with your PRs!