# LoRaWAN Adventures with the SX1303

**URL:** <https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891>\
**Category:** Show and Tell\
**Tags:** lora\
**Created:** [September 2, 2021, 8:30pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891 "2021-09-02T20:30:37Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![xoseperez](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/xoseperez/32/4970_2.png) [@xoseperez](https://forums.balena.io/u/xoseperez)\
**Post date:** [March 8, 2022, 10:46am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/81 "2022-03-08T10:46:32Z")

</div>

Hacking away is good 🙂.

I have used the Chirpstack multiplexer to bypass restrictive firewalls by sending the UDP packets over NTP port (123/udp) since this is usually always open. The multiplexer will just forward 123/udp to 1700/udp and back seemlessly. 😉

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [March 8, 2022, 12:17pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/82 "2022-03-08T12:17:52Z")

</div>

> [@nmaas87](#):
>
> would really love to have my own “private” Stack for just my own, internal sensors

It’s fairly straightforward to run a completely local LoRa stack with Chirpstack. Basically just run all the apps in separate containers on a single Pi. Basicstation → Gateway Bridge → Network Server → Application Server from there you could point webhooks or MQTT to other local apps.

I did it once a while back and it wasn’t difficult at all. One thing I like is that installing Gateway Bridge on the actual gateway with your concentrator makes it pretty easy to pipe to an MQTT broker (I liked [emqx](https://www.emqx.com/en/products/emqx)) from which you could send anywhere, local or cloud.

You could do this with TTS (or is it still called the things stack?) by installing locally too.

@xoseperez that multiplexer is an interesting find, thanks for sharing.

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [March 8, 2022, 1:07pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/83 "2022-03-08T13:07:18Z")

</div>

Thank you for the detailed overview - I am sorry I must have caused some confusion here.  
I actually had a Chirpstack already running, courtesy of RAKwireless Firmware for the RAK5146 - so not on balena :). But I actually manged to setup my own, private gateway at that time.

I think I will try to go into the direction of setting up the udp-packet-forwarder - but sending all data into an (maybe existing) balena Chirpstack instance and include the multiplexer. I basically want my own household sensors off TTNv3 - espcially as I want them to continue working even if the internet is flaky. Yesterday night I prepared the otherside of things, made an MQTT bridge to TTNv3 for my current sensors, brought the payload down and decoded it offline - and setup the InfluxDBv2 and Grafana instances (this is all done on my homeserver, so no balena there, but some Docker). So now I only need to send the calibrated data to InfluxDB and graph them in Grafana to be able to move away from external data logger/graphers (I never had the time to make it right, so… yeah, shameful to admit it. But now I want to get that done as I have to do something similar for my company, so doing this at home is a good learning oppurtunity. Also, I will include some balena Sensor nodes and pipe the data to the same Mosquitto instance and got then one central calibration/ingestion script which will make including different/additional sensors very easy as a preprocessing entity to InfluxDB).

As for emqx - I think I will take a look at it. Seeing the link I was laughing because some weeks ago I installed their MQTTX which is one of the most capable MQTT browsers/clients I have seen so far. I like that thing a lot :). However, as my Master Thesis centered around the performance of Message Brokers in extreme situations, I am very loyal to the winner (and my personal favorite since ever), Mosquitto 😉 . But thank you very much for all the infos! 🙂

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [March 8, 2022, 2:19pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/84 "2022-03-08T14:19:08Z")

</div>

> [@nmaas87](#):
>
> and setup the InfluxDBv2

Have you seen [timescale](https://www.timescale.com), I’ve been testing rather than Influx which has been so much easier since its Postgres under the hood 👍

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [March 8, 2022, 3:31pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/85 "2022-03-08T15:31:15Z")

</div>

Nice one. Though I must admit I am a total fan of good old MySQL and MariaDB - sometimes MSSQL. I do need to configure quite some Postgres for my job, but I never really got the hang of it 😃 Does this integrate into Grafana easily, just out of curiosity?

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [March 8, 2022, 3:44pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/86 "2022-03-08T15:44:54Z")

</div>

Yeah, its the same as picking postgres as a source in Grafana

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [March 13, 2022, 8:27pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/87 "2022-03-13T20:27:10Z")

</div>

So… my ultimate goal was to integrate my gpsTime ( [GitHub - nmaas87/gpsTime: balena enabled GPS NTP timeserver](https://github.com/nmaas87/gpsTime) ) project with the RAK5146 - as the RAK5146 got a nice GPS module and even output the PPS signal - but sadly RAK did not manage to output it via the RAK2287/RAK5146 Pi HAT to the Raspberry Pi.

My initial idea was to solder directly to the PCI-E socket - just getting the PPS signal from there. However, the thing I **REALLY WOULD NEED** in my lab would be a 10-20x binocular/stereomicroscope - because these jobs are too tiny for my 2x magnifying glass. I tried, but failed. So I shelved the idea again. Until today.

In the meantime, I had migrated my LoRaWAN sensors from ThingSpeak to my private InfluxDB/Grafana instance and still had one ESP8266/BME280 combo hanging at my desk that reported to ThingSpeak. I wanted to this combo to be gone - or more than that, replaced by some RPi with belanaSensor. Hm… let me think. I got an RPi 3 just running the udp-packet-forwarder… basically having its i2c interface free… and a lot of cpu cycles and memory left… wait a minute…

I started again with the RPi hat and noticed the unpopulated 9x2 area on the board.  
A radio? Maybe meant for some SX-something-something? Hm… Would not make sense…  
I pulled out my multimeter, getting the first gnd point measured. Then I saw that some points where connected to i2c. Ok, damn, this is no SX. The 9x2 grid makes no sense, these pads should be for some non-radio function. But,… it got an antenna out so… Let me see. I think this hat is just recycled… What else got RAK in stock? BINGO! - the RAK2247 Pi Hat ( [Connect RAK2247 Concentrator module to Raspberry Pi with this Pi HAT – RAKwireless Store](https://store.rakwireless.com/collections/wishat/products/rak2247-pi-hat?variant=36031289688222) ) - with a big fat Ublox MAX-7Q module at the unpopulated spot. Where is the damn manual?! Ah… it matches my findings! ( [https://www.u-blox.com/sites/default/files/products/documents/MAX-7\_DataSheet\_UBX-13004068.pdf](https://www.u-blox.com/sites/default/files/products/documents/MAX-7_DataSheet_UBX-13004068.pdf) )  
Could it be that even the 1 PPS output would be linked from this unpopulated area to the 1 PPS port on the PCI-E?! IT IS!

So I got my 3v3, GND and SDA/SCL for my BME280 sensor - and the 1 PPS output already tied to the RAK5146 without the need to solder a fine pitch!

![max7q](https://global.discourse-cdn.com/balena/original/2X/7/798a4185db8127ffb3e5fc300903f9f8d56bb074.png)

With that, I needed to go through all RPi pins and find one which was not used by the hat. Spoiler: They are nearly all used, except the I2C ID ports and GPIO 4 - so GPIO 4 it is! I soldered the 1 PPS output to the GPIO 4 - which will be used later by my gpsTime project.

 ![s1](https://global.discourse-cdn.com/balena/original/2X/b/bb69b3ffd44988a128f0123bd5893d0982badd6e.jpeg)

Then I added a breakout for 3v3, GND, SDA, SCL

 ![s2](https://global.discourse-cdn.com/balena/original/2X/e/e4b877ab19c19f918bf0184acee31a6ee8ca0c33.jpeg)

(Some reference stuff [RAK2287/RAK5146 Pi HAT Datasheet | RAKwireless Documentation Center](https://docs.rakwireless.com/Product-Categories/WisHat/RAK2287-RAK5146-Pi-HAT/Datasheet/#overview-2) / [RAK5146 WisLink LPWAN Concentrator Datasheet | RAKwireless Documentation Center](https://docs.rakwireless.com/Product-Categories/WisLink/RAK5146/Datasheet/#hardware) )

After that - I put everything together on the wall behind my TV.  
Loaded up a new docker-compose binding udp-packet-forwarder (with GPS=0), a gpsTime instance using GPIO4 and balenaSensor with my network mosquitto server. And thats it 🙂

Now I got my RAK5146 working (with fake GPS, because I don’t need it, the PPS output will probably be used on the RAK5146 module as it is hardwired), gpsTime with precise GPS/PPS signal from the RAK5146 M8Q module and balenaSensor taking care of my BME280 - so that now everything is on one neat system.

 ![s3](https://global.discourse-cdn.com/balena/original/2X/c/c2b8a0a678bc0ee067bf3143300c637c763a7944.jpeg)

And well, what shall I say? It works! 🙂

Still have to see about the LoRa multiplexer, but thats something for another weekend or so 🙂

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [March 23, 2022, 9:43pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/88 "2022-03-23T21:43:58Z")

</div>

So, I got the chirpstack-packet-multiplexer running as the fourth service on my RPi 3 - and it has still a lot of resources free :). The mux is currently only used as plumping between the udp-packet-forwarder and TTNv3 - but as soon as I get my own Chirpstack setup again on my side, I will add this as another destination and rework my Mosquitto/InfluxDBv2/Grafana setup to an all-in-house system. Very welcome, after I had some ISP outages last week 🙂

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [March 24, 2022, 12:05pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/89 "2022-03-24T12:05:08Z")

</div>

Looking forward to see this running on balena @nmaas87

do you have a public repo for this?

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [March 24, 2022, 3:22pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/90 "2022-03-24T15:22:51Z")

</div>

Hi Marc,  
I don’t really know which part you specifically mean.  
The Mosquitto / InfluxDBv2 / Grafana stack is running on Docker x86,  
the udp-packet-forwarder / chirpstack-packet-multiplexer / gpsTime / balenaSensor on balenaOS RPi 3 / AARCH64.

I have send my current files to this repo, but you need to tweak the files to your own systems (and the gpsTime will not work if you have not hacked your hat like I did): [GitHub - nmaas87/loragw](https://github.com/nmaas87/loragw)

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [March 29, 2022, 10:41am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/91 "2022-03-29T10:41:07Z")

</div>

Thanks @nmaas87 i was thinking on having `Chirpstack LNS` running on balena 🙂

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [May 8, 2022, 9:31am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/92 "2022-05-08T09:31:14Z")

</div>

So, in the meantime I setup my local Chirpstack instance on my home server and now get everything working.  
The Multiplexer does deliver all messages to TTNv3 as well as my local Chirpstack instance and I could migrate my Sensors to be “at home” only. I also ordered some RAK11300 so that I can more easily build my own LoRa nodes, but I need to get working in KiCad 6 (finally) and wait for the parts to arrive (and design the boards, order those and the needed parts etc etc etc). And I updated my blog on the topic :).

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [May 22, 2022, 1:37am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/93 "2022-05-22T01:37:38Z")

</div>

In case you were interested @nmaas87 @mpous, I’ve been trying to get my Oratek Tofu carrier up and running with the RAK5146. At first I was using RAK’s Pi Hat, because the Tofu only has a m.2 connection on the bottom of their board. But recently they came out with an [m.2 → mpcie adapter](https://store.oratek.com/products/tofu-m-2-mpcie-adapter?pr_prod_strat=collection_fallback&pr_rec_id=91ede313f&pr_rec_pid=7252612612294&pr_ref_pid=6227586613446&pr_seq=uniform).

At first, I didn’t think it would work (because nothing is ever that easy) but in fact it’s working very nicely.

Combined with @xoseperez’s bascistation repo I now have a 4GB CM4 with LoRa, Cellular backhaul (Sixfab LTE Hat), UPS power with about 5 hours of battery backup (Sixfab Power Hat) that is solar ready, and plenty of computing power to grow into.

![2022-05-21 21.24.46](https://global.discourse-cdn.com/balena/original/2X/a/a3ae348f9a28f17bbc29e8a1a0ad62d2f8b47a5a.gif)

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [May 22, 2022, 1:56am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/94 "2022-05-22T01:56:52Z")

</div>

Here it is, no power cables 😄

![IMG_10662](https://global.discourse-cdn.com/balena/original/2X/2/250e7ffe6bd21c56fb0f93ec43f88a5cd97683b2.gif)

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [May 22, 2022, 10:23am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/95 "2022-05-22T10:23:54Z")

</div>

Extremely rad setup you got going on there :)! Love it!  
I added some sensors to mine and am going to add an advanced C02 sensor and radiation sensor as well soonish - and that with an RPi 3. And I still got tons of memory and cpu cycles left 😛 - so you can do so much more with the CM4 😉

---

<div class="post-metadata">

**Author:** ![barryjump](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@barryjump](https://forums.balena.io/u/barryjump)\
**Post date:** [May 24, 2022, 5:54pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/96 "2022-05-24T17:54:23Z")

</div>

@xoseperez I was poking around in your repo’s tools folder [basicstation/tools at master · xoseperez/basicstation · GitHub](https://github.com/xoseperez/basicstation/tree/master/tools).

Was going to experiment a bit with it this weekend. Looks like you’re trying to parse the bs logs. How is it working for you?

Been wanting to do this for a long while! Wishing that Semtech would write some prometheus metrics and/or allow for structured json logs out of the box.

---

<div class="post-metadata">

**Author:** ![xoseperez](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/xoseperez/32/4970_2.png) [@xoseperez](https://forums.balena.io/u/xoseperez)\
**Post date:** [May 24, 2022, 8:28pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/97 "2022-05-24T20:28:59Z")

</div>

Oh, they are still a WIP. Actually, thank you for reminding me about them!  
Pretty much a dirty hack to get some metrics, I’m sure there are better ways to do it. My goal is to display some basic metrics on an OLED display connected to the Raspberry Pi based gateway.  
I am mostly interested in the log2api one, since I have no need to persist data… will try to work on it a bit this week.

---

<div class="post-metadata">

**Author:** ![xoseperez](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/xoseperez/32/4970_2.png) [@xoseperez](https://forums.balena.io/u/xoseperez)\
**Post date:** [May 25, 2022, 12:46pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/98 "2022-05-25T12:46:15Z")

</div>

@barryjump I have reviewed the parsers and decided to move them to their own repo instead of being under the basicstation repo (after all there is a parser for the UDP Packet Forwarder image too). You can now find them here:

> **[GitHub - xoseperez/packet-forwarder-loggers: Set of parsers and loggers to...](https://github.com/xoseperez/packet-forwarder-loggers)**
>
> Set of parsers and loggers to monitor metrics from a LoraWAN Packet Forwarder running inside a Docker container - GitHub - xoseperez/packet-forwarder-loggers: Set of parsers and loggers to monitor ...

Still having some issues with the `log2idb` logger but will fix them soon. Any feedback will be very welcome!

EDIT: by the way, you can run the parser itself inside a container but I have yet to test it with balena…

---

<div class="post-metadata">

**Author:** ![chet\_manly](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@chet\_manly](https://forums.balena.io/u/chet_manly)\
**Post date:** [August 8, 2022, 7:18pm UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/99 "2022-08-08T19:18:33Z")

</div>

@nmaas87 @barryjump et al. Thank you for this detailed thread. I’m in the market to build a Raspberry Pi-based LoRaWAN gateway with the following features:

1. SX1303
2. GPS/PPS for location and fine timestamping
3. LBT
4. Basics Station

I’ve only found a few SX1303 concentrators on the market and all of them have minimal documentation. The one I’m most interested in ATM is the RAK5146, hence my interest in this discussion.

Correct me if I’m wrong, but I gather that the [RAK2287/RAK5146 Pi HAT](https://store.rakwireless.com/products/rak2287-pi-hat) generally works with the RAK5146, but does not route the PPS to the RPi. That being said, I also see that RAK suggests their [mPCIe-to-USB adapter](https://store.rakwireless.com/products/mpcie-to-usb-board) for the RAK5146 USB version, but this of course has 0 documentation. I’m wondering if anyone knows whether this adapter will route everything necessary (e.g. PPS) to the RPi to satisfy the above features?

I’m also a little confused as to the general state of LoRaWAN support for SX1303 concentrators using the USB interface. I’ve seen many instances, in different repositories, of developers warning that the USB versions aren’t supported. Admittedly, these were a number of months ago. Would I be shooting myself in the foot in terms of supporting the above features if I get a USB concentrator? The reason I ask in this case is because the SPI version of the RAK5146 does not support LBT (why?).

Does anyone know of any reasonable Pi-based solution, that doesn’t require any hardware modification, that will satisfy the above features? I’m not partial to the RAK5146.

Thank you.

---

<div class="post-metadata">

**Author:** ![nmaas87](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmaas87/32/5570_2.png) [@nmaas87](https://forums.balena.io/u/nmaas87)\
**Post date:** [August 9, 2022, 6:36am UTC](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891/100 "2022-08-09T06:36:29Z")

</div>

> [@chet\_manly](#):
>
> the [RAK2287/RAK5146 Pi HAT](https://store.rakwireless.com/products/rak2287-pi-hat) generally works with the RAK5146, but does not route the PPS to the RPi

this is correct, the PPS is internally wired to the RAK5146. The Hat does connect the GPS module of the RAK5146 to the RPi via the GPIO connector and the RAK5146 via USB, but not the PPS signal of the GPS module.

> [@chet\_manly](#):
>
> RAK suggests their [mPCIe-to-USB adapter](https://store.rakwireless.com/products/mpcie-to-usb-board) for the RAK5146 USB

This is an absolute generic/off-the-shelf adapter, if you look at the backside of the module you will see that it even got an SIM card slot and only some minimal power circuitry. Meaning: You will only be able to use the RAK5146 itself, but not even the GPS itself is going to be connected to your RPi (and the PPS neither)

> [@chet\_manly](#):
>
> the SPI version of the RAK5146 does not support LBT (why?)

I cannot answer that question, maybe @xoseperez has more knowledge about that.

As for basic station, Xose made a good repo which should be working very well with the 5146 ( [GitHub - xoseperez/basicstation: Basics™ Station Packet Forward protocol using Docker](https://github.com/xoseperez/basicstation) ). I am still running it on the old udp-packet-forwarder as it suits my needs. Also its sadly my only RAK5146 and it is running in production right now, so I got no spare one to test stuff with.

Cheers

[Previous page](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891.md?page=4)

[Next page](https://forums.balena.io/t/lorawan-adventures-with-the-sx1303/346891.md?page=6)
