Regarding Raspberry Pi Pico, GPS NEO-6M and LoRa SX1278 Module and DLOS8N - Outdoor LoRaWAN Gateway

In India.
I make a Transmitter and Receiver device using Raspbery pi pico, GPS NEO-6M Module and LoRa SX1278 Module at Transmitter end and Raspberry pi pico, LoRa SX1278 Module at the receiver end. In this device i am sending my GPS Cordinate from Transmitter end and receive it at the receiver end.
Transmitter end code are:
#include <SPI.h>
#include <LoRa.h>
#include <TinyGPS++.h>

#define LORA_SCK 18
#define LORA_MISO 16
#define LORA_MOSI 19
#define LORA_CS 8
#define LORA_RST 9
#define LORA_DIO0 7

#define LED_PIN 25
#define BUZZER_PIN 17 // (Connect to GPIO 17 of Raspberry Pi Pico) Replace 17 with the GPIO pin number your buzzer is connected to

#define GPS_RX 1 // Connect GPS TX pin to Raspberry Pi Pico pin 1 (UART1_RX)
#define GPS_TX 0 // Connect GPS RX pin to Raspberry Pi Pico pin 0 (UART1_TX)

#define TRANSMISSION_INTERVAL 60 // Interval between transmissions in milliseconds (e.g., 1 seconds)

TinyGPSPlus gps;

void setup()
{
Serial.begin(115200);
Serial1.begin(9600); // Initialize hardware UART1 for GPS

LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
if (!LoRa.begin(433E6))
{
Serial.println("LoRa init failed. Check your connections.");
while (true);
}

Serial.println("LoRa init succeeded.");

pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT); // Set the buzzer pin as output
}

void loop()
{
static unsigned long previousTransmission = 0;

while (Serial1.available() > 0)
{
if (gps.encode(Serial1.read()))
{
if (gps.location.isValid())
{
float latitude = gps.location.lat();
float longitude = gps.location.lng();
Serial.println("GPS Running...");
sendLocation(latitude, longitude);

    digitalWrite(LED_PIN, HIGH); // Turn on LED
    digitalWrite(BUZZER_PIN, HIGH); // Turn on buzzer
    delay(1000); // Indicate transmission
    digitalWrite(LED_PIN, LOW); // Turn off LED
    digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
    delay(1000); 
    
    previousTransmission = millis(); // Update last transmission time
  }
  else
  {
   Serial.println("GPS NOT START");
   delay(1000);
   digitalWrite(LED_PIN, HIGH); // Turn on LED when GPS Not Start but Device Start
  }
}

}

// Check if it's time to transmit again
if (millis() - previousTransmission >= TRANSMISSION_INTERVAL)
{
// Transmit periodic status message
//sendStatus("I'm alive!");
previousTransmission = millis(); // Update last transmission time
}
}

void sendLocation(float latitude, float longitude)
{
String message = String(latitude, 6) + "," + String(longitude, 6);
Serial.print("Sending GPS Signal: ");
Serial.println(message);
LoRa.beginPacket();
LoRa.print(message);
LoRa.endPacket();
}

void sendStatus(const char* statusMessage)
{
Serial.print("Sending status: ");
Serial.println(statusMessage);
LoRa.beginPacket();
LoRa.print(statusMessage);
LoRa.endPacket();
}

Receiver end code are:
#include <SPI.h>
#include <LoRa.h>

// Pin Definitions
const int LORA_SCK = 18;
const int LORA_MISO = 16;
const int LORA_MOSI = 19;
const int LORA_CS = 8;
const int LORA_RST = 9;
const int LORA_DIO0 = 7;
const int LED_PIN = 25;
const int BUZZER_PIN = 17;

void setupLoRa() {
Serial.begin(115200);
LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
if (!LoRa.begin(525E6)) {
Serial.println("LoRa init failed. Check your connections.");
while (true);
}
Serial.println("LoRa init succeeded.");
}

void setup() {
setupLoRa();
pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
}

void indicateTransmission() {
digitalWrite(LED_PIN, HIGH); // Turn on LED
digitalWrite(BUZZER_PIN, HIGH); // Turn on buzzer
delay(1000); // Indicate transmission
digitalWrite(LED_PIN, LOW); // Turn off LED
digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
delay(1000);
}

void receiveAndIndicate() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
Serial.println("GPS Running...");
Serial.print("Received GPS Signal: ");
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
Serial.print(" with RSSI ");
Serial.println(LoRa.packetRssi());
indicateTransmission();
} else {
digitalWrite(LED_PIN, HIGH); // Turn on LED when GPS Not Start but Device Start
}
}

void loop() {
receiveAndIndicate();
}

I am using Transmitter and Receiver Device both but communication between them is not going to long range.
After that i ordered "DLOS8N - Outdoor LoRaWAN Gateway" to increase my communication range.
Now, tell me in brief with code to use my LoRaWAN Gateway as middle point which receive the GPS coordinate from my Transmitter device and then send it to my Receiver device.

Its difficult to read your code, you need to use the CODE tag to format it.

Looks like you are using the LoRa device with the libraries default settings, which are not long range settings.

The transmitter and receiver are using different frequencies too, so there should be no communication at all.

LoRa and LoRaWAN are different, a LoRaWAN Gateway is not a LoRa packet repeater, you would not use it to repeat or forward packets between a LoRa transmitter and receiver. .

Your GPS location transmitter is sending in peer to peer LoRa mode, and the packets will not be recognized by the LoRaWAN gateway.

Transmitter end code are:

#include <SPI.h>
#include <LoRa.h>
#include <TinyGPS++.h>

#define LORA_SCK 18
#define LORA_MISO 16
#define LORA_MOSI 19
#define LORA_CS 8
#define LORA_RST 9
#define LORA_DIO0 7

#define LED_PIN 25
#define BUZZER_PIN 17 // (Connect to GPIO 17 of Raspberry Pi Pico) Replace 17 with the GPIO pin number your buzzer is connected to

#define GPS_RX 1 // Connect GPS TX pin to Raspberry Pi Pico pin 1 (UART1_RX)
#define GPS_TX 0 // Connect GPS RX pin to Raspberry Pi Pico pin 0 (UART1_TX)

#define TRANSMISSION_INTERVAL 60 // Interval between transmissions in milliseconds (e.g., 1 seconds)

TinyGPSPlus gps;

void setup() 
{
  Serial.begin(115200);
  Serial1.begin(9600); // Initialize hardware UART1 for GPS
  
  LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
  if (!LoRa.begin(433E6)) 
  {
    Serial.println("LoRa init failed. Check your connections.");
    while (true);
  }
  
  Serial.println("LoRa init succeeded.");
  
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT); // Set the buzzer pin as output
}

void loop() 
{
  static unsigned long previousTransmission = 0;
  
  while (Serial1.available() > 0) 
  {
    if (gps.encode(Serial1.read())) 
    {
      if (gps.location.isValid()) 
      {
        float latitude = gps.location.lat();
        float longitude = gps.location.lng();
        Serial.println("GPS Running...");
        sendLocation(latitude, longitude);
      
        digitalWrite(LED_PIN, HIGH); // Turn on LED
        digitalWrite(BUZZER_PIN, HIGH); // Turn on buzzer
        delay(1000); // Indicate transmission
        digitalWrite(LED_PIN, LOW); // Turn off LED
        digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
        delay(1000); 
        
        previousTransmission = millis(); // Update last transmission time
      }
      else
      {
       Serial.println("GPS NOT START");
       delay(1000);
       digitalWrite(LED_PIN, HIGH); // Turn on LED when GPS Not Start but Device Start
      }
    }
  }
  
  // Check if it's time to transmit again
  if (millis() - previousTransmission >= TRANSMISSION_INTERVAL) 
  {
    // Transmit periodic status message
    //sendStatus("I'm alive!");
    previousTransmission = millis(); // Update last transmission time
  }
}

