Private Network without internet

No sorry I didn’t succeeded in. But I doesn’t have time to do more research on the problem

Hello @Gauss_Moniotring, There is a simple solution you can implement on two Raspberry Pi devices. You can possibly reduce it to one.
Use this loraserver https://www.loraserver.io/.
Install the gatewaybrgide, loraserver and lora app server on a raspberry pi.
Install node-red on same raspberry Pi.
Configure Node-red to connect to the MQTT server running with the Lora Server setup and write the data to anything you want. MongoDB, Influx, or other storage.

WR if ‘simple’ any chance you can post a blog or how to showing steps…? :wink:

Yes, sure I can. Will post a blog and share the link here.

1 Like

@aizukanne Great. we wait for the step by step

It is possible to implement a private LORAWAN Network to connect Lora Nodes via gateways to a LoraWAN server and have the data collected from these nodes saved to a database or other storage medium. I will attempt to outline the steps required in summary. While this is meant to serve as a sort of guide, I will be referring to other articles which have detailed step by step instructions for implementing some of the functional units while adding a few pointers of my own. This article would guide the integration of the system as a whole.

In order to implement a private LoRaWAN Network, the following are required.

  1. LoRa Nodes (The Thing in the Internet of Things)

  2. At least one LoRaWAN Gateway/Packet Forwarder (An Access Point for the LoRa Nodes)

  3. LoRaWAN Network Server.
    I use the opensource LoRa Server project by @brocaar available here https://www.loraserver.io/ , and it provides the following:
    a. LoRa Gateway Bridge: A service which abstracts the packet-forwarder UDP protocol into JSON over MQTT.
    b. LoRa Server: A LoRaWAN Network Server, responsible for de-duplication and handling of received uplink frames received by the gateway(s), handling of the LoRaWAN mac-layer and scheduling of downlink data transmissions.
    c. LoRa App Server: A LoRaWAN application-server, responsible for the device “inventory” part of a LoRaWAN infrastructure, handling of join-request and the handling and encryption of application payloads.

  4. Node-RED: A simple programming tool for connecting hardware devices, APIs and online services.

The situation described already has LoRa Nodes and a Gateway so I will begin with the LoRaWAN Network Server. A Raspberry Pi or other single board computer running raspbian, armbian or other debian strain including Ubuntu, is required.

STEP 1. The LoRa Gateway Bridge requires an MQTT broker. Follow the detailed instructions here https://www.loraserver.io/lora-gateway-bridge/install/requirements/ to install Mosquitto MQTT broker.

STEP 2. Follow the detailed instructions here https://www.loraserver.io/lora-gateway-bridge/install/debian/ to install the LoRa Gateway Bridge and confirm it is running.

STEP 3. Install all requirements for the Lora Server. These include MQTT, REDIS Server and PostgreSQL. Detailed instructions are here. https://www.loraserver.io/loraserver/install/requirements/ . NOTE that you already installed an MQTT broker on the same machine so no need to install another.

STEP 4. Follow the detailed instructions here https://www.loraserver.io/loraserver/install/debian/ to install the LoRa Server and confirm it is running. You may want to change a few parameters but from my experience, default settings work perfectly if all components are installed on the same machine.

STEP 5. The requirements for the Lora App Server should be installed following the instructions here https://www.loraserver.io/lora-app-server/install/requirements/ . However, you will notice that all required services (MQTT, REDIS Server and PostgreSQL) have been installed in the previous steps so all you need do is to enable the pg_trgm (trigram) extension in postgreSQL as described in the link above.

STEP 6. Install the Lora App Server by following the instructions here https://www.loraserver.io/lora-app-server/install/debian/ . Basic configuration works out of the box where all LoRaWAN Server Components are installed on the same machine. Also remember to create self-signed certificates for the webserver and fill in the correct locations of these files in the configuration file. At this point, you should have a fully functional LoRaWAN Server. To confirm this, login to the LoRa App Server WEB UI by navigating to https://:8080/. Username is admin and Password is admin. Remember to change them.

STEP 7. When logged in, create a network server (basically enter the details of your Lora server installed in STEP 4), add an organization, create device and service profiles and add your gateway(s). I recommend creating at least two device profiles, one for Activation by Personalization (ABP) and Over the Air Activation (OTAA). Please note that the LoRa server IP address on your gateway software (identified as TTN SERVER) on most single channel gateways / packet forwarder configurations should be set to the IP address of this server. After this configuration, do not power up your gateway until they have been created in the Lora App Server. If they are powered on before creation in the app server and are automatically detected by the Lora Server, you will see errors when you try to add them later on the Lora App Server.

STEP 8. Create an application by adding the details of the application under an organization.

STEP 9. Create each of your nodes as devices under the application you just created. This ensures the data collected from these nodes are published under the application. The devices will be configured based on the selected device profiles which you should have created previously. The server can provide both ABP and OTAA authentication methods .

STEP 10. Install Node-Red. Node-Red is usually preinstalled in Raspbian. However it may be outdated and it is recommended to update it. Configure Node-RED to start on boot using the command

sudo systemctl enable nodered.service

If running debian/ubuntu, follow the commands here https://nodered.org/docs/getting-started/installation to install. Also remember to configure node-red to autostart on boot.

