SX1303 915M LoRaWAN Gateway Module+HAT for Raspberry Pi (CE09113)

Hey Michael,

Looks like it might be the best way to go with your suggestion there. If you have it functioning with those changes it should realistically work on Pete’s device.

@Pete85947 Out of question are you using this with a Pi 4 model B and are you running this on Bookworm OS or a previous version. Waveshare can take a while to change some of their wiki pages and so I wonder if its possible this issue could be affected by incompatibility somewhere?

Cheers,
Blayden

2 Likes

OK, I’m just going to make this quick.

A big shout-out to Michael99645 for taking the time to help me better understand LoRaWAN and providing the fix for the GPS issue. Without his assistance, I probably wouldn’t have pursued fixing the downlink issue from The Things Network, as the existing setup was sufficient to complete my project. Now, all my original issues have been resolved.

Further testing by 180 students at the upcoming AgTech events in Orange, Wagga Wagga, and Armidale should provide a thorough stress test for this setup—and turn my hair a little greyer.

I’ll attach my working global_conf.json.sx1250.AU915 for everyone to enjoy. :blush:
global_conf.json.sx1250.AU915.zip (1.4 KB)

Over the next month, I’ll do a more detailed walkthrough, as this will be needed for the students if they want to create their own LoRaWAN gateway.

Thank you everyone!!!

Kind regards,
Pete Smith

Before :frowning:
image

After :smiley:

4 Likes

Thanks for sharing @Pete85947!!!

Looking forward to the detailed work though as I’m sure many people will find it extremely helpful :slight_smile:

2 Likes

Here is the first draft. :slight_smile:

LoRaWAN GateWay SX1303 AU915.pdf (4.4 MB)

Cheers
Pete Smith

5 Likes

Second Draft: LoRaWAN GateWay SX1303 AU915

  • Added TTN setup.
  • Fixed some command line errors.

LoRaWAN GateWay SX1303 AU915.pdf (4.8 MB)

Cheers
Pete Smith

2 Likes

Such a comprehensive writeup @Pete85947 - this kind of high quality instruction is what gets peoples projects done. Nice work :slight_smile: I’m sure other makers will find it useful on their journey too

2 Likes

Thanks. This was super helpful in getting my gateway running.

FYI, for your next version of the doc, you have a typo in the name of the service you create in a couple of spots on page 19 - “loarpacketforward.service” rather than “lorapacketforward.service”

Also, in case anyone else is having problems, I didn’t get this to work on Debian Bookworm which the latest Raspberry Pi OS is built on, so I went back to a Bullseye version and it worked fine. My understanding is that “echo xx > /sys/class/gpio/export” is no longer supported as a way to address the gpio ports, and the reset_lgw.sh script relies on that to reset the ports.

Thanks,
Mark

2 Likes

Thank heaps for the feedback, Mark165263. I’m glad you found it useful. :blush: I’ll update my walkthrough. :+1:

I found the same issue with Raspberry Pi OS Bookworm. That’s why I mentioned under Software Requirements that I was using Raspberry Pi OS (Debian Bullseye). However, there is some good news. I found a discussion on GitHub that addresses this issue: Failed to start the concentrator with kernel 6.6.22 (Pi 4B Bookworm + SX130X). This file is supposed to fix the issue.
reset_lgw.gpiod.zip (678 Bytes)

I will give Bookworm a try with the new reset_lgw.gpiod.sh over the coming weeks, unless you beat me to it. :smile:

Update:
I’ve tested the file reset_lgw.gpiod.sh on Debian Bookworm with both an RP3b+ and an RP4, and it appears to work well. :slight_smile:

You will need to rename it to reset_lgw.sh and place a copy in both of the following folders: util_chip_id/ and packet_forwarder/.

Cheers
Pete

2 Likes

Third Draft: LoRaWAN GateWay SX1303 AU915

LoRaWAN GateWay SX1303 AU915.pdf (4.8 MB)

Cheers
Pete

2 Likes

Hey guys, I’m looking at this product: SX1303 915M LoRaWAN Gateway Module+HAT for Raspberry Pi | Buy in Australia | CE09113 | Waveshare22613 | Core Electronics

Is this compatible with a raspberry pi 5 via gpio pins?
Is the pcie required to be plugged into the pi or is this optional when using the gpio pins?

Thanks for your time!

Hi @Jackson277976, Welcome to the forums!!!

From the Product Wiki it says it requires modification to work with the Pi 5.

From what I can tell the pinout should work with the Pi 5 but you’d have to dig a lot deeper to know for sure.

