Last updated
This product is a Raspberry Pi expansion board based on SX1268/SX1262 chip, a wireless serial port module with LoRa modulation function.
With multi-level relay to achieve ultra-long-distance communication, low power consumption wake-up communication, encrypted transmission, etc.
This product uses a private protocol and does not support LoRaWAN.
Support global license-free ISM 433/470/868/915MHz frequency band.
Supports wake-on-air, that is, ultra-low power consumption, suitable for battery-powered applications.
Support point-to-point transmission, broadcast transmission, channel monitoring, and multi-level relaying for ultra-long-distance communication.
Support RSSI signal indicator for evaluating signal quality and improving communication network.
Support the LBT function, and monitor the channel environmental noise before sending, which can greatly improve the communication success rate of the module in harsh environments.
LoRa spread spectrum technology, up to 84 channels/81 channels (SX1268/SX1262).
Support waking on radio, online configuration, carrier sense, automatic relay, communication key, low power sleep.
In an ideal environment, the communication distance can reach 5KM.
Consumption | Transmit Current | 100mA (Transient current) |
---|---|---|
Receive Current | 11mA | |
Sleep Current | 2uA (LoRa module deep sleep) | |
MAX Transmit Power | 22.0dBm (10, 13, 17, 22dBm Selectable) | |
Transmit Length | 240 Bytes (32, 64, 128, 240 Bytes Selectable) | |
Buffer | 1000 Bytes | |
Working Bands | 410.125~493.125MHz or 850.125~930.125MHz | |
Receive Sensitivity | -147dBm@0.3Kbps (On air) | |
Air Speed | 0.3K~62.5Kbps (software selectable) | |
Interface | UART | |
Range | 5KM (Sunny day; open area; Antenna: AUX 5dBi, Height 2.5m; Air Speed: 2.4kbps) | |
Working Voltage | 5V | |
Logic Voltage | 3.3V | |
Working Temperature | -40 ~ 85°C |
Hardware description of SX1268 LoRa HAT
SX1268/SX1262 LoRa module
74HC125V: voltage level translator
CP2102: USB TO UART converter
Raspberry Pi GPIO connector: for connecting with Raspberry Pi
USB TO UART port
UART header: for connecting MCU
SMA antenna connector
IPEX antenna connector
Indicators:
RXD/TXD: UART RX/TX indicator
AUX: auxiliary indicator
PWR: power indicator
UART selection jumpers
A: control the LoRa module through USB TO UART
B: control the LoRa module through Raspberry Pi
C: access Raspberry Pi through USB TO UART
LoRa mode selection jumpers
short M0, short M1: transmission mode
short M0, open M1: configuration mode
open M0, short M1: WOR mode
open M0, open M1: deep sleep mode
【Note】 1. Combine M1 and M0 with high and low levels to determine the working mode. M1 and M0 are high when they are not connected to the jumper cap. After switching the working mode, if the module is idle, it will enter the new working mode. Otherwise, the current transmission will be processed and enter the new working mode after receiving. 2. Mode 0: Transmission mode, Module transmits data when users send data to the UART interface. Wireless receiving is enabled to receive data and send it to the UART interface when idle. 3. Mode 1: When it is defined to Transmit, the user needs to add wakeup codes before transmitting, receiving is the same as Mode 0. 4. Mode 2: Wireless transmit and wireless receive are disabled, users can configure configuration according to #Registers Configuration 5. Mode 3: Wireless transmit and wireless receive are disabled, and the module enters deep sleep mode. The module will configure when switching to other modes.
What's LoRa
Semtech's LoRa is IoT wireless platform with long-distance and low-power, generally referring to radio frequency chips in LoRa. The main features are as follows.
The spread spectrum modulation technology used by LoRa (abbreviation of long-range) is derived from chirp spread spectrum (CSS) technology, which is one of the long-distance wireless transmission technology and LPWAN communication technology. At present, LoRa in the ISM frequency band mainly includes 433, 868, 915 MHz, etc.
Integrating digital spread spectrum, digital signal processing, and forward error correction codes, the performance of long-distance communication in LoRa has been improved a lot. Moreover, the link budget in LoRa, the main factor that determines distance under a given environment, is better than any other standardized communication technology.
LoRa RF chips mainly include SX127X series, SX126X series, and SX130X series, of which SX127X, SX126X series are used for LoRa nodes, and SX130X is used for LoRa gateways. For details, please refer to Semtech's product list.
LoRaWAN is a low-power, wide-area networking (LPWAN) protocol based on LoRa Technology. It is designed to wirelessly connect battery-operated 'things' to the Internet in regional, national, or global networks, and targets key Internet of Things (IoT) requirements such as bi-directional communication, end-to-end security, mobility, and localization services. The node wirelessly connected to the Internet has network access authentication, which is equivalent to establishing an encrypted communication channel between the node and the server. For details of network access, refer to source code. The LoRaWAN protocol level is shown in the figure below.
Class A/B/C node devices in the MAC cover all the applications for the Internet of Things. The difference between them is that the time slots for nodes to send and receive are different.
The band parameters in Modulation, such as EU868 and AS430, are differnt in differnt contries. The regional parameters refer to link.
The LoRaWAN coverage in the city or other areas requires a node (LoRa node radio frequency chip), gateway (or base station, LoRa gateway radio frequency chip), server, and cloud. As shown in the following figure:
First, DEVICE (node device) sends network access data package to GATEWAY and then to the server. After the authentication is passed, it can send and receive application data with the server normally.
GATEWAY (gateway) can communicate with the server through a wired network, 3/4/5G wireless network.
The main operators on the server side include TTN, etc. If you want to build cloud services by yourself, please refer to lorawan-stack,chirpstack
LoRa devices and networks such as LoRaWAN enable smart IoT applications to help the planet's present challenges such as energy management, natural resource reduction, pollution control, infrastructure efficiency, disaster prevention, and so on. Semtech's LoRa devices have been successfully applied in many aspects such as smart cities, homes and buildings, communities, metrology, supply chain and logistics, agriculture, and so on. LoRa networks reach hundreds of millions of devices in more than 100 countries for a smarter planet.
1. Prepare two SX126x LoRa HAT modules (here called Lora HAT), two Micro USB cables, assemble SMA antennas, place the jumper cap on A, and connect M0 and M1 to GND.2. Install the CP2102 driver on the WINDOWS PC, and connect the two Lora HATs to the PC using Micro USB.3. Open the PC device manager, find the two COM ports corresponding to the CP2102, use the SSCOM serial port software to connect the two Lora modules respectively, and set the baud rate to 9600.4. Input data in the input field of one SSCOM serial port software, click the send button, and you can see the data received by the LoRa module in the display field of the other SSCOM serial port software.
This test uses a Windows PC to connect to the LoRa HAT, and the jump settings will not change according to the factory location.
1. Install python3 on Windows, then enter cmd in the startup bar to search and open the Windows terminal.
2. Enter the path of python3 into the terminal, the default address is generally as shown in the picture below, pay attention to check your python3 path, and install pyserial.
3. Use the upper computer software to set up LoRa HAT, unplug the M1 jumper when setting, connect to the M1 jumper, and close the serial port of the upper computer after the setting is completed. Set the parameters as follows:
4. Unzip the sample demo to the desktop, open the main.py file to modify the COM port, and then run the demo.
In this chapter, we will demonstrate two examples. Demo 1: the test of two LoRa HATs connect to two Raspberry Pis for receiving and sending. Demo 2: The test of using 3 LoRa HATs for relay communication receiving and sending.
1. Hardware connection: After powering on Raspberry Pi, connect LoRa HAT as shown below:
Enter the following commands one by one to install the Python library, the first command enables the Raspberry Pi serial port.
2. Enable serial port.
Open the Terminal of Raspberry Pi.Run command sudo raspi-config to open Configure interface.Choose Interfacing Options -> Serial -> No -> Yes.
After executing the following command, the node will automatically print to the terminal when it receives the data sent by other nodes. When the node needs to send data to other nodes, press the keyboard i, and then enter the input according to the prompt, as shown in the figure below:
first node
second node
transpareant transfer diagram
Relay communication is a method for ultra-long-distance communication. Setting up the LoRa module to relay mode, and its address register would be only for forwarding pairing, no more active transceiver function, and no low power consumption.
【Note】 To test the Relay example, you require at least three LoRa HATs.
Assume the three LoRa modules as LoRa module A, LoRa module B, and LoRa module C.
Directly connected LoRa module A to the Raspberry Pi, set up LoR module B and LoRa module C by Windows upper-computer.
relay transfer diagram
lora module B setting
lora module C setting
lora module A setting
After LoRa module A is connected to the Raspberry Pi, open the main.py file, change line 66, change realy=False to realy=True, and execute the following command, LoRa module C will print the data from the serial port after receiving the data, and relay the LoRa module B will not print any data from the serial port, enter the following command:
This demo uses STM32F103CBT6 based on the HAT function.
Connect the jumper cap to B, and remove the M0, and M1 jumper caps instead of using the GPIO of STM32F103C.
SX1268 LoRa HAT | STM32 |
---|---|
5V | 5V |
GND | GND |
RXD | PA10 |
TXD | PA9 |
M1 | PB15 |
M0 | PB14 |
2. Example
The settings of the LoRa module connected to the computer USB are the same as in the above three demos.
Open the Keil project document and use different definitions in communication methods in lines 75 to 77 of the main.c file.
Select the communication method above and press F7 to compile, press F8 to download to STM32.
In this section, we briefly describe the working process and Python program of this product.
After powering on, and setting up /dev/ttyS0 serial port and 9600 baud rate, the M0 (BCM22) pin of the module is in low level, M1 (BCM27) pin is in high level, the module enters the configuration mode:
Lines 11 to 77 in the following code set the LoRa module's low address, high address, network ID, frequency, airspeed size, cache size, power size, RSSI input enable, encryption key and whether it is enabled the relay mode parameters, click to check register descriptionand LoRa Configuration. Lines 79 to 113 are the serial port sending configuration commands to the LoRa module. If the configuration is correct, pull down the M1 pin to enter the transceiver mode.
Data received by the receiver send to the controller from the serial output and pay attention to the third line of code. If the amount of received data is too large, please increase the delay accordingly and wait for all the data to be received before reading. Lines 10 to 15 are based on whether RSSI Enable to print RSSI value.
In the main.py file, after the program runs, wait for the user to press the keyboard to perform the corresponding operation, enter Esc to exit the loop, enter i to enter the application information to be sent, and enter s to broadcast the CPU temperature every 10 seconds: