Help with GPS GY-NEO6MV2

Hi

I am Spanish, Is my first time I write in this forum. I need help with my project, I try to make a kilometers accounts for my bike.

My problem is with GPS ( is a GY-NEO6MV2), the refresh is every 9 seconds more or lees. I add a code for check the cheksum and I think this is the problem. Anyone know how repair it!! I add the complete code.

#include <LiquidCrystal.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);

 int sensorPin = A1;
 int medio=0;
 int Temperatura=0;
 int Rc=220;
 int val;
 int tempPin = A0;
 static const int RXPin = 4, TXPin = 3;
 static const uint32_t GPSBAUD = 9600;
 int speed1=0 ;
 int sat=0;
 
 TinyGPSPlus gps;
 SoftwareSerial ss (RXPin, TXPin);
 
void setup() { 
  lcd.begin(16, 2);
  Serial.begin(115200);
  ss.begin(GPSBAUD);
  lcd.setCursor(0,0); // Vision de pantalla generico no cambiara
  lcd.print("Temp: ");
  lcd.setCursor(11,0);
  lcd.print("Sat:");
   
}

void loop()

{
 while (ss.available() > 0 )
 gps.encode(ss.read());

  medio=analogRead(sensorPin); // 
  speed1=gps.speed.kmph();
  val=analogRead(tempPin);
  int mv = (val/1024.0)*5000;
  int cel = mv/10;
  int sat =gps.satellites.value();
  
  
  Serial.print("Resistencia: "); // Serial print
  //Serial.print(medio);
  Serial.print(" -- ") ;
  Serial.print(" Temperatura: ");
  Serial.print(cel);
  Serial.print(" -- Velocidad : ");
  Serial.print(gps.speed.kmph());
  Serial.print(" -- Sped : ");
  Serial.print(speed1);
  Serial.print(" km/h"); 
  Serial.print(" -- Satelites: ");
  Serial.print(sat); // Hasta aqui
  Serial.print(" -- Checksum : ");
  Serial.print(gps.failedChecksum());
  Serial.print(" -- Overfload : ");
  Serial.println(ss.overflow() ? "Si!" : "No");
  
  lcd.setCursor(6,0); // Print Celsius
  lcd.print(cel);
  // lcd.print(" --");
  lcd.setCursor(15,0); // Print Satellites ok
  lcd.print(sat);
  lcd.setCursor(0,1); // Print speed
  lcd.print(speed1);
  lcd.print("   km/h");
 }

If you see the serial print the checksum error is very common, and I read is a error but I don't know where is.

I add serial text :

Resistencia: -- Temperatura: 31 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 28 -- Overfload : No
Resistencia: -- Temperatura: 31 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 28 -- Overfload : No
Resistencia: -- Temperatura: 29 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 29 -- Overfload : Si!
Resistencia: -- Temperatura: 31 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 30 -- Overfload : Si!
Resistencia: -- Temperatura: 31 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 30 -- Overfload : Si!
Resistencia: -- Temperatura: 29 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 30 -- Overfload : No
Resistencia: -- Temperatura: 31 -- Velocidad : 1.07 -- Sped : 1 km/h -- Satelites: 6 -- Checksum : 30 -- Overfload : No

Thanks you
Jaime

jlloret:
My problem is with GPS ( is a GY-NEO6MV2), the refresh is every 9 seconds more or lees. I add a code for check the cheksum and I think this is the problem. Anyone know how repair it!! I add the complete code.

The Ublox Neo-6M GPS module has a default baudrate of 9600 and a data update rate of 1 Hz. So updates should appear once per second.

If you get less updates from your GPS library, then this is most likely your problem:

#include <SoftwareSerial.h>

The SoftwareSerial is not able to work at 9600 baud while a HardwareSerial port is working at the same time.

If the Arduino board (i.e. MEGA2560) has more than one HardwareSerial port, use a port like Serial1, Serial2 or Serial3 for the GPS module!

If you have just an UNO which provides only one HardwareSerial port, then you have two possibilities:

  1. DO NOT USE SERIAL at the same time when using SoftwareSerial.
  2. Throw out SoftwareSerial from your code and include the AltSoftSerial library instead.

