Storing Data locally in Raspberry-Pi with Lorawan Gateway

Hi @xoseperez ,

Sorry, for the trouble again!

With Balena it works perfectly. But I want to install things stack withou balena, So i referred the doucment [Configuration | The Things Stack for LoRaWAN], I successfully connected with the IP address of my raspberry-pi. But the problem is, When, I enter the user name and password, It is reloading the same page, neither it is showing wrong credentials nor I can open the console. I can see the client error in linux terminal, below I am attaching the photo of the same. Can you please help me with this?

Thanks in Advance!!!

Yes, there are some extra few steps to make it work. That’s why I put together a new docker image as a wrap up for the TTS official image that includes configuration and certificate auto-generation. You can find it here: GitHub - xoseperez/the-things-stack-docker: The Things Stack LoRaWAN Network Server (Open Source Edition) on a Raspberry Pi using docker . It is the same image that uses the balena project you tested before. In the end, Balena is a device and fleet manager that runs services as docker containers. You can still run them without Balena…
Make sure, again, to define the TTS_DOMAIN variable to the right IP.

@pjariwala On a separate note, try this on a new SD card with fresh RPi OS.

Aim: To have your own Gateway Packet Forwarder, Chirpstack LoRa Network Server (LNS) and Application Server including MQTT broker , data storage native on Raspberry Pi+RAK5146 HAT.

  1. Follow the instructions on the RAK link - Quick Start Guide for Raspberry Pi and RAK LPWAN Concentrators | RAKwireless Documentation Center

  2. Execute “gateway-config” on the commandline and select Chirpstack instead of TTN and also select 127.0.0.1 as LNS Server. (i.e. 127.0.0.1 on global.conf)

  3. Add your devices on the application server RPI-IPADDRESS:8080, Join mode ABP or OTAA. Add decode codec suitable for the devices you are using. Make sure you are getting packets on the Device Data tab.

  4. Configure Node-RED MQTT node to spit out human readable/JSON format of incoming DATA component. Configure Node-RED file nodes to store data locally. Rakstar Enjoy :checkered_flag:

In this way you need not go out of Raspberry Pi (to external LoRaWAN Servers for example). All the tasks that you mentioned such as receiving LoRaWAN packets in the concentrator, forwarding it to localhost (127.0.0.1) LNS, decoding DATA packets on Node-RED using local MQTT broker, storing data in csv files locally using Node-RED file nodes can be done on the Raspberri Pi itself.

Thanks to RAKwireless, Chirstack (Brocaar), Node-RED( Nick O’Leary), The Things Network, Mobilefish, Steve Cope, Anh Quan Tong and many more YouTubers for their contribution on the LoRa and LoRaWAN platform and IoT.

Hi @xoseperez ,

I tried your version also, but the same error is coming which I mentioned before, this time I had define TTS_DOmain to Rspberry pi IP address. In addition to this, one more error is coming, which I have attached below in the picture. Can you, please help me?

Thanks in Advance!!!

Hi @Cloudmiracle

Thanks for the feedback!.

I have one question, So, first I have to send the lora packets to the Chirpstack public server and, then I have to install Node-Red, into the Raspberry pi and then I will send data to infulx Db and store it in Raspberry pi, Is it like that, or I am understanding it in a wrong way?

Thyanks in Advance!!!

@pjariwala

I think you forgot to attach the picture…

Hi @xoseperez ,

I am so sorry for that.

Thanks!!!

Well, have you defined any LNS or CUPS configuration in your docker-compose.yml file?
I suggest you to read the section in the TTS docker image that talks about pairing it with a basicstation service: GitHub - xoseperez/the-things-stack-docker: The Things Stack LoRaWAN Network Server (Open Source Edition) on a Raspberry Pi using docker and GitHub - xoseperez/the-things-stack-docker: The Things Stack LoRaWAN Network Server (Open Source Edition) on a Raspberry Pi using docker .
Hints:

  • Set the TC_TRUST and TC_KEY in your basicstation service once you have your gateway created in TTS
  • Use TLS_SNI=false in your basicstation service to avoid certificate checking (will fail agains IP-signed certificates).

Hi @xoseperez ,

I am facing problem in TC_TRUST. What exactly I have put Value in TC_TRUST variable? Can you help me with that?

Thanks in Advance!!!

The TC_TRUST is the server certificate created by the Ths Things Stack instace on first boot (or when some of the important variables change, like TTS_DOMAIN). You can fetch that certificate using the get_certificate command from within the container like stated here: GitHub - xoseperez/the-things-stack-docker: The Things Stack LoRaWAN Network Server (Open Source Edition) on a Raspberry Pi using docker

Hi @xoseperez,

