Wio E5 with Micropython Will guide you to implement Wio E5 with Xiao ESP32 S3 via Micropython.
Story
In this tutorial, we'll walk you through integrating **LoRa Wio E5** (a low-power, long-range LoRa module) with the **XIAO ESP32-S3** (a compact microcontroller with built-in WiFi and Bluetooth) using **MicroPython**. The goal is to establish LoRa communication between the devices, allowing you to create IoT applications with long-range, low-power data transfer capabilities.
ð¦ Prerequisites
ð ï¸ Hardware:
ð°ï¸ Wio LoRa-E5 Module(STM32-based LoRa module)ð¥ï¸ XIAO ESP32-S3 (compact ESP32 board)ð Jumper wires for connecting the modulesð Breadboard for prototypingð USB Cables for flashing and power
ð¥ï¸ Software:
Python 3.x installed on your PC for firmware flashing and serial communication Thonny IDE (or any MicroPython IDE of your choice) esptool (for flashing MicroPython firmware onto the ESP32-S3) MicroPython firmware for XIAO ESP32-S3 from [MicroPython.org] (https://micropython.org/download/esp32/) UART AT command reference for Wio-E5 from Seeed Studio
Get PCBs for Your Projects Manufactured
You must check out PCBWAY for ordering PCBs online for cheap!
You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad.
ð§ Step 1: Flashing MicroPython on XIAO ESP32-S3 and Wio LoRa E5
ð¥ Flashing MicroPython on XIAO ESP32-S3:
1. Download the MicroPython firmware for ESP32-S3 from (https://micropython.org/download/esp32/). Make sure to download the **ESP32-S3 specific firmware.
2. Install esptool:
You'll need the esptool package to flash MicroPython on the ESP32-S3. Install it with:
pip install esptool
3. Erase existing firmware on the XIAO ESP32-S3 by connecting it to your PC and running the following command:
esptool.py --chip esp32s3 --port <your-port> erase_flash
4. Flash the MicroPython firmware:
Replace `<your-port>` with the port the ESP32-S3 is connected to (e.g., `COM4` on Windows or `/dev/ttyUSB0` on Linux). Then, run:
esptool.py --chip esp32s3 --port <your-port> write_flash -z 0x1000 esp32s3-<your-firmware>.bin
ð Flashing Wio LoRa-E5:
The Wio LoRa-E5 module communicates primarily over UART using AT commands. You won't flash MicroPython onto it but will communicate with it through AT commands from the XIAO ESP32-S3.
For detailed instructions on setting up the Wio-E5 with firmware, refer to the [Seeed Studio documentation: https://wiki.seeedstudio.com/Wio-E5-LoRa-Module/]
ð Step 2: Wiring Connections
Hereâs how you can connect the **XIAO ESP32-S3** to the **Wio LoRa-E5** module using UART:
Ensure that you connect the pins correctly, especially the TX and RX, as this will facilitate communication between the devices.
ð§ Step 3: Setting Up Thonny IDE for ESP32-S3
1. Download and install Thonny IDE if you haven't already.
2. Select **ESP32** as your MicroPython interpreter.
3. Plug in your XIAO ESP32-S3, and in Thonny, go to Tools > Options > Interpreter, then select the correct Port corresponding to your device (e.g., `COM3` on Windows or `/dev/ttyUSB0` on Linux).
Verify the connection by running:
print("Hello from XIAO ESP32-S3!")
If the message prints to the terminal, you are connected!
ð§âð» Step 4: Sending AT Commands from XIAO ESP32-S3 to Wio LoRa-E5
To communicate with the Wio LoRa-E5, you will use UART on the XIAO ESP32-S3 to send AT commands. Hereâs a basic MicroPython script to initialize UART communication and send commands.
MicroPython UART Communication Script:
# P2P Transmitter Example
from machine import UART, Pin
from utime import sleep_ms
uart1 = UART(1, baudrate=9600, tx=Pin(43), rx=Pin(44))
def echo():
rxData=bytes()
while uart1.any()>0:
rxData += uart1.read(1)
print(rxData.decode('utf-8'))
uart1.write('at+mode=test\n') # enter test mode
sleep_ms(100)
data = 0
while True:
print("Send data:",data)
uart1.write('at+test=txlrpkt,"{}"\n'.format(data)) # send test data
sleep_ms(100)
echo() # show debug data from LoRa-E5 module
data += 1 # increment and loop test-data
data = data % 255
print("")
sleep_ms(1000)
This script initializes UART communication on the XIAO ESP32-S3 and sends an AT command to the Wio LoRa-E5. The response is printed to the console.
ð ï¸ Step 5: Receiving Data on XIAO ESP32-S3
To receive data from the Wio LoRa-E5, youâll need to listen for incoming messages using UART. The following script listens for LoRa messages:
# P2P Receiver Example
from machine import UART, Pin
from utime import sleep_ms
uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
def echo():
rxData=bytes()
while uart1.any()>0:
rxData += uart1.read(1)
data = rxData.decode('utf-8')
out = data.replace('+TEST: RXLRPKT','')
print(out)
uart1.write('at+mode=test\n') # enter test mode
sleep_ms(100)
while True:
uart1.write('at+test=rxlrpkt\n')
echo() # show debug data from LoRa-E5 module
sleep_ms(1000)
This script puts the Wio-E5 in receive mode and continuously listens for incoming messages.
𧪠Step 6: Testing Your Setup
Now that both sending and receiving are set up:
1. Power up both devices.
2. Send a message from one device (e.g., "Hello LoRa!").
3. Receive the message on the other device.
4. Verify that the message appears correctly on the receiving device's console.
You can also monitor communication through Thonny IDE.
ð Additional Enhancements
Add Sensors: Connect environmental sensors (like temperature or humidity) to your XIAO ESP32-S3 to send real-world data over LoRa.Wi-Fi Gateway: Use the Wi-Fi capability of the ESP32-S3 to forward LoRa data to a cloud service like MQTT-Deep Sleep: Implement power-saving techniques by putting the ESP32-S3 in deep sleep mode to save battery life in remote applications.
ð Conclusion
Congratulations! You've successfully integrated LoRa Wio-E5 with XIAO ESP32-S3 using MicroPython. This project enables you to build a wide range of long-range IoT applications, such as environmental monitoring, smart agriculture, or asset tracking.
ð Feel free to extend this project, add sensors, and explore the vast possibilities of LoRa and ESP32-S3.