SX1302 LoRaWAN Gateway HAT

From Waveshare Wiki
Jump to: navigation, search
SX1302 LoRaWAN Gateway HAT
400px-SX1302-LoRaWAN-Gateway-HAT-1.jpg

RPi/SPI/UART/I2C
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

This product is a LoRa gateway module using the new-generation SX1302/3 baseband chip, featuring long transmission distance, large node capacity, and high receiving sensitivity, with the SX1303 supporting concurrent communication. The outstanding low-power performance of SX1302/3 allows the gateway to simplify its thermal design, reducing material costs and minimizing size.

Features

LoRaWAN Gateway Module features:

  • Integrates Semtech SX1302/3 normal band and SX1250 radio RF frond-end chip
  • Onboard PA and LNA, features +26dBm transmit power and -141dBm high sensitivity receiving gain
  • The SX1303 supports Fine Timestamps and network positioning based on the time difference of arrival (TDOA)
  • 52PIN Mini-PCIe socket for easy integration into various embedded systems
  • Onboard 4 x LED indicators for module operating status
  • Comes with online development resources and manual (example in C)

HAT features:

  • Standard Raspberry Pi 40PIN GPIO header, supports Raspberry Pi series boards
  • Incorporate the L76K module with BD support, provide accurate clock and location info for gateway module
  • Comes with online development resources and manual (example in C)

Specifications

LoRa gateway GNSS module
Power supply 5V
Fequency range EU868(863-870MHz) GPS L1(1575.42MHz)
BD2 B1(1561.098MHz)
Positioning accuracy - <2.5m CEP
Modulation LoRa/(G)FSK -
Transmit power > 26dBm@5V -
Receiving sensitivity -141dBm@125KHz/SF12
-121dBm@125KHz/SF5
Capture: -148dBm
Track: -163dBm
Recapture​​: -160dBm
Overall power consumption Transmit: 710mA@5V GPS on
Receive: 99mA@5V GPS on
Sleep: 41mA@5V GPS off
Communication interface SPI, I2C UART
External connector Mini-PCIe -
Operating temperature -40~85℃
Dimensions 50.95mm × 30mm -

Hardware Description

Hardware Connection

Connect the HAT to Raspberry Pi as shown in the following figure, place the GPS antenna with the unlabeled side facing upwards in the visible open sky area

SX1302 LoRaWAN Gateway HAT 001.jpg

Onboard Interfaces

SX1302-LoRaWAN-Gateway-HAT-details-inter.png

LoRa & LoRaWAN

What is LoRa?

LoRa from Semtech is a long-range, low-power IoT wireless platform, generally referring to RF chips that use LoRa technology. The main features are as follows:

  • LoRa (short for long range) uses spread spectrum modulation technology derived from Chirp Spread Spectrum (CSS) technology, which is a type of long-distance wireless transmission technology and LPWAN communication technology. Spread spectrum technology trades bandwidth for sensitivity. Wi-Fi, ZigBee, and others all use spread spectrum technology, but the characteristic of LoRa modulation is that it approaches the limit of Shannon's theorem and maximizes sensitivity. Compared to traditional FSK technology, under the same communication rate, LoRa is 8 to 12 dBm more sensitive than FSK. Currently, LoRa primarily operates in the Sub-GHz ISM frequency band.
  • LoRa technology integrates technologies such as digital spread spectrum, digital signal processing, and forward error correction coding, significantly improving long-distance communication performance. The link budget of LoRa is superior to any other standardized communication technology, and the link budget refers to the main factors that determine the distance in a given environment.
  • LoRa RF chips mainly include the SX127X series, SX126X series, and SX130X series, where the SX127X and SX126X series are used for LoRa nodes, and the SX130X is used for LoRa gateways. For more details, please refer to the product list of Semtech.

What is LoRaWAN?

  • LoRaWAN is a low-power wide-area network open protocol built on top of LoRa radio modulation technology. It aims to wirelessly connect battery-powered "things" to the Internet in regional, national, or global networks, and is tailored to key IoT requirements such as two-way directional communication, end-to-end security, mobility, and localized services. Among them, the node is wirelessly connected to the Internet and has network access authentication, which is equivalent to establishing an encrypted communication channel between the node and the server, as shown in the following figure of the LoRaWAN protocol layer.
    • Class A/B/C three types of node devices in the MAC layer basically cover all the application scenarios of the Internet of Things. The difference among the three lies in the different time slots for node reception and transmission
    • In the Modulation layer, EU868, AS430, etc., indicate that different countries use different frequency parameters. For regional parameters, please refer to link

