# Raspberry Pi as LoRa wan node (send data to gateway to forward to TTN)

**URL:** <https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704>\
**Category:** End Devices (Nodes)\
**Created:** [July 23, 2024, 2:20am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704 "2024-07-23T02:20:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakindu](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lakindu](https://www.thethingsnetwork.org/forum/u/lakindu)\
**Post date:** [July 23, 2024, 2:20am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/1 "2024-07-23T02:20:29Z")

</div>

I am using a Raspberry Pi Model 4b with [SX1262 LoRa wan hat](https://www.waveshare.com/sx1262-lorawan-hat.htm) to send data to the RAK gateway which uploads data to TTN.

I found some sample [code](https://files.waveshare.com/wiki/SX1262-XXXM-LoRaWAN-GNSS-HAT/Sx126x_lorawan_hat_code.zip) that is called “Sx126x lorawan hat code” but after going through the code I am led to believe that it is not for a lora wan but for simple lora p2p.

I am a little confused because I cannot understand if it is possible to use the Raspberry Pi as a LoRwan node? If I can do so, what are the libraries I need to use? This is needed by my company as a part of their project so any help would be much appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [July 23, 2024, 6:59am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/2 "2024-07-23T06:59:51Z")

</div>

> [@lakindu](#):
>
> if it is possible to use the Raspberry Pi as a LoRwan node?

Yes it is possible. However for LoRaWAN the sx1262 isn’t a good choice when used with a raspberry pi. LoRaWAN has very strict timings which are hard to realize using a non realtime Linux system. It is magnitudes easier to implement it on a microcontroller that does not run an operating system.  
For use with the Raspberry Pi a module that does the critical timing itself and interfaces using an UART would be a better choice. Something like Wio-E5 from Seeed or RAK3172.

---

<div class="post-metadata">

**Author:** ![lakindu](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lakindu](https://www.thethingsnetwork.org/forum/u/lakindu)\
**Post date:** [July 23, 2024, 9:31am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/3 "2024-07-23T09:31:18Z")

</div>

> Yes it is possible. However for LoRaWAN the sx1262 isn’t a good choice when used with a raspberry pi. LoRaWAN has very strict timings which are hard to realize using a non realtime Linux system.

I see. If I have to implement it, regardless of its disadvantages, how do I go about it because the library that I linked doesn’t seem to support LoRa wan, just LoRa p2p only?

Thank you

Edit - Typo

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [July 23, 2024, 10:02am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/4 "2024-07-23T10:02:11Z")

</div>

> [@lakindu](#):
>
> regardless of its disadvantages,

The disadvantages are that communication will not be reliable so there is a enormous chance things won’t work well resulting in lost packets and gateways having to transmit too often (causing DoS for other devices).

If you want to proceed anyway you need to find code that does implement LoRaWAN for the sx1262 chipset. Radiolib comes to mind. However, if it doesn’t work well, don’t come back complaining because a Raspberry Pi is totally unsuited for the timings involved. Too much timing noise because of the operating system. For LoRaWAN you need something that can implement strict timing or offload that burden to the module (which is not possible with the sx1262 stand-alone)

---

<div class="post-metadata">

**Author:** ![stevencellist](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/stevencellist/32/46434_2.png) [@stevencellist](https://www.thethingsnetwork.org/forum/u/stevencellist)\
**Post date:** [July 23, 2024, 10:37am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/5 "2024-07-23T10:37:16Z")

</div>

The maintainer/owner of RadioLib has tried running the LoRaWAN stack on a Raspberry Pi for 3~4 hours which reportedly ran fine, but over time it is very likely to demonstrate the behaviour explained by @kersing.

---

<div class="post-metadata">

**Author:** ![lakindu](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lakindu](https://www.thethingsnetwork.org/forum/u/lakindu)\
**Post date:** [July 25, 2024, 9:49am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/6 "2024-07-25T09:49:50Z")

</div>

> For use with the Raspberry Pi a module that does the critical timing itself and interfaces using an UART would be a better choice.

Taking your advice, I established the connection to the ESP32 with the Raspberry Pi using USB connection and it works like a charm so thank you for that.

For the esp32, I want to take the values and forward it to LoRa wan. However, one problem I encountered in the RadioLib example was the Network key. I can find the DevEUI, AppEUI, AppKey in the ttn console for the gateway but I cannot find the Network key. Could you kindly tell me how to find the Network key?

Thank you!

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [July 25, 2024, 10:50am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/7 "2024-07-25T10:50:55Z")

</div>

> [@lakindu](#):
>
> Could you kindly tell me how to find the Network key?

Have you selected LoRaWAN version 1.1 in the TTN console for this device?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [July 25, 2024, 11:14am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/8 "2024-07-25T11:14:49Z")

</div>

> [@lakindu](#):
>
> I can find the DevEUI, AppEUI, AppKey in the ttn console for the gateway but I cannot find the Network key.

I’m assured by @CaptainAwesome that the notes.md are foolproof with lots and lots of detail on configuration on the console and for the config.h device file - have you read it?

---

<div class="post-metadata">

**Author:** ![lakindu](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lakindu](https://www.thethingsnetwork.org/forum/u/lakindu)\
**Post date:** [July 29, 2024, 1:48am UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/9 "2024-07-29T01:48:56Z")

</div>

@kersing @descartes I entered the App key to the network key field and the program shows the OTAA verification is successful and an uplink has been sent.

Thank you

---

<div class="post-metadata">

**Author:** ![d00m](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@d00m](https://www.thethingsnetwork.org/forum/u/d00m)\
**Post date:** [October 4, 2024, 4:29pm UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/10 "2024-10-04T16:29:29Z")

</div>

> [@lakindu](#):
>
> I established the connection to the ESP32 with the Raspberry Pi using USB connection and it works like a charm so thank you for that.

hello!  
so did you finally able to use this LoRaWAN Hat with RPI 4B?  
Im also checking if this possible, at least for testing purposes.

---

<div class="post-metadata">

**Author:** ![hamzaaa](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@hamzaaa](https://www.thethingsnetwork.org/forum/u/hamzaaa)\
**Post date:** [September 1, 2025, 5:07pm UTC](https://www.thethingsnetwork.org/forum/t/raspberry-pi-as-lora-wan-node-send-data-to-gateway-to-forward-to-ttn/68704/11 "2025-09-01T17:07:24Z")

</div>

Hello!  
I am trying to make a similar prototype for testing purposes by using a Raspberry Pi Model B and a standalone SX1262 using Python. I am trying to make a LoRaWAN and getting issues after making the needed configurations and I am guessing for same issues mentioned by Kersing. I am wondering if an MKR WIFI 1010 Arduino would help me in this case because I dont have the ESP32 please ? also if I got you right the raspberry pi and the arduino would be used simultaneously to build LoRaWAN ? @lakindu tagging you because I see you used ESP32 if you can share your experience please that would be really helpful. thankyou !
