Hello engineers, may you kindly assist.
When i connect both the GPS module (Neo 6M) and the LoRa module (SX1278) to the Arduino Uno, the LoRa module fails to initialize. However, when I connect only the LoRa module, it initializes successfully.
Components:
- Arduino Uno
- Neo 6M GPS module
- SX1278 LoRa module
below is the code and I have also attached an image. Your assistance will be greatly appreciated
.
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <SPI.h>
#include <LoRa.h>
SoftwareSerial gpsSerial(14, 15); // RX, TX pins for NEO-6M GPS module
TinyGPSPlus gps;
#define LORA_SS_PIN 10 // LoRa module's NSS pin
#define LORA_RST_PIN 9 // LoRa module's RESET pin
#define LORA_DIO0_PIN 2 // LoRa module's DIO0 pin
void setup() {
Serial.begin(9600); // Set up Serial library at 9600 bps
gpsSerial.begin(9600);
SPI.begin(); // Initialize SPI for LoRa module
LoRa.setPins(LORA_SS_PIN, LORA_RST_PIN, LORA_DIO0_PIN);
if (!LoRa.begin(433E6)) {
Serial.println("LoRa initialization failed!");
while (1);
}
else
{
Serial.println("LoRa initialization successful!");
}
}
void loop() {
while (gpsSerial.available() > 0) {
if (gps.encode(gpsSerial.read())) {
if (gps.location.isValid()) {
float latitude = gps.location.lat();
float longitude = gps.location.lng();
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
String coordinates = String(latitude, 6) + "," + String(longitude, 6);
LoRa.beginPacket();
LoRa.print(coordinates);
LoRa.endPacket();
}
}
}
}
