Open mohelshafei1950 opened 1 year ago
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
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
include
include
include
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()) {
} delay(1); }
//function to send information over LoRa network void LoRa_send() {
}
//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
include
include
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(); }