The Internet of Things (IoT) has become increasingly popular, creating a demand for long-range, low-power communication technologies.
LoRa (Long Range) is a low-power wide-area network (LPWAN) technology designed to meet these requirements, making it ideal for IoT applications. One device that utilizes LoRa technology is the Ebyte LoRa E32 series, a collection of wireless transceiver modules. This article series will explore the Ebyte LoRa E32 device and its integration with MicroPython. This first article will focus on the specifications and basic use of the device.
Here my selection of LoRa E32 devices AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)
We are going to test E32-433T20D, a wireless serial port module based on Semtech’s SX1278 RF chip Block (TTL level), transparent transmission mode, working in the 410-441MHz frequency band (default 433MHz), using LoRa spread spectrum technology.
The SX1278 is a LoRa module that supports spread spectrum technology, offering numerous benefits for low-speed communication applications. With its long communication distance, robust anti-interference capabilities, and strong confidentiality, the SX1278 has become a popular choice in various industries. This article will discuss the key features, advantages, and applications of the SX1278 LoRa module.
SX1278 Overview
The SX1278 LoRa module is designed for optimal performance in low-speed communication applications. It has a default air rate of 2.4 kbps and a transmit power of 20 dBm. The module incorporates an industrial-grade crystal oscillator, ensuring stability, consistency, and an accuracy of less than 10 ppm. Currently, the SX1278 is in stable mass production and is widely utilized in the industry, IoT transformation, and smart furniture applications.
Advantages of the SX1278 LoRa Module
- Spread Spectrum Technology: The SX1278 supports advanced LoRa modulation, offering long-distance and anti-interference advantages over traditional GFSK technology.
- Communication Distance: Under ideal conditions, the communication distance can reach up to 3 km.
- Transmission Modes: The module supports fixed-point transmission, broadcast transmission, and channel monitoring.
- Air Wake-Up: The ultra-low power consumption feature makes the SX1278 suitable for battery-powered applications.
- Forward Error Correction (FEC): The module supports FEC to improve communication stability.
- Adjustable Transmit Power: The maximum transmit power is 100 mW, with multiple software-adjustable levels.
- Frequency Band: The SX1278 operates in the global license-free ISM 433 MHz frequency band.
- Data Transmission Rate: The module supports data transmission rates ranging from 0.3 kbps to 19.2 kbps.
- Power Supply: A 2.3 – 5.5 V power supply is supported, with more than 3.3 V ensuring optimal performance.
- Industrial-Grade Design: The SX1278 is designed for long-term use at temperatures ranging from -40°C to +85°C.
- Antenna: The SMA-K interface allows for easy connection of a coaxial cable or external antenna.
Data Security and Compression
The SX1278 module offers data encryption and compression functions, providing secure communication. The data transmitted over the air is randomized, and strict encryption and decryption algorithms render intercepted data meaningless. The data compression function helps reduce transmission time, lowers the likelihood of interference, and enhances reliability and transmission efficiency.
Certifications
The E32-433T20D module, which incorporates the SX1278, adheres to FCC, CE, and CCC design specifications, as well as other domestic and international standards. It meets various RF-related certifications and export requirements.
Operating and transmission type
This device has some interesting function:
Transmission
Transparent transmission
This can be considered a “Demo mode”, by default, you can send messages to all devices of the same configured address and channel.
Fixed transmission
In this type of transmission, you can specify an address and a channel where you want to send the message.
You can send a message to a:
- A specified device with a predetermined Address Low, Address High, and Channel.
- Broadcast a message on a predetermined Channel.
Normal mode
Simply send a message.
Wake-up mode and power-saving mode
As you can intend, if a device is in Wake-up mode can “wake” one or more devices that are in power-saving mode with a preamble communication.
Program/sleep mode
With this configuration, you can change the configuration of your device.
Specifications
Here are the specifications for the module:
- Module size: 21*36mm
- Antenna type: SMA-K (50Ω impedance)
- Transmission distance: 3000m(max)
- Maximum power: 2dB(100mW)
- Air rates: 2.4Kbps (6 optional levels (0.3, 1.2, 2.4, 4.8, 9.6, 19.2kbps)
- Emission length: 512Byte
- Receive length: 512Byte
- Communication Interface: UART – 8N1, 8E1, 8O1, Eight kinds of UART baud Rate, from 1200 to 115200bps (Default: 9600)
- RSSI support: No (Built-in intelligent processing)
- Working frequency: 410MHz-441MHz (Default 433MHz), Channel: 32
Electronic parameter | Min. | Typ. | Max. | Unit |
---|---|---|---|---|
Power supply | 2.3 | 3.3 | 5.5 | V |
Communication level | 3.0 | 3.3 | 3.6 | V |
Transmitting current | 102 | 110 | 118 | mA |
Receiving current | 12 | 15 | 18 | mA |
Sleep current | 3 | 5 | 8 | μA |
Operating temperature | -40 | 20 | +85 | ℃ |
Operating humidity | 10 | 60 | 90 | % |
Storage temperature | -40 | 20 | +125 | ℃ |
You must pay attention to the communication level that differs from the power supply, the second can receive voltage like 3.3v and 5v, but the first wants a 3.3v.
Pinout
Pin No. | Pin item | Pin direction | Pin application |
---|---|---|---|
1 | M0 | Input(weak pull-up) | Work with M1 & decide on the four operating modes. Floating is not allowed, it can be ground. |
2 | M1 | Input(weak pull-up) | Work with M0 & decide on the four operating modes. Floating is not allowed, it can be ground. |
3 | RXD | Input | TTL UART inputs connect to external (MCU, PC) TXD output pin. It can be configured as open-drain or pull-up input. |
4 | TXD | Output | TTL UART outputs connect to external RXD (MCU, PC) input pin. It can be configured as open-drain or push-pull output |
5 | AUX | Output | To indicate module’s working status & wakes up the external MCU. During the procedure of self-check initialization, the pin outputs low level. Can be configured as open-drain output orpush-pull output (floating is allowed). |
6 | VCC | Power supply 2.3V~5.5V DC | |
7 | GND | Ground |
As you can see, you can set various modes via M0 and M1 pins.
Mode | M1 | M0 | Explanation |
---|---|---|---|
Normal | 0 | 0 | UART and the wireless channel are good to go |
Wake-Up | 0 | 1 | Same as normal but a preamble code is added to transmitted data for waking-up the receiver. |
Power-Saving | 1 | 0 | UART is disable and wireless is on WOR(wake on radio) mode which means the device will turn on when there is data to be received. Transmission is not allowed. |
Sleep | 1 | 1 | Used in setting parameters. Transmitting and receiving disabled. |
For the next simple test, we are going to use Normal mode.
Wiring
STM32
Here my selection of STM32 STM32F103C8T6 STM32F401 STM32F411 ST-Link v2 ST-Link v2 official
To put on work transparent transmission, we can put the M0 and M1 to GND.
You can remove AUX wiring for this test, but it’s better if you cannect It.
E32 | STM32F4 |
---|---|
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
RX | PA10 (PullUP 4,7KΩ) |
TX | PA9 (PullUP 4,7KΩ) |
AUX | Not connected (better if you set a pin, but not needed for this test) |
VCC | 5v |
GND | GND |
esp32
Here my selection of esp32 ESP32 Dev Kit v1 - TTGO T-Display 1.14 ESP32 - NodeMCU V3 V2 ESP8266 Lolin32 - NodeMCU ESP-32S - WeMos Lolin32 - WeMos Lolin32 mini - ESP32-CAM programmer - ESP32-CAM bundle - ESP32-WROOM-32 - ESP32-S
The wiring diagram is quite simple, and for now, I put M0 and M1 directly to GND for the test.
E32 | esp32 |
---|---|
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
RX | TX2 (PullUP 4,7KΩ) |
TX | RX2 (PullUP 4,7KΩ) |
AUX | Not connected (better if you set a pin, but not needed for this test) |
VCC | 5v |
GND | GND |
Raspberry Pi Pico
Here the rp2040 selection Official Pi Pico - Official Pi Pico W - Waveshare rp2040-zero - WeAct Studio rp2040
And here is the connection diagram, for this test, you can remove the AUX pin connection. You can also see that I use a different default Serial port because It differs from the Arduino environment.
Pay attention UART(1) use different pin in MicroPython than Arduino environment Serial1
E32 | rp2040 |
---|---|
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
RX | TX1 GPIO4 (PullUP 4,7KΩ) |
TX | RX1 GPIO5 (PullUP 4,7KΩ) |
AUX | 2 (better if you set a pin, but not needed for this test) |
VCC | 5v |
GND | GND |
For the Arduino standard pinout, you must change the UART declaration so uart2 = UART(1, rx=Pin(9), tx=Pin(8))
Simple communication sketch
Now, we are going to do a simple sketch, without any library, that transfer a message by using the transparent transmission that is the default setting for these LoRa devices.
#############################
#
# Simple send receive test
#
# by Renzo Mischianti
# www.mischianti.org
#
#############################
from machine import UART, Pin
import utime
# UART configuration Raspberry Pi Pico (Arduino)
uart1 = UART(1, 9600, rx=Pin(9), tx=Pin(8))
# UART configuration Raspberry Pi Pico (MicroPython)
# uart1 = UART(1, 9600)
# UART configuration ESP32
# uart1 = UART(2, 9600)
print("Hi, I'm going to send message!")
uart1.write("Hello, world?")
utime.sleep_ms(500)
while True:
if uart1.any():
char = uart1.read(1).decode('utf-8')
print(char, end='')
Here is the print of the first started device
Hi, I'm going to send message!
13
Hello, world?
Library
Now we do the same example with the ebyte-lora-e32
MicroPython library. Naturally, this is a trivial example, and you can’t understand the potential of the library, but you can understand how to use It.
To install the library, you can download It from this GitHub repository:
Or you can install it via Pypi with the command:
pip install ebyte-lora-e32
On Thonny IDE, you can use Tools --> Manage plug-ins...
.
Communication sketch with the library
Now we do the previous example with the library.
#############################
#
# Simple send receive test
# with the micropython library
# pip install ebyte-lora-e32
#
# by Renzo Mischianti
# www.mischianti.org
#
#############################
from lora_e32 import LoRaE32, print_configuration, Configuration
from lora_e32_operation_constant import ResponseStatusCode
from machine import UART, Pin
# Initialize the LoRaE32 module
# UART configuration Raspberry Pi Pico (Arduino)
uart1 = UART(1, 9600, rx=Pin(9), tx=Pin(8))
# UART configuration Raspberry Pi Pico (MicroPython)
# uart1 = UART(1, 9600)
# UART configuration ESP32
# uart1 = UART(2, 9600)
lora = LoRaE32('433T20D', uart1)
code = lora.begin()
print("Initialization: ", ResponseStatusCode.get_description(code))
# Send a string message (transparent)
message = 'Hello, world!'
code = lora.send_transparent_message(message)
print("Send message: ", ResponseStatusCode.get_description(code))
# Receive a string message (transparent)
while True:
if lora.available() > 0:
code, value = lora.receive_message()
print(ResponseStatusCode.get_description(code))
print(value)
The result in the REPL console is:
Initialization: Success
Send message: Success
Success
Hello, world!
Thanks
As you can see, for the simple operation, the library doesn’t add any additional features, but in the real-world example, we can find It very useful, but we look in deep in the following articles.
- EByte LoRa E32 & MicroPython: specifications, overview and first use
- EByte LoRa E32 & MicroPython: exploring MicroPython library
- EByte LoRa E32 & MicroPython: detailed look at the configuration
- EByte LoRa E32 & MicroPython: a deep dive into transmission types