All communication between the board and the Pi should work over GPIO using the UART, I2C and SPI so no need for a PCIe connector.

Hi Guys,

I really need help with my setup. This is my first time working with Lorawan. I want to send data from moisture sensor connected to multiple Arduino MKR WAN 1310 directly to my Rasp 4 without using TTN or Chirpstack.

I have this Arduino code but I have no idea how to start writing my python code. I am finding it difficult to incorporate GitHub - Lora-net/sx1302_hal: SX1302/SX1303 Hardware Abstraction Layer and Tools (packet forwarder...)

#include <SPI.h>
#include <LoRa.h>

int moisturePin = A0; // Analog pin connected to moisture sensor
int counter = 0;

void setup() {
  Serial.begin(9600);
  while (!Serial);

  LoRa.begin(915E6); // Set frequency to 915 MHz
}

void loop() {
  int moistureValue = analogRead(moisturePin);

  LoRa.beginPacket();
  LoRa.print("Moisture: ");
  LoRa.print(moistureValue);
  LoRa.print(" Counter: ");
  LoRa.print(counter);
  LoRa.endPacket();

  counter++;
  delay(10000); // Send data every 10 seconds
}

I would appreciate any help. Thank you guys.

Hey @klyde280140, welcome to the forums!

Could we get a bit more clarification on the exact issue you’re having? It sounds like you currently have a working Arduino MKR WAN sending LoRa packets, and you’re not sure what code to use to receive them with your RPi 4. Is this correct?

Here are some good resources to get started with LoRa on RPi:

Hope this helps!

Hi @Zach Yes that is correct. Thank you for the resources that you sent. However, I found https://forum.core-electronics.com.au/uploads/short-url/oGzMGvOs0kGF9i2zuzv9rKhvoaL.pdf, made by @Pete85947 really useful.

I managed to get the device EUI but when I created my gateway on The Things Stack, I got the error shown below. Has someone experienced the same error?

Hey @klyde280140,

Interesting, I’m doing some investigating but haven’t found much yet. A couple of questions I had:

  • Are you currently trying to send/receive LoRa packets? Or simply opening the gateway in isolation?
  • I noticed the $@ at the beginning of the stack address, I haven’t used LoRaWAN or TTN very much but this looked non-standard and I couldn’t see anything referencing this in the pdf you sent. Do you know the purpose of this/If it is an error?

This is the configuration on my Raspberry pi 4 model B+

My target.config

# That file will be included in the Makefiles to configure where to install files on the target
# The IP address of the gateway host on which the files need to be installed
TARGET_IP=192.168.118.44
# The directory on the gateway file system to which  the files need to be installed
TARGET_DIR=/home/smartnest/Desktop/TTN/sx1302_hal/bin
# The user to be used by ssh/scp to copy the files on the gateway host
TARGET_USR=smartnest


My global_conf.json.sx1250.AU915 


