SX1268 433M LoRa HAT

From Waveshare Wiki
Jump to: navigation, search

SX1268 433M LoRa HAT
SX1268 433M LoRa HAT
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Primary Attribute
Category:
{{{userDefinedInfo}}}: {{{userdefinedvalue}}}
Brand: Waveshare
Website
English: Website
Chinese: 官网
Onboard Interfaces
RPi UART
Related Products

Instruction

This is a Raspberry Pi LoRa HAT based on SX12682, covers 433MHz frequency band. It allows data transmission up to 5km through serial port.

Features

  • Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards
  • Onboard CP2102 USB TO UART converter, for serial debugging
  • Brings the UART control interface, for connecting host boards like Arduino/STM32
  • 4x LED indicators, easy to check the module status
  • LoRa spread spectrum modulation technology, up to 81 available signal channel, longer communication distance, more robust to interference
  • Auto multi-level repeating, suit for ultra long range communication, allows multi network on the same region
  • Low power consumption features like deep sleeping and Wake on Radio, ideal for battery-powered applications
  • Customizable communication key which won't be retrieved, greatly improves the security of user data
  • Supports LBT, monitoring the signal channel noise before transmitting, greatly improves the success ratio under extreme environment
  • Supports RSSI signal intensity indicating, for evaluating signal quality, tuning the network
  • Supports wireless parameter configuration, by sending wireless command/data packet, remotely configure or retrieve the module parameter
  • Supports fixed-point transmission, broadcast, signal channel monitor
  • Comes with development resources and manual (examples for Raspberry Pi/STM32)

Specification