void sendLocation(float latitude, float longitude) 
{
  String message = String(latitude, 6) + "," + String(longitude, 6);
  Serial.print("Sending GPS Signal: ");
  Serial.println(message);
  LoRa.beginPacket();
  LoRa.print(message);
  LoRa.endPacket();
}

void sendStatus(const char* statusMessage)
{
  Serial.print("Sending status: ");
  Serial.println(statusMessage);
  LoRa.beginPacket();
  LoRa.print(statusMessage);
  LoRa.endPacket();
}

Receiver end code are:

#include <SPI.h>
#include <LoRa.h>

// Pin Definitions
const int LORA_SCK = 18;
const int LORA_MISO = 16;
const int LORA_MOSI = 19;
const int LORA_CS = 8;
const int LORA_RST = 9;
const int LORA_DIO0 = 7;
const int LED_PIN = 25;
const int BUZZER_PIN = 17;

void setupLoRa() {
  Serial.begin(115200);
  LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
  if (!LoRa.begin(433E6)) {
    Serial.println("LoRa init failed. Check your connections.");
    while (true);
  }
  Serial.println("LoRa init succeeded.");
}

void setup() {
  setupLoRa();
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
}

void indicateTransmission() {
  digitalWrite(LED_PIN, HIGH); // Turn on LED
  digitalWrite(BUZZER_PIN, HIGH); // Turn on buzzer
  delay(1000); // Indicate transmission
  digitalWrite(LED_PIN, LOW); // Turn off LED
  digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
  delay(1000);
}

void receiveAndIndicate() {
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    Serial.println("GPS Running...");
    Serial.print("Received GPS Signal: ");
    while (LoRa.available()) {
      Serial.print((char)LoRa.read());
    }
    Serial.print(" with RSSI ");
    Serial.println(LoRa.packetRssi());
    indicateTransmission();
  } else {
    digitalWrite(LED_PIN, HIGH); // Turn on LED when GPS Not Start but Device Start
  }
}

void loop() {
  receiveAndIndicate();
}

Is any way to use my device with these code to communicate with my Gateway?

Good, now the code can be read.

Probably best to describe what the project actually is and in particular why you want to 'extend' the range.

Incidentally, the LoRaWAN Gateway is for the 868Mhz or 915Mhz bands so would not handle the packets from your 433Mhz nodes even if you set them up as LoRaWAN nodes.

I am created and using Transmitter and Receiver Device both but communication between them is not going to long range (not more than 300-400 meter).

Then, after that i ordered "DLOS8N - Outdoor LoRaWAN Gateway" to increase my communication range for Tracking my Transmitter Device.

The code i provided is based to normal communication (without using Gateway) and both the code are working properly but commincation range in not so long. As per LoRa SX1278 Module it shouls be communicate upto 10 Km.

Distance depends on the device settings and environment.

The range of a LoRa device could be 500m maximum in an urban area, but the same devices and settings could achieve 800km+ if there is clear line of sight between transmitter and receiver.

Probably best to describe what the project actually is and in particular why you want to 'extend' the range.

I am working in a Company, where Electronics department just start and we are 3-electronics engineer, we all have diferent project assign.
I am Suresh Kumar and In this company the project assigned to me is that i have to make a Transmitter Device and Receiver Device to communicate wireless based on LoRa SX1278 Module. In addition the other components provided to me is Raspberry Pi Pico and GPS NEO-6M Module. As told me that the LoRa SX1278 Module can communicate upto 10 Km+.
But when i made my project based on above programing, then i test it in open area also in conjusted area but the communication between both the device is not going more that 200m to 300m.

Then after that My Project manager told me to ordered gateway then i ordered DLOS8N LORaWAN Gateway.
Now i have issue that, I can't add my Transmitter Device to Gateway.
Tell me howan this possible ?

Suggest you go back to basics and work out why LoRa reception in an 'open' area is as low as 200m.

The LoRaWAN Gateway will not process packets from the plain LoRa node that you are using.

LoRaWAN Gateways process packets from LoRaWAN nodes.

Give me any suggestion regarding why LoRa reception in an 'open' area is as low as 200m.

Modules or antenna are faulty.

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