GPS and LoRa modules not working together

Status
Not open for further replies.

Hanashiro

New member
Hi everyone,
I’ve been working on a project that uses a u-blox GPS NEO6MV2 with a NiceRF 2AD66 LoRa device which uses a SX1276 chip. Using the GPS and the LoRa separately they work just fine with the example programs of their libraries (LoRa from sandeepmistry, TinyGPS and TInyGPS++ from mikalhart), even though the GPS had trouble finding a fix sometimes. However, when I used both at the same time, to transmit the gps coordinates, it simply did not work(The GPS could not find location or the LoRa could not send the GPS coordinates). I tried using a Teensy 4.0 and an Arduino Nano as microcontrollers. Does anyone have ideas for a solution?

Code used with both at the same time:
Code:
#include <SPI.h>
#include <LoRa.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
boolean once = true;
float LAT = 0, LNG = 0;
long wtime = 0;
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

int counter = 0;
void setup() {
  Serial.begin(9600);
  ss.begin(GPSBaud);

  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();

  Serial.println("LoRa Sender");

  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }

}

void loop() {
/*------------------------------Coleta de dados do GPS------------------------*/  
  while (ss.available() > 0)
    if (gps.encode(ss.read()))

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }

/*------------------------------Verificação de dados do GPS------------------------*/  
//Quantidade de satélites:

Serial.print(gps.satellites.value());

//LATITUDE+LONGITUDE 
  if (gps.location.isValid())
  {
    LAT = (gps.location.lat(), 6);
    Serial.print(F(","));
    LNG = (gps.location.lng(), 6);
    if(once == true){
    wtime = millis();
    once = false;
    }
    Serial.print(wtime);
  }
  else
  {
    Serial.println(F("INVALID LOCATION"));
  }

//DATA
  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID DATA"));
  }
//TIME
    Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID TIME"));
  }
    
 Serial.println();



  LoRa.beginPacket();
  LoRa.print("Packet number: ");
  LoRa.print(counter);
  LoRa.print(gps.satellites.value());
  if (gps.location.isValid())
  {
    LoRa.print(LAT);
    Serial.print(F(","));
    LoRa.print(LNG);
  }
  else
  {
    Serial.println(F("INVALID LOCATION"));
  }
   Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID DATA"));
  }
  LoRa.endPacket();

  counter++;
}
 
i had a similar problem with GPS and Teensy 4.1 with ethernet. GPS would work ok until Ethernet was activated. I had to use another GPS (NEO-8MU) with active external antenna on a long cable. GPS was on the window sill. I also had an MBED MCU (NUCLEO_F446RE) where GPS wouldn't work with internal antenna. With active external GPS antenna, the GPS would lock on just fine.
 
Status
Not open for further replies.
Back
Top