SX1262-LoRa-HAT-021.png

  • To achieve LoRaWAN network coverage in a city or other areas, it requires four components: nodes (LoRa nodes RF chips), gateways (or base stations, with LoRa gateways RF chips), servers, and clouds, as shown in the following diagram.
    • DEVICE (node device) must first send an access request data packet to the GATEWAY (gateway), which then forwards it to the server. After authentication is successful, it can then normally exchange application data with the server.
    • GATEWAY (gateway) can communicate with the server via wired networks, 3/4/5G wireless networks
        • The main operators on the server side are TTN, etc. For setting up your own cloud service, please refer to lorawan-stack and chirpstack

600px-1350px-SX1268-LoRa-HAT-021.png

  • There are two ways for Raspberry Pi Pico and Pico-LoRa-SX1262 to access the Internet through LoRaWAN, one is OTAA (Over-The-Air-Activation), and the other is ABP (Activation By Personalization). This article connects to the network using method one, OTAA, as shown in the following figure. For detailed information, please refer to the documents Link 1, Link 2 and Source code
    • Step 1. The terminal device sends a Join-Request message to the network it wishes to join, noting that the joining process is always initiated by the terminal device. The Join-Request message can be transmitted at any data rate and using one of the specific regional joining channels. For example, in Europe, the terminal device can send a Join-Request message by randomly selecting from 868.10 MHz, 868.30 MHz, or 868.50 MHz. The Join-Request message reaches the network server through one or more gateways. Additionally, note that the appropriate frequency bands should be selected according to local radio regulations. For specific frequency band distribution tables, click link to view or visit LoRa Alliance to search.The Join-Request message consists of the following fields, while AppEUI and DevEUI are generated during server-side registration, please refer to the following instructions.
      • AppEUI: A 64-bit globally unique application identifier in the IEEE EUI64 address space, uniquely identifying the entity capable of processing Join-Request frames.
      • DevEUI: A 64-bit globally unique device identifier that uniquely identifies the terminal device in the EEE EUI64 address space.
      • DevNonce: A unique random 2-byte value generated by the terminal device. The network server uses the DevNonce of each terminal device to track their join requests. If the terminal device sends a join request using a previously used DevNonce (this is called a replay attack), the network server will reject the join request and not allow the terminal device to register with the network.
    • Step 2. The network server processes the Join-Request-Message. If the terminal device is allowed to join the network, the network server will generate two session keys (NwkSKey and AppSKey) and a Join-Accept message. Then, the Join-accept message itself is encrypted using the AppKey. The network server uses AES decryption operations in ECB mode to encrypt the Join-Accept message.
    • Step 3. The network server sends the encrypted Join-Accept message back to the terminal device as a normal downlink.
    • Step 4. The terminal device decrypts Join-Accept using AES. It then uses AppKey and AppNonce to generate two session keys, NwkSKey and AppSKey, for subsequent communication with the Networking server. The Network Server also stores kSKey, and the Join server distributes AppSKey to the Application Server.

Pico-LoRa-SX1262-868M 016.png

  • As DevEUI and AppEUI parameters for terminal devices to access the Internet, they need to be registered and generated by the server side. The specific process is as follows:
    • Register and log in to TTS and create applications

1000px-Pico-LoRa-SX1262-868M 006.jpg

    • Create a node device in the current application, and click the red box in the figure below

1000px-Pico-LoRa-SX1262-868M 007.jpg

    • The various parameters for creating a node device are shown in the 5 steps within the red box as shown in the figure, and it is necessary to save the DevEUI in Step 2 and the AppKey value in Step 3 for future use

Pico-LoRa-SX1262-868M 008.jpg

Applications

LoRa devices and networks (such as LoRaWAN) enable smart IoT applications to help address the formidable challenges faced by the Earth, including energy management, natural resource reduction, pollution control, infrastructure efficiency, and disaster prevention. Semtech's LoRa devices have already achieved hundreds of successful application cases in fields such as smart cities, homes and buildings, communities, metering, supply chain and logistics, and agriculture. LoRa networks now cover hundreds of millions of devices across more than 100 countries and regions, committed to building a smarter planet.


This product test is based on TTS(The THINGS STACK) and Semtech SX1302 official library. If users set up their own cloud server, please refer to lorawan-stack and chirpstack


Demo Download

Raspberry Pi 4B

