How do I setup a LoRa gateway for multiple nodes?

Currently, I am working with the SX1278 module and ESP32. I was able to establish Point 2 Point communication between 2 ESP32 modules (with connected LoRa modules) by using the LoRa library developed by Sandeep Mistry. Now, I wish to take my project a step further and would like to setup one of the ESP32 devices as a gateway which can receive data from 3-5 nodes while simultaneously pushing the data to AWS. I would rather make my own gateway than opt for an expensive pre-made one, as I would have to develop the code for it anyways. Is there any way I can work this out using my current setup? If so, which library should I use and is it compulsory to introduce the LoRaWAN protocols?

Just add a byte to the payload the sensor is sending that represents the sensor 'number'.

srnet:
Just add a byte to the payload the sensor is sending that represents the sensor ‘number’.

How exactly am I supposed to do this? As of now, I am converting my data to JSON and sending this by means of the LoRa library (by Sandeep Mistry) as shown below.

  • LoRa.beginPacket();*
  • LoRa.print(jsonBuffer);*
  • LoRa.endPacket();*
    I am using the LoRa.setSyncWord() function to identify my device. I don’t have a lot of experience in this field and am unsure whether I can use the same library and process for the Many to One (Multiple nodes to a Gateway) setup. Should I just use different Sync Words for the different node devices and add an if statement to check for all the devices on my gateway?

I dont use that LoRa library myself, I wrote my own that makes stuffing bytes and variables into payloads a fair bit easier, it has a fully worked example of a sensor transmitter and receiver where the sensor identifies itself by a source address which the receiver uses. See the link below;

Do not (repeat do not) use invented syncwords to identify nodes or private networks, you can really mess up LoRa communications. Stick to the two known to work syncwords, 0x12 and 0x34.

raghaviyengar:
I would rather make my own gateway than opt for an expensive pre-made one, as I would have to develop the code for it anyways. Is there any way I can work this out using my current setup? If so, which library should I use and is it compulsory to introduce the LoRaWAN protocols?

I have a simple LoRa gateway that receives data from several nodes and uploads (using MQTT) to Node-Red and this stores the data in an Influx database. I'm using the same LoRa libraries your using and this has worked well for about 2 years.
The nodes are sleeping most of the time (battery powered) so wake up, take readings and send them. They do not receive any data from the gateway.

Riva:
I have a simple LoRa gateway that receives data from several nodes and uploads (using MQTT) to Node-Red and this stores the data in an Influx database. I'm using the same LoRa libraries your using and this has worked well for about 2 years.
The nodes are sleeping most of the time (battery powered) so wake up, take readings and send them. They do not receive any data from the gateway.

Okay, could you help me understand how it works? Have you programmed your nodes to wake up at particular times and transmit data while the other nodes are asleep? Also how frequently do you draw data? How do you identify your devices? Also, if you don't mind would share a sample code to your Gateway?

Attached is the whole gateway code I use.
The nodes wake up every 8 seconds using AVR watchdog timer and every 75 wakes (10 minutes) takes readings that are added to a rolling average. Then every 225 wakes (30 minutes) the values are transmitted to the gateway.
The data is transmitted as JSON and includes the device name (L2 in the example below) so the node knows where the data came from.

/*
  AdaFruit Feather sketch to collect rolling average readings from a BME280
  and send them to a personal LoRa gateway as a JSON string like...
  {\"D\":\"L2\",\"N\":0,\"T\":26.13,\"P\":1020.00,\"A\":-56.06,\"H\":46.82,\"L\":496.00,\"V\":3.73}
  D = Device (string)
  N = Packet number that increments every time results sent (uint8_t)
  T = Temperature (float)
  P = Pressure (float)
  A = Altitude (float)
  H = Humidity (float)
  L = MAX44009 reading (float)
  V = Battery voltage (float)
*/

OLED_LoRa_Gateway8.ino (10.6 KB)

Settings.h (362 Bytes)

Riva:
Attached is the whole gateway code I use.
The nodes wake up every 8 seconds using AVR watchdog timer and every 75 wakes (10 minutes) takes readings that are added to a rolling average. Then every 225 wakes (30 minutes) the values are transmitted to the gateway.
The data is transmitted as JSON and includes the device name (L2 in the example below) so the node knows where the data came from.

/*

AdaFruit Feather sketch to collect rolling average readings from a BME280
 and send them to a personal LoRa gateway as a JSON string like...
 {"D":"L2","N":0,"T":26.13,"P":1020.00,"A":-56.06,"H":46.82,"L":496.00,"V":3.73}
 D = Device (string)
 N = Packet number that increments every time results sent (uint8_t)
 T = Temperature (float)
 P = Pressure (float)
 A = Altitude (float)
 H = Humidity (float)
 L = MAX44009 reading (float)
 V = Battery voltage (float)
*/

Thanks a lot for this. I'll try to modify this according to my application. This is quite elaborate but the only thing I'm skeptical about is the collision of data since we aren't implementing LoRaWAN. Will it be a problem?

raghaviyengar:
Thanks a lot for this. I'll try to modify this according to my application. This is quite elaborate but the only thing I'm skeptical about is the collision of data since we aren't implementing LoRaWAN. Will it be a problem?

As I only have a few sensors and they only send data every 30 minutes then the chance of data collision is low but I still sometimes miss data from a sensor. Not sure if this is due to collision with my other sensors or interference with other equipment out of my control but to reduce the chance of lost data each node transmits the same data three times with a small random delay between each send to reduce the chance of collision.
The image below that shows packet number should have smooth ramps if all data is received but you can see the odd small step where a reading was missed. All I do though is to use the last reading if no data is received and the second image shows the graphs from the sensors do not do leery things when packets are lost.
I don't have spare LoRa modules to test two way comms but looking at the examples with the Lora library you should be able to construct a gateway that replies to nodes that data was received okay.

Clipboard-2.jpg

Clipboard-2.jpg

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.