{ 
"SX130x_conf": { 
"com_type": "SPI", 
"com_path": "/dev/spidev0.0", 
"lorawan_public": true, 
"clksrc": 0, 
"antenna_gain": 0, /* antenna gain, in dBi */ 
"full_duplex": false, 
"fine_timestamp": { 
"enable": false, 
"mode": "all_sf" /* high_capacity or all_sf */ 
}, 
"sx1261_conf": { 
"spi_path": "/dev/spidev0.1", 
"rssi_offset": 0, /* dB */ 
"spectral_scan": { 
"enable": false, 
"freq_start": 867100000, 
"nb_chan": 8, 
"nb_scan": 2000, 
"pace_s": 10 
}, 
"lbt": { 
"enable": false,
 "rssi_target": -70, /* dBm */ 
                "channels":[ /* 16 channels maximum */ 
                    { "freq_hz": 867100000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 867300000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 867500000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 867700000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 867900000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 868100000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 868300000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 868500000, "bandwidth": 125000, "scan_time_us": 128, "transmit_time_ms": 400 }, 
                    { "freq_hz": 869525000, "bandwidth": 125000, "scan_time_us": 5000 "transmit_time_ms": 4000 }, 
                    { "freq_hz": 868300000, "bandwidth": 250000, "scan_time_us": 128, "transmit_time_ms": 400 } 
                ] 
            } 
        }, 
        "radio_0": { 
            "enable": true, 
            "type": "SX1250", 
            "freq": 917200000, 
            "rssi_offset": -166, 
            "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 
2162.56, "coeff_e": 0}, 
            "tx_enable": true, 
            "tx_freq_min": 915000000, 
            "tx_freq_max": 928000000, 
            "tx_gain_lut":[ 
                {"rf_power": -6, "pa_gain": 0, "pwr_idx": 15}, 
                {"rf_power": -3, "pa_gain": 0, "pwr_idx": 16}, 
                {"rf_power": 0, "pa_gain": 0, "pwr_idx": 17}, 
                {"rf_power": 3, "pa_gain": 1, "pwr_idx": 19}, 
                {"rf_power": 6, "pa_gain": 1, "pwr_idx": 20}, 
                {"rf_power": 10, "pa_gain": 1, "pwr_idx": 22}, 
                {"rf_power": 11, "pa_gain": 1, "pwr_idx": 1}, 
                {"rf_power": 12, "pa_gain": 2, "pwr_idx": 2}, 
                {"rf_power": 13, "pa_gain": 1, "pwr_idx": 3}, 
                {"rf_power": 14, "pa_gain": 2, "pwr_idx": 4}, 
                {"rf_power": 16, "pa_gain": 2, "pwr_idx": 5}, 
                {"rf_power": 20, "pa_gain": 3, "pwr_idx": 6}, 
                {"rf_power": 23, "pa_gain": 3, "pwr_idx": 7}, 
                {"rf_power": 25, "pa_gain": 3, "pwr_idx": 9}, 
                {"rf_power": 26, "pa_gain": 3, "pwr_idx": 11}, 
                {"rf_power": 27, "pa_gain": 1, "pwr_idx": 14} 
            ] 
        }, 
        "radio_1": { 
            "enable": true, 
            "type": "SX1250", 
            "freq": 917900000, 
            "rssi_offset": -166, 
            "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 
2162.56, "coeff_e": 0}, 
            "tx_enable": false 
        }, 
        "chan_multiSF_All": {"spreading_factor_enable": [ 5, 6, 7, 8, 9, 10, 11, 12 ]}, 
        "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000}, 
        "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000}, 
        "chan_multiSF_2": {"enable": true, "radio": 0, "if":  0}, 
        "chan_multiSF_3": {"enable": true, "radio": 0, "if": 200000}, 
        "chan_multiSF_4": {"enable": true, "radio": 1, "if": -300000}, 
        "chan_multiSF_5": {"enable": true, "radio": 1, "if": -100000}, 
        "chan_multiSF_6": {"enable": true, "radio": 1, "if":  100000}, 
        "chan_multiSF_7": {"enable": true, "radio": 1, "if":  300000}, 
        "chan_Lora_std":  {"enable": true, "radio": 0, "if": 300000, "bandwidth": 
500000, "spread_factor": 8}, 
        "chan_FSK":       {"enable": false} 
    },
     "gateway_conf": { 
        "gateway_ID": "0016c001f15d6662", 
        /* change with default server address/ports */ 
        "server_address": "au1.cloud.thethings.network", 
        "serv_port_up": 1700, 
        "serv_port_down": 1700, 
        /* adjust the following parameters for your network */ 
        "keepalive_interval": 10, 
        "stat_interval": 60, 
        "push_timeout_ms": 100, 
        /* forward only valid packets */ 
        "forward_crc_valid": true, 
        "forward_crc_error": false, 
        "forward_crc_disabled": false, 
        /* GPS configuration */ 
        "gps_tty_path": "/dev/ttyS0", 
        /* GPS reference coordinates */ 
        "ref_latitude": 0.0, 
        "ref_longitude": 0.0, 
        "ref_altitude": 0, 
                "servers": [ 
                  { 
                        "gateway_ID": "0016c001f15d6662", 
                        "server_address": "au1.cloud.thethings.network", 
                        "serv_port_up": 1700, 
                        "serv_port_down": 1700, 
                        "serv_enabled": true 
                  } 
                ] 
    }, 
 
    "debug_conf": { 
        "ref_payload":[ 
            {"id": "0xCAFE1234"}, 
            {"id": "0xCAFE2345"} 
        ], 
        "log_file": "loragw_hal.log" 
    } 
}

This is the result I am getting when I ran ./lora_pkt_fwd -c global_conf.json.sx1250.AU915