Copy the following commands to the Raspberry Pi terminal one by one and wait for each command to finish. If there is an error, please check the context.

sudo apt update
sudo apt install git
cd ~/Documents/
git clone https://github.com/siuwahzhong/sx1302_hal.git
cd sx1302_hal
git checkout ws-dev
make clean all
make all
cp tools/reset_lgw.sh util_chip_id/
cp tools/reset_lgw.sh packet_forwarder/

Raspberry Pi 5

wget https://files.waveshare.com/wiki/SX130X/demo/PI5/sx130x_hal_rpi5.zip
sudo unzip sx130x_hal_rpi5.zip
cd sx1302_hal_rpi5-master/
make clean all
make all
cp tools/reset_lgw.sh util_chip_id/
cp tools/reset_lgw.sh packet_forwarder/

Demo

1. Open the website to register a TTS account and log in
2. Get the gateway EUI for later use

# get sx1302 EUI -- Pi 4B
cd ~/Documents/sx1302_hal/util_chip_id/
./chip_id 
# get sx1302 EUI -- Pi 5
cd util_chip_id/
sudo ./chip_id

SX1302 LoRaWAN Gateway HAT 003.jpg
3. Add a gateway device to TTS, as shown in the figure below, and select the frequency band according to the region SX1302 LoRaWAN Gateway HAT 002.jpg
SX1302 LoRaWAN Gateway HAT 004.jpg
SX1302 LoRaWAN Gateway HAT 005.jpg

3. After creating a gateway device on TTS, enter the device Overview interface, download the configuration file, and modify the test_conf configuration file in the sx1302_hal library as shown in the figure below

# Pi 4B
cd ~/Documents/sx1302_hal/packet_forwarder/
cp global_conf.json.sx1250.EU868 test_conf.json
# Pi 5
cd packet_forwarder/
cp global_conf.json.sx1250.EU868 test_conf.json

SX1302 LoRaWAN Gateway HAT 006.jpg
3.1 Modify the contents of test_conf.json file according to the global_conf.json downloaded from the TTS website, noting the filling of parameters related to the sections radio_0, radio_1, and gateway_conf.
SX1302 LoRaWAN Gateway HAT 007.jpg

4. Run packet_forwarder
After modifying the various parameters of the configuration file and running the packet-forwarder program, the gateway starts to connect to TTS and keeps connected

# Pi 4B
cd ~/Documents/sx1302_hal/packet_forwarder/
./lora_pkt_fwd -c test_conf.json
# Pi 5
cd packet_forwarder/
./lora_pkt_fwd -c test_conf.json

Node Access

For related documents, please refer to Pico-LoRa-SX1262-868M


FAQ

 Answer:
  • Please enable I2C
  • After enabling I2C normally, the I2C devices can be identified:

I2c-addr-sx1302.png


 Answer:

Please reassemble the modules, then restart the Raspberry Pi.


 Answer:

The frequency range of SX1302 LoRaWAN Gateway HAT is EU868 (863-870MHz) This frequency band can be used to develop products in China, but cannot cover a large area of the regional network; The 470M lora used in China can cover the regional network .



 Answer:

It is considered that the UART is not enabled, and configure the UART as follows: Open the /boot/config.txt file, find the following configuration statement to enable the serial port, if not, you can add it to the end of the file.

enable_uart=1

For Raspberry Pi 3B users, the serial port is used for Bluetooth and needs to comment out:

#dtoverlay=pi3-miniuart-bt

Then restart Raspberry Pi:

sudo reboot

Make sure both Raspberry Pis are processed in the same way, then connect the A of one module to the B of the other module
If you are using other 485 devices, make sure to connect A-A, B-B.


 Answer:
  • It is considered that it is caused by the SPI not being enabled, please enable the SPI on the Raspberry Pi;
  • Considering it may be due to poor contact between the golden finger, please press down on the tail and test again to ensure a good fit between the modules.


 Answer:
  • SX1303 has lower power consumption than SX1202.
  • SX1303 supports fine time stamps, which can be used for network positioning based on calculated time differences, while SX1302 does not support this function.


 Answer:

SX1303 supports 8-channel SF5~12 LoRa solution, SX1303 gateway supports 8-channel simultaneous reception of node data, and supports single-channel sending data to nodes.


 Answer:

The demo in this WIKI uses Raspberry Pi 4B and is not suitable for Raspberry Pi 5. If using Raspberry Pi 5, you need to modify the GPIO pin.


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)