arduino-LoRa icon indicating copy to clipboard operation
arduino-LoRa copied to clipboard

Poor LoRa transmission Range

Open mohelshafei1950 opened this issue 2 years ago • 1 comments

Hi I am using 2 Arduino MKRWAN 1310 boards with 2 GSM Antennas (I guess 2dBi) and the transmission range doesn't exceed 60m using SF12 and 30m using SF7 in an open football court (direct LOS), Although SF7 should detect up to 2km and SF12 should detect up to 14km . Does anyone know how to increase the transmission range and how to use ADR communication protocol if assigning LoRa.setSpreadingFactor() isn't efficient?. The code that I am using is below and if anyone can give me any suggestion either in the code or hardware I would be grateful. Thank you in advance.

// Sender #include <SPI.h> #include <LoRa.h> #include <Arduino_MKRGPS.h> #include <MKRWAN.h>

float latitude; float longitude; float altitude; float speed; float satellites; int counter = 1 ;

byte localAddress = 0xBB; //address of this device byte destination = 0xFF; //where we are sending data to LoRaModem modem(Serial1); void setup() {

// initialize serial communications and wait for port to open: Serial.begin(9600); while (!Serial) if (!LoRa.begin(868E6)) { Serial.println("Starting LoRa failed!"); while (1); }

if (!GPS.begin()) { Serial.println("Failed to initialize GPS!"); while (1); } // modem.setADR(true); LoRa.setSpreadingFactor(12); LoRa.setSignalBandwidth(125E3); LoRa.setCodingRate4(5);

}

void loop() { // check if there is new GPS data available if (GPS.available()) {

// read GPS values
latitude   = GPS.latitude();
longitude  = GPS.longitude();
altitude   = GPS.altitude();
speed      = GPS.speed();
satellites = GPS.satellites();

// print GPS values
printValues();

// Create and send LoRa packet
LoRa_send();

} delay(1); }

//function to send information over LoRa network void LoRa_send() {

LoRa.beginPacket();//creates a LoRa packet
LoRa.write(destination);  //destination address
LoRa.print(" LAT: ");
LoRa.print(latitude);
LoRa.print(" LONG: ");
LoRa.print(longitude);
LoRa.endPacket(); //sends the LoRa packet
delay(10000); //a 10 second delay to limit the amount of packets sent

}

//function that prints all readings in the Serial Monitor void printValues() {

Serial.print("Location: "); Serial.print(latitude, 7); Serial.print(", "); Serial.println(longitude, 7); Serial.print("Altitude: "); Serial.print(altitude); Serial.println("m"); Serial.print("Ground speed: "); Serial.print(speed); Serial.println(" km/h"); Serial.print("Number of satellites: "); Serial.println(satellites); }

// Receiver #include <SPI.h> #include <LoRa.h> #include <MKRWAN.h> String message;

byte localAddress = 0xFF;
LoRaModem modem(Serial1);

void setup() { Serial.begin(9600); while (!Serial); Serial.println("LoRa GPS data receiver"); if (!LoRa.begin(868E6)) { Serial.println("Starting LoRa failed!"); while (1); } //modem.setADR(true); LoRa.setSpreadingFactor(12); LoRa.setSignalBandwidth(125E3); LoRa.setCodingRate4(5); delay(1000);

} void loop() {

onReceive(LoRa.parsePacket()); }

void onReceive(int packetSize) { if (packetSize == 0) return; // if there's no packet, return

int recipient = LoRa.read(); String incoming = ""; // Serial.println(LoRa.available()); while (LoRa.available()) { incoming += (char)LoRa.read(); }

if (recipient != localAddress && recipient != 0xFF) { Serial.println("This message is not for me."); return; // skip rest of function }

Serial.print(incoming); Serial.print(" || RSSI: "); Serial.println(LoRa.packetRssi()); Serial.println(); }

mohelshafei1950 avatar May 06 '23 17:05 mohelshafei1950

You should try a sanity test for your setup. Place the modules 1-2m apart, their RSSI when sending packets on 17db should be more or less around -40 db and not much less. Also you can set bandwidth, that helps with sensitivity too

mistrjirka avatar Jun 29 '23 07:06 mistrjirka