Specification of SX1268 433M LoRa HAT
Consumption Transmit Current 110mA (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 ~ 850.125MHz
Receive Sensitivity [email protected] (On air)
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

Hardware description of SX1268 LoRa HAT
  1. SX1268 LoRa module
  2. 74HC125V: voltage level translator
  3. CP2102: USB TO UART converter
  4. Raspberry Pi GPIO connector: for connecting with Raspberry Pi
  5. USB TO UART port
  6. UART header: for connecting host boards like STM32/Arduino
  7. SMA antenna connector
  8. IPEX antenna connector
  9. Indicators:
    • RXD/TXD: UART RX/TX indicator
    • AUX: auxiliary indicator
    • PWR: power indicator
  10. 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
  11. 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】

Mode 0: Transmission mode, Module transmit data when users send data to UART interface. Wireless receiving is enabled to receive data and send to UART interface when idle.
Mode 1:When it is defined to Transmit, user need to add wakeup codes before transmitting, receiving is same as Mode 0.
Mode 2: Wireless transmit and wireless receive are disabled, users can configure configuration according to #Registers Configuration
Mode 3: Wireless transmit and wireless receive are disabled, module enter deep sleep mode. Module will configure when switching to other modes.

Use Guides

Registers Configuration

If the module is set to configuration mode (Mode 2), you can configure registers according to table below. (Baud rate: 9600, 8N1)

Configure registers
Function Descriptions
Configure registers| Command format 0xC0 + Begin address + Length + Data
Answer format 0xC1 + Begin address + Length + Data
Examples 1: Set channel to 0x11
Head Begin address Length Data
Command 0xC0 0x05 0x01 0x11
Answer 0xC1 0x05 0x01 0x11
Examples 2: Set Module address (0x1234), NETID(0x00), UART(9600, 8N1), Air speed(1.2K)
Head Begin address Length Data
Command 0xC0 0x00 0x04 0x12 0x34 0x00 0x61
Answer 0xC1 0x00 0x04 0x12 0x34 0x00 0x61
Read registers Command format 0xC1 + Begin address + Length
Answer format 0xC1 + Begin address + Length + Data
Examples 1: Read channel
Head Begin address Length Data
Command 0xC1 0x05 0x01
Answer 0xC1 0x05 0x01 0x12 0x34 0x00 0x61
Examples 2: Read Module address, NETID, Serial port and air speed.
Head Begin address Length Data
Command 0xC1 0x00 0x04
Answer 0xC1 0x00 0x04 0x12 0x34 0x00 0x61
Configure temporary registers Command format 0xC2 + Begin address + Lenght + Data
Answer format 0xC1 + Begin address + Lenght + Data
Examples 1:Set channel to 0x11
Head Begin address Length Data
Command 0xC2 0x05 0x01 0x11
Answer 0xC1 0x00 0x01 0x11
Examples 2: Set module address(0x1234), NETID(0x00), serial port(9600 8N1), Air speed(1.2K)
Head Begin address Length Data
Command 0xC2 0x00 0x04 0x12 0x34 0x00 0x61
Answer 0xC1 0x00 0x04 0x12 0x34 0x00 0x61
Wireless configuration Command format 0xCF 0xCF + Common command
Answer format 0xCD 0xCF + Common answer
Examples 1: Wireless set channel to 0x11
Wireless Head Head(common) Begin address Length Data
Command 0xCF 0xCF 0xC2 0x05 0x01 0x11
Answer 0xCD 0xCF 0xC1 0x05 0x01 0x11
Examples 2: Wireless set module (0x1234), NETID(0x00), serial port(9600 8N1), Air speed(1.2K)
Wireless Head Head (common) Begin address Length Data
Command 0xCF 0xCF 0xC2 0x00 0x04 0x12 0x34 0x00 0x61
Answer 0xCD 0xCF 0xC1 0x00 0x04 0x12 0x34 0x00 0x61
Format error Answer of Format error
0xFF 0xFF 0xFF

【Note】

1. When wireless configuring, you need to firstly configure Modules address, NETID, Air speed and Key of both modules to same values. For example, if Modules A: Module address is 1, NETID is 1, Air speed is 2.4Kbps and Key is 1. Module B: Module address is 2, NETID is 2, Air speed is 62.5Kbps and Key is 2. If you want to use Module A to configure Module B via wireless network, you need to set Module A to be same as Module B. Then you can use 0xCF 0xCF command to configure Module B via wireless network.
2. After configure temporary registers, LoRa modules work by settings of temporary registers. If LoRa modules restart, the settings of temporary are invalid, LoRa module will re-configure registers according to network settings by 0xC1 commands.

Registers Description

Description of registers
NO. Read/Write Name Description Note
00H R/W ADDH ADDH (Default:0) High bits and Low bits of module address. Note thant when module address is 0xFFFF.

It works as broadcasting and listening address and LoRa module doesn't filter address anymore

01H R/W ADDL ADDL (Default:0)
02H R/W NETID NETID (Default: 0) Network ID, it is used to distinguish network.

If you want to communicating between two modules, you need to set their NETID to same ID

03H R/W REG0 Bit 7 Bit 6 Bit 5 UART baud rate (bps) The baud rates and parity of modules which are intercommunicating can be different.

Generally we recommend you to set their baud rate to same value to avoid data blocking or data losing

0 0 0 Baud rate is 1200
0 0 1 Baud rate is 2400
0 1 0 Baud rate is 4800
0 1 1 Baud rate is 9600 (default)
1 0 0 Baud rate is 19200
1 0 1 Baud rate is 38400
1 1 0 Baud rate is 57600
1 1 1 Baud rate is 115200
Bit 4 Bit 3 Parity bit The serial port of modules which are intercommunicating can set to different paramters
0 0 8N1 (Default)
0 1 8O1
1 0 8E1
1 1 8N1 (same as 00)
Bit 2 Bit 1 Bit 0 Wireless Air speed (bps) The air speed of two modules which are intercommunicating must be same.

Higher the speed, smaller the latency and shorter the communicating distance.

0 0 0 Air speed is 0.3K
0 0 1 Air speed is 1.2K
0 1 0 Air speed is 2.4K (default)
0 1 1 Air speed is 4.8K (default)
1 0 0 Air speed is 9.6K
1 0 1 Air speed is 19.2K
1 1 0 Air speed is 38.4K
1 1 1 Air speed is 62.5K
04H R/W REG1 Bit 7 Bit 6 Setting of dividing packet If the size of data transmitted are shorter than the length of divided packet. Data are continuous sent to serial port after receiving;

If the size of data transmitted are longger than the length of divided packet. Data are divided and sent to serial port after receiving.

0 240 bytes (default)
0 1 128 bytes
1 0 64 bytes
1 1 32 bytes
Bit 5 Enable ambient noise After enabling, You can send command 0xC0 0xC1 0xC2 0xC3 to read register in Transmit Mode or WOR Mode;

Register 0x00: RSSI of current ambient noise
Register 0x01: The RSSI of last communicating (current noise of channel is dBm = - RSSI/2);
Command format: 0xC0 0xC1 0xC2 0xC3 + Begin address + Read length;
Answer format: 0xC1 + Address + Read length + Data;
For example:
Command: 0xC0 0xC1 0xC2 0xC3 0x00 0x01
Answer: 0xC1 0x00 0x01 RSSI (The address should begin from 0x00)

0 Disable (default)
1 enable
Bit 4 Bit 3 Bit 2 Reserved
Bit 1 Bit 0 Transmit power The relationship between power and current is non-linear.

If power is maximum, the power efficiency is highest.
Current will not small in the same proportion of power.

0 0 22dBm (default)
0 1 17dBm
1 0 12dBm
1 1 10dBm
05H R/W REG2 Channel control (CH) 0-83. 84 channels in total Actually frequency is 850.125 + CH *1MHz. Default 868.125MHz
06H R/W REG3 Bit 7 Enable RSSI byte After enabling, data sent to serial port is added with a RSSI byte after receiving
0 Disable (default)
1 Enable
Bit 6 Transmitting mode When point to point transmitting, module will recognize the first three byte as Address High + Address Low + Channel. and wireless transmit it
0 Transparent transmitting (default)
1 Point to Point Transmitting
Bit 5 Relay function If target address is not module itself, module will forward data;

To avoid data echo, we recommend you to use this function in point to point mode, that is target address is different with source address

0 Disable (default)
1 Enable
Bit 4 Enable LBT Module will listen before transmit wireless data.

This function can be used to avoid interference, however, it also clause longer latency;
The MAX LBT time is 2s, after 2s, data is forced to transmit

0 Disable(default)
1 Enable
Bit 3 WOR Mode Tramsmit/Receive control This setting only work for Mode 1;

Receiver waits for 1000ms after receive wirelesss data and forward,and then enter WOR mode again
User can send data to serial port and forward via wireless network during this interval,
Every serial byte will refresh this interval time (1000ms);
You much send the first byte in 1000ms.

0 WOR Receiver (default)

Module is enable to receive/transmit, and wakeup code is added to transmitted data.

1 WOR Sender

Module is disable to send data. Module is working in WOR listen mode. Consumption is reduced

Bit 2 Bit 1 Bit 0 WOR Period This setting only work for Mode 1;

Period is equal to T = (1 + WOR) * 500ms; MAX 4000ms, MIN 500ms
Longer the Period time of WOR listen, lower the average consumption, however, longer the latency
The settings of receiver and sender must be same.

0 0 0 500ms
0 0 1 1000ms
0 1 0 1500ms
0 1 1 2000ms
1 0 0 2500ms
1 0 1 3000ms
1 1 0 3500ms
1 1 1 4000ms
07H W CRYPT_H High bytes of Key (default 0) Only write enable, the read result always be 0;

This key is used to encrypting to avoid wireless data intercepted by similar modules;
This key is work as calculation factor when module is encrypting wireless data.

08H W CRYPT_L Low bytes of key (default 0)
80H ~ 86H R PID Information of module (7 bytes) 7 bytes data of module information

Debugging

1. To test, you need two SX1268 LoRa HAT (hereafter called LoRa HAT), two micro USB cables.
2. Connect SMA antennas to LoRa HATs. Set jumpers to A and set M0 and M1 to GND.
3. Connect USB to UART interfaces of two LoRa HATs to PC by micro USB cables
4. Check the COM ports on Devices Manager
5. Open SSCOM software, Set serial ports to 9600, 8N1 and try to send data.
SX1262 LoRa HAT user manual-1.png
SX1262 LoRa HAT user manual-2.png

Using Examples

You can download the demo codes from #Demo codes

Unzip the archive downloaded and get the codes as below:
SX1262 LoRa HAT user manual-3.png
Raspberry Pi examples
To use Raspberry Pi examples, you need to copy the RaspberryPi to /boot/ directory of Raspbian (OS of Raspberry Pi) first, then move it to /home/pi directory of Raspbian

1. Hardware connection

To test the codes, you need to setup two devices with one RaspberryPi board and two LoRa HAT.
Add one LoRa HAT on Raspberry Pi (device 1), then set jumpers to B and remove M0, M1 jumpers
Connect another LoRa HAT to PC(device 2), then set jumpers to A and set M0 and M1 to GND refer to #Debugging
Powering on Raspberry Pi
SX1262 LoRa HAT user manual-4.png

2. Enable serial port

Open Terminal of Raspberry Pi
Run command sudo raspi-config to open Configure interface
Choose Interfacing Options -> Serial -> No -> Yes

3. Install libraries

There are libraries should be installed ahead
sudo apt-get install python-pip 
sudo pip install RPi.GPIO
sudo apt-get install python-smbus
sudo apt-get install python-serial

4. Transparent communicating

Transparent-Broadcast
Transparent-Point to Point
Enter directory of transparent example
cd ~/RaspberryPi/transparent
Run code
sudo python transparent.py BROADCAST_AND_MONITOR
SX1262 LoRa HAT user manual-5.png
You can also use command P2P to do Point to Point communicating
sudo python transparent.py P2P
SX1262 LoRa HAT user manual-6.png

5. Relay example

Relay communicating is one of ultra-long distance communicating. In Relay mode, address register of LoRa HAT is used to NETID forward and pair instead of auto receiving/transmitting, low consumption operation could not be done either.

【Note】 To test Relay example, you require at least three LoRa HATs.

Relay
Take the first three LoRa HATs as LoRa A, LoRa B and LoRa C
Connect LoRa B to PC, and set it to Relay mode.That is set M0 to GND and disconnect M1 then configure ADDH register to 0x01, ADDL to 0x02, REG3 to 0x23 by command: C1 00 09 01 02 00 62 00 12 23 00 00 (HEX). After configuring, connect M1 and M0 to GND.
Connect LoRa C to PC and set it as end note. That is set M1 to GND and disconnect M1, then configure ADDH register to 0x03, ADDL to 0x04, NETID to 0x04 by command: C1 00 09 00 00 02 62 00 12 03 00 00 (HEX). After configuring, connect M1 and M0 to GND
Add LoRa A to Raspberry Pi, set jumpers to A and disconnect M1, M0.

SX1262 LoRa HAT user manual-10.png

Enter directory of relay example. run the codes
cd ~/RaspberryPi/relay
sudo python relay.py

SX1262 LoRa HAT user manual-11.png

6. WOR example

Consumption of LoRa HAT is low when working in WOR mode. In WOR mode, data communication has latency, can be powered by batteries because of low consumption.

To test WOR example, two LoRa HATs are required.

Add LoRa HAT on Raspberry Pi and set jumpers to B, disconnect M1 and M0.
Connect LoRa HAT to PC and set it to WOR mode. You need to set M1 to GND and disconnect M1 before configuring and connect M1 to GND, diconnect M0 after configuring. (Device 1)
Enter directory of WOR example and run it
cd ~RaspberryPi/wor
sudo python wor.py
The data transmitted by Pi (device 1)will be received by PC (device 2) with delay.
STM32

The examples for STM32 are based on Open103C (STM32F103CBT6). Use HAL Lib.

1. Hardware connection

Set jumpers to B, and connect LoRa HAT to STM32 board pins by pins:

SX1268 LoRa HAT STM32
5V 5V
GND GND
RXD PA10
TXD PA9
M1 PB15
M0 PB14
SX1262 LoRa HAT user manual-12.png

2. Expected result

The connection of other LoRa HATs (if required) you can refer to the Raspberry Pi example parts.

Open the project, and modify the definition on main.c file for different communicating modes
#define TRASNSPARENT
//#define RELAY
//#define WOR

Resources

Documents

Demo codes

Softwares

FAQ

...

Supports

Mail.png Contact your seller (fast response and most recommended)

or send emails to [email protected] (not fast enough but please be patient) for help.

Our working time: 09:00-18:00 (UTC+8 Monday to Saturday)