As you suggested I have run the Command ( ```
docker exec stack ./get_certificate.sh


 basicstation:
    image: xoseperez/basicstation:latest
    container_name: basicstation
    restart: unless-stopped
    privileged: true
    network_mode: host
    labels:
        io.balena.features.kernel-modules: '1'
        io.balena.features.firmware: '1'
        io.balena.features.dbus: '1'
        io.balena.features.supervisor-api: '1'
        io.balena.features.balena-api: '1'
    environment:
        MODEL: RAK5146
        TC_KEY: NNSXS.XS2ECSUDA4D3QS2G2AFADNQKT6VAJED5USINVRY.PP3ICMNOYOBFRT7AXRBZQ5KJQGPYISRBEKEGQGBX44DC6NUDGXBQ
        TC_TRUST: -----BEGIN CERTIFICATE-----
                            MIIDvDCCAqSgAwIBAgIUCcpBuBXyY/it8GmWNq5nQ+Bb/WwwDQYJK                                                                                                    oZIhvcNAQELBQAwZDELMAkGA1UEBhMCRVMxEjAQBgNVBAgTCUNhdGFsdW55YTESMBAGA1 
UEBxMJQmFyY                                                                                                             2Vsb25hMRYwFAYDVQQKEw1UVE4gQ2F0YWx1bnlhMRUwEwYDVQQDEwwxOTIuMTY4LjAuODAwHhcNMjMwN                                                                                                             jE1MTMxOTAwWhcNMjgwNjEzMTMxOTAwWjBkMQswCQYDVQQGEwJFUzESMBAGA1UECBMJQ2F0YWx1bnlhM                                                                                                             RIwEAYDVQQHEwlCYXJjZWxvbmExFjAUBgNVBAoTDVRUTiBDYXRhbHVueWExFTATBgNVBAMTDDE5Mi4xN                                                                                                             jguMC44MDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMn0osPehGlxqnOr+ToSVpalBe859                                                                                                             lrzno4Adw8ImcSGO262u8r0wr+wOUq4B5M3HIcZELrPmDx3pbN2C42MiS40dnF4tPGMsbRcYWUXT5LCq                                                                                                             zt7PwBUS5h5hl/2jUnWMFtnHxGX1QeFy3dmkrDpwN94tqDBcyEL/zTwxRHPnlOEigSgvnJxjVjH02rBj                                                                                                             jUVHPggV63L7bK4z9Tq9w+Kf7FPpDmpyXEdKG/o/J4J3aPCynGCg9YbUrO7raSSwWfkYnEqy/YTaxga5                                                                                                             bw1FWLdwIr9iJqYW+7Ua+SNwQmr7rsEhfFy4MBE9bBpOuk5WhZzHHIoSC68F9VgQvf8gW6tp5MCAwEAA                                                                                                             aNmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQIwHQYDVR0OBBYEFC45r7XJ7c9I5                                                                                                             sTchiMfD4iNnQWIMB8GA1UdIwQYMBaAFC45r7XJ7c9I5sTchiMfD4iNnQWIMA0GCSqGSIb3DQEBCwUAA                                                                                                             4IBAQB9FvEvWP5BGf8jWByNtFqQwNkf2GFEH65kmJtdVyG8VyQgCDTikAAbc0mmlDWbtakC07bmKsdME                                                                                                             zmM+mc8cteWLBp74IvRxH5ECjP1zLoXiIm2SkSNaSnNdR8fwtqxFVd9huK2DhTbOiBlW1Mh5lqMJXKXA                                                                                                             jl/IjxOM3QkvTmLzhY9zJWV4980ngxfcbGFWHYoJNNAyK5+YNSzS+DtiMsURRQu/0gUkuBH7xxtfO/7z                                                                                                             f7Jk6MaS94yByZo57jxPMFGk9iaEBBi3+AKfvqztnpRqEUJXrTk4YKymTng0kY2jvrf53H7xAVEVJt9k                                                                                                             
          P67Gyh6LjVCBLrFB3lj8wIHAqLh
           -----END CERTIFICATE-----
        TLS_SNI: "false"

But then also, I am facing the same problem, Can you please help me?
Sorry for the trouble!!

Thanks in advance!!

You are trying to connect the basicstation service to the local network server, so you have to set the TC_URI to the local IP, something like:

TC_URI: "wss://192.168.1.150:8887"

Make sure you mount the 8887 port in your TTS service.

Also, all text variables should be quoted with double quotes.

Hi @xoseperez ,

Thank you so much for the help!

Now, it is connecting to TTN locally.

Great! Congratulations :grinning:

Hi @xoseperez ,

Thank you so much!!

Sorry, for one more doubt, How can I use Infux Db, because, In Node-Red, I have created a flow, where I used MQTT IN Node and Now I want to store data in Influx Db, but when I am writing the command it showin error. So, how can I use that?

Thanks in advance!!

The easiest way is to use the influxdb node for Node-RED: node-red-contrib-influxdb (node) - Node-RED. You have a few examples on how to use it in the node documentation from within Node-RED

Hi @xoseperez ,

I am trying to install influx db and node-red on raspberry-pi [Because I don’t want to use the from balena], but when I start the node-red it showing error that, node-red is already running. I had commented all the lines of influx db and node-red, in docker-compose.yml, but then also it is showing me error. So, How can, I stope both influx db and node red completely, which is there in your docker.
Can you please help me with this?

Thanks in advance!!!

Well, this goes beyond the scope of what we do at RAK :slight_smile:

First you should find out the running instance, if it’s a docker container it will show up with docker ps -a, then you can kill it and remove it. You can also remove it if you brought it up with docker-compose by typing docker compose down while at the folder with the docker-compose.yml file.

Hi @xoseperez ,

As you guided for downloading Things Stack Locally in Raspberry pi. It was working properly. But, Suddelny Now Gateway is not connecting. Below, I am attaching the error, Can you please help me this?

Thanks in advance!

Maybe the gateway changed the IP?
It’s recommended to have a fixed IP or, even better, a fixed server name (i.e. lns.myhome.com). The certificates in the TTS service are bundled with the domain name (TTS_DOMAIN variable).