STEP 11. With node-red installed, connect to node-red Web UI by navigating to http://:1880/. Once logged in, select and drag the “mqtt in” node from inputs on the left column, into your flow. Configure it to connect to your MQTT broker and subscribe to the application topic as described here https://www.loraserver.io/lora-app-server/integrate/data/ . The first application is usually published as 1. If unsure, first subscribe to application/# and connect the output of “mqtt in” to a “json” node and then to a “debug” node to see the output in the debug tab. If the application ID is confirmed as 1 (for example), subscribe to application/1/node/+/rx to receive all data from all nodes configured in the application. At this point, details of any data transmitted by your nodes should appear in the debug tab. This is the full message payload published by the LoRa App Server, formatted as json and would look like this.

{"applicationID":"1","applicationName":"smart-nodes","deviceName":"alpha-monitor","devEUI":"1234567887654321","rxInfo":[{"mac":"30aea4ffff5614e8","rssi":-86,"loRaSNR":9,"name":"esp32-demo-gateway","latitude":11.123456,"longitude":12.123456,"altitude":453}],"txInfo":{"frequency":868099975,"dataRate":{"modulation":"LORA","bandwidth":125,"spreadFactor":7},"adr":true,"codeRate":"4/5"},"fCnt":784,"fPort":1,"data":"RIwPQWWe7kCFAAMAYgAzUH1PAQAB"}

The information from your nodes is stored in the object (“data”:“RIwPQWWe7kCFAAMAYgAzUH1PAQAB”) and is Base64 encoded.

STEP 12. Add a javascript function node to the flow after the json node. The json node converts json formatted strings to javascript objects. Open the javascript function node and enter the following to convert the data from Base64.

//Decode data from transmission into variables var newMsg = { payload: msg.payload.length }; newMsg.payload = new Buffer(msg.payload.data, 'base64'); return newMsg;

Remove the “debug” node previously connected to the output of the "json: node and connect it to the output of the “function” node. Deploy the changes and subsequent data sent by your nodes will be displayed decoded in the debug tab.

STEP 13. To store the data, you can chose to write them to a file or save to a wide choice of databases. To write to a file, drag the “file” output node from the storage section of the list of nodes on the left column to the flow. Connect the file node to the output of the “function” node. Configure the name of the file you want the data saved to and select the options as needed. Ensure you select “Append to file as the action”. Deploy your changes.

At this point all the data received from your nodes will be saved to a file and you can download the file at any time. If you are adventurous, you can configure the function node to format your data further before storing to file.

I hope this helps.

25 Likes

please how do i run this data capture on the raspberry pi

1 Like

Can you be a bit more explicit?

hello arinze. Now I have the system working. my nodes now send data to the Rak 831. the gateway now gets the data from four nodes at fixed frequencies. and i can now trap that with my nodered server. my chanllenge is that i want to involve control commands from the gateway back to the nodes. like i want to incoporate an LED and a Servo on each node. so i can turn on and off the LED and also control the direction of the servo. is that any way i can get help on this?

Hello Cherechi,

It is possible to schedule and send messages to devices. You can enqueue messages which will be sent to the class A devices in the RX window after they transmit. Take a look at the link below for details. https://www.chirpstack.io/application-server/integrate/sending-receiving/

Thanks,
I will have a look at it now.

@cherechi Are you connecting your gateway to TTN or any other LoRaWAN service provider? And if not, do you have multiple gateways?

Hey Aizukanne,
Thanks so much for this very explanatory steps. I have carried out this process to the latter and my system is working find. but I am stuck now because my nodes now send data at various frequencies. but I want each node to send data at a fixed frequency and also recieve any form of commands at the same frequency. this will be just for testing purposes. I hope i can get a solution to this.
thanks in advance

Hi,

That would be redefining the standards. LoRa protocol specifes that nodes alternate transmissions across different select frequencies. It allows greater spectrum utilization.

As for sending data to remotes, it is scheduled in a window after each transmission. So the node will receive data on the last frequency he transmitted or a specified channel.

However, you can limit your nodes to the three mandatory frequencies but they will use any one of the three for each transmission.

Regards

Arinze

1 Like

LoRaWAN specifies that, “LoRa” does not.

Private networks are however off topic here, as this is the TTN forum.

Amazing description! Congrats.
It fits my solution i was looking all around the internet.
Do you recommend going DIY on the gateway? or any other prebuilt one that runs linux? I am open to any option really

Private networks are off topic on the TTN forum.

This post is quite old but let me ask this again because there may be better answers after 4 years. I want to use Lorawan for Marine Vessel Monitoring. My country has coastal areas far from an internet connection. If the Lora gateway is too far from an internet connection (3G), is there a way to somehow extend the Lora gateway by connecting it to another? For example, Lora gateway 1 is connected to 3G, Lora gateway 2 is in the coastal area which receives the boats data but is far from an internet connection so it must connect to Lora gateway 1.

The options to link gateways have not changed, still not possible.

Is the ‘Lora Gateway 1’ a TTN gateway ?

What would be the backhaul between Gateway 1 and Gateway 2 ?

LoRa itself seems very unsuitable, since it would run into legal duty cycle issues if it was forwarding more that a handful of packets from the remote nodes.

LoRaWAN has very recently had a relay mode incorporated into the standard, but that seems to be based on relays for individual nodes, and I wonder if even that has yet been implemented on TTN.