*** Packet Forwarder ***
Version: 2.1.0
*** SX1302 HAL library version info ***
Version: 2.1.0;
***
INFO: Little endian host
INFO: found configuration file global_conf.json.sx1250.AU915, parsing it
INFO: global_conf.json.sx1250.AU915 does contain a JSON object named SX130x_conf, parsing SX1302 parameters
INFO: com_type SPI, com_path /dev/spidev0.0, lorawan_public 1, clksrc 0, full_duplex 0
INFO: antenna_gain 0 dBi
INFO: Configuring legacy timestamp
INFO: Configuring Tx Gain LUT for rf_chain 0 with 16 indexes for sx1250
INFO: radio 0 enabled (type SX1250), center frequency 917200000, RSSI offset -166.000000, tx enabled 1, single input mode 0
INFO: radio 1 enabled (type SX1250), center frequency 917900000, RSSI offset -166.000000, tx enabled 0, single input mode 0
INFO: Lora multi-SF channel 0>  radio 0, IF -400000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 1>  radio 0, IF -200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 2>  radio 0, IF 0 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 3>  radio 0, IF 200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 4>  radio 1, IF -300000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 5>  radio 1, IF -100000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 6>  radio 1, IF 100000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 7>  radio 1, IF 300000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora std channel> radio 0, IF 300000 Hz, 500000 Hz bw, SF 8, Explicit header
INFO: FSK channel 8 disabled
INFO: global_conf.json.sx1250.AU915 does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to 0016C001F15D6662
INFO: server hostname or IP address is configured to "au1.cloud.thethings.network"
INFO: upstream port is configured to "1700"
INFO: downstream port is configured to "1700"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 60 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: GPS serial port path is configured to "/dev/ttyS0"
INFO: Reference latitude is configured to 0.000000 deg
INFO: Reference longitude is configured to 0.000000 deg
INFO: Reference altitude is configured to 0 meters
INFO: global_conf.json.sx1250.AU915 does contain a JSON object named debug_conf, parsing debug parameters
INFO: got 2 debug reference payload
INFO: reference payload ID 0 is 0xCAFE1234
INFO: reference payload ID 1 is 0xCAFE2345
INFO: setting debug log file name to loragw_hal.log
WARNING: [main] impossible to open /dev/ttyS0 for GPS sync (check permissions)
CoreCell power enable on through GPIO18...
CoreCell reset through GPIO23...
SX1261 reset through GPIO22...
CoreCell ADC reset through GPIO13...
Opening SPI communication interface
Note: chip version is 0x12 (v1.2)
INFO: using legacy timestamp
INFO: LoRa Service modem: configuring preamble size to 8 symbols
ARB: dual demodulation disabled for all SF
INFO: found temperature sensor on port 0x39
INFO: [main] concentrator started, packet can now be received
INFO: concentrator EUI: 0x0016c001f15d6662
INFO: [down] PULL_ACK received in 94 ms
INFO: [down] PULL_ACK received in 48 ms
INFO: [down] PULL_ACK received in 57 ms
INFO: [down] PULL_ACK received in 81 ms
INFO: [down] PULL_ACK received in 118 ms
INFO: [down] PULL_ACK received in 50 ms

##### 2024-09-26 12:04:14 GMT #####
### [UPSTREAM] ###
# RF packets received by concentrator: 0
# CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
# RF packets forwarded: 0 (0 bytes)
# PUSH_DATA datagrams sent: 0 (0 bytes)
# PUSH_DATA acknowledged: 0.00%
### [DOWNSTREAM] ###
# PULL_DATA sent: 6 (100.00% acknowledged)
# PULL_RESP(onse) datagrams received: 0 (0 bytes)
# RF packets sent to concentrator: 0 (0 bytes)
# TX errors: 0
### SX1302 Status ###
# SX1302 counter (INST): 60904350
# SX1302 counter (PPS):  60086332
# BEACON queued: 0
# BEACON sent so far: 0
# BEACON rejected: 0
### [JIT] ###
src/jitqueue.c:440:jit_print_queue(): INFO: [jit] queue is empty
#--------
src/jitqueue.c:440:jit_print_queue(): INFO: [jit] queue is empty
### [GPS] ###
# GPS sync is disabled
### Concentrator temperature: 33 C ###
##### END #####

And I am not able to connect to TTN. I have my gateway as “DISCONNECTED”

LORAWAN MODULE PINOUT

Hey @klyde280140,

Reading further into this “Axios Error” from TTN leads me to believe it is not a problem on your end, at least not entirely.

It seems (from reading forum posts like this one) that TTN/TTS can often output this Axios Error simply because another user is “hogging resources”. TTN is free to use, provided that you allow all nearby sensors to communicate publicly, and because it’s all based on community goodwill, you may run into problems using it every now and then.

I have two suggestions:

  1. Ensure your devices are meeting the requirements to be integrated into the TTN LoRaWAN network.

  2. Consider another stack option, I understand this is not ideal given your requirements in the original post, but it seems this issue exists for the same reason you were drawn to use TTN in the first place.

I did not notice anything wrong with your Arduino or Python code, further backing up my thoughts that it is not a setup issue.

Hope this helps!

1 Like