I'd suggest solution number 2: Never use SoftwareSerial in your code, use AltSoftSerial instead!
No free choice of pin with AltSoftSerial, RX/TX pins depend on your board, UNO RX= pin-8.
So you'd have to modify the LCD cabling, as you are already using pin-8 for your LCD, which is not possible with AltSoftSerial on an UNO.

Hi Jurs

I try your choice, I add AltsoftLibrary and I change the wires Lcd, this is my new code.

#include <LiquidCrystal.h>
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
// #include <SoftwareSerial.h>

LiquidCrystal lcd(7,5, 6, 10, 11 , 12);

 int sensorPin = A1;
 int medio=0;
 int Temperatura=0;
 int Rc=220;
 int val;
 int tempPin = A0;
 static const int RXPin = 4, TXPin = 3;
 static const uint32_t GPSBAUD = 9600;
 int speed1=0 ;
 int sat=0;
 
 TinyGPSPlus gps;
 // SoftwareSerial ss (RXPin, TXPin);
 AltSoftSerial altSerial;

 
void setup() { 
  lcd.begin(16, 2);
  Serial.begin(115200);
  altSerial.begin(GPSBAUD);
  lcd.setCursor(0,0); // Vision de pantalla generico no cambiara
  lcd.print("Temp: ");
  lcd.setCursor(11,0);
  lcd.print("Sat:");
   
}

void loop()

{
 while (altSerial.available() > 0 )
 gps.encode(altSerial.read());

  medio=analogRead(sensorPin); // 
  speed1=gps.speed.kmph();
  val=analogRead(tempPin);
  int mv = (val/1024.0)*5000;
  int cel = mv/10;
  int sat =gps.satellites.value();
  
  
  Serial.print("Resistencia: "); // Serial print
  //Serial.print(medio);
  Serial.print(" -- ") ;
  Serial.print(" Temperatura: ");
  Serial.print(cel);
  Serial.print(" -- Velocidad : ");
  Serial.print(gps.speed.kmph());
  Serial.print(" -- Sped : ");
  Serial.print(speed1);
  Serial.print(" km/h"); 
  Serial.print(" -- Satelites: ");
  Serial.print(sat); // Hasta aqui
  Serial.print(" -- Checksum : ");
  Serial.print(gps.failedChecksum());
  Serial.print(" -- Overfload : ");
  Serial.println(altSerial.overflow() ? "Si!" : "No");
  
  lcd.setCursor(6,0); // Print Celsius
  lcd.print(cel);
  // lcd.print(" --");
  lcd.setCursor(15,0); // Print Satellites ok
  lcd.print(sat);
  lcd.setCursor(0,1); // Print speed
  lcd.print(speed1);
  lcd.print("   km/h");
 }

But don't work, I don't receive anything.

Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 37 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No
Resistencia: -- Temperatura: 42 -- Velocidad : 0.00 -- Sped : 0 km/h -- Satelites: 0 -- Checksum : 0 -- Overfload : No

Do you know what is my error??

Thank you very much Jurs
Jaime

jlloret:
Do you know what is my error??

What type of board are you using?
Is it an UNO?

When checking the GPS module, I'd better do a simple raw data test first:

#include <AltSoftSerial.h>

AltSoftSerial altSerial;

void setup() {
  Serial.begin(9600); // serial for PC serial monitor
  Serial.println("AltSoftSerial Test Begin");
  altSerial.begin(9600); // serial for GPS module, GPS-TX connected to UNO pin-8
}

void loop() {
  char c;
  if (altSerial.available()) {
    c = altSerial.read();
    Serial.print(c);
  }
}

If your hardware is correctly connected and powered on, you should see some raw data on the serial monitor. Valid GPS signals from the satellites are not required for that.

But when you want to see data after retrieving them from the TinyGPS library, you will need to receive valid GPS signals from the GPS satellites.

P.S.: At 9600 baud, you can send or receive 960 bytes per second from the GPS module. The serial input buffer is 63 bytes in size, as well as the serial output buffer. So if you don't want to miss any characters from the GPS-module, you better NOT SEND MORE THAN 63 characters to the Serial monitor between the readings of the GPS module. Otherwise you miss characters from the GPS module because you are blocking the GPS send by overflowing the serial output buffer. Other possibility: Increase the baudrate for the Serial monitor to let's say 115200 baud for the serial monitor:

  Serial.begin(115200); // serial monitor (use the same in the serial monitor window)
  Serial.println("AltSoftSerial Test Begin");
  altSerial.begin(9600); // GPS serial TX connected to UNO pin-8

In that case you can send much more than 63 characters to the Serial monitor between two readouts of the GPS altSerial port.

A few checksum errors is normal.

The data all zeros probably means your GPS hasn't finished detecting the satellites.

while (ss.available() > 0 )
gps.encode(ss.read());

You should rethink this bit of code.

IIRC the encode method returns true if the most recent character put into it is the end of a GPS "setence", and false otherwise. Or the other way arround.

This means two things.

If you only got a few characters of the sentence so far, you will still go ahead and print all that stuff. It looks like all that printing is clogging up your Uno, and you have the issue with 2 serials attempting to run as the previous poster said.

The other problem is, if you have a processing backlog on the serial, and more than 1 full sentence available, encode( ) will keep on processing until it runs out of data ( or the serial buffer overflows, which is very likely with gps messages being about 120 char each ).

Hi,
Have you tried the example programs that came with TinyGPS++?

I did and they work, then modify them to your needs.
The examples give a full GPS output, even how many satellites it is reading.
As mentioned earlier, you may not be detecting any satellite, are you in a building, especially with a metal roof, then basically forget about getting a decent number of satellites.

Tom.... :slight_smile:

Hi all

Thank you for yours reply. I change the software and hi delete the softwareserial. I make directly a hardware serial. I buy to a Arduino Mega to get more serials to the modules.

This is the new code work ok, but very slowly, every 2 seconds refresh the gps signal in lcd and the first connect is about 8 minuts :-s

Thank you for all. This is the code now work, slowly but work.

#include <LiquidCrystal.h>
#include <TinyGPS++.h>
//#include <SoftwareSerial.h>

LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);

 int sensorPin = A1;
 int medio=0;
 int Temperatura=0;
 int Rc=220;
 int val;
 int tempPin = A0;
 static const int RXPin = 4, TXPin = 3;
 static const uint32_t GPSBAUD = 9600;
 int speed1=0 ;
 int sat=0;
 
 TinyGPSPlus gps;
 // SoftwareSerial ss (RXPin, TXPin);
 
void setup() { 
  lcd.begin(16, 2);
  Serial.begin(9600);
  // ss.begin(GPSBAUD);
  lcd.setCursor(0,0); // Vision de pantalla generico no cambiara
  lcd.print("Temp: ");
  lcd.setCursor(11,0);
  lcd.print("Sat:");
   
}

void loop()

{
 while (Serial.available() > 0 )
 gps.encode(Serial.read());

  medio=analogRead(sensorPin); // 
  speed1=gps.speed.kmph();
  val=analogRead(tempPin);
  int mv = (val/1024.0)*5000;
  int cel = mv/10;
  int sat =gps.satellites.value();
  
  
  /* Serial.print("Resistencia: "); // Serial print
  //Serial.print(medio);
  Serial.print(" -- ") ;
  Serial.print(" Temperatura: ");
  Serial.print(cel);
  Serial.print(" -- Velocidad : ");
  Serial.print(gps.speed.kmph());
  Serial.print(" -- Sped : ");
  Serial.print(speed1);
  Serial.print(" km/h"); 
  Serial.print(" -- Satelites: ");
  Serial.print(sat); // Hasta aqui
  Serial.print(" -- Checksum : ");
  Serial.print(gps.failedChecksum());
  Serial.print(" -- Overfload : ");
  Serial.println(ss.overflow() ? "Si!" : "No"); */
  
  lcd.setCursor(6,0); // Print Celsius
  lcd.print(cel);
  // lcd.print(" --");
  lcd.setCursor(15,0); // Print Satellites ok
  lcd.print(sat);
  lcd.setCursor(0,1); // Print speed
  lcd.print(speed1);
  lcd.print("   km/h");
 }

Thanks for all
Jaime

jlloret:
This is the new code work ok, but very slowly, every 2 seconds refresh the gps signal in lcd and the first connect is about 8 minuts :-s

To me it looks like your GPS module is badly connected.

"Serial" ist the USB-Serial Connection from RX/TX pins 0/1 to your PC ("serial monitor").
You cannot use the same port for your GPS module.

The GPS module must be connected to a different serial port like "Serial1".