GPS not working.

Hello,

I am trying to create a GPS speedometer with only leds.
I have follow this tutorial GPS speedometer

I have changed the code a bit because i don't have a LCD screen, and i only want to have leds.

I have connected everything the same as the tutorial.
The GPS power led is turn ON (RED), and the PPS led is blining GREEN.
But all the leds not seens to work.
The only thing that not the same that is the GPS module, I have the : VK2828U7G5L, Maybe that is the problem?

I have also check this part of the scripts :

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

  }

I did not get any input so that means the GPS module is detected anyway?

This is the original code :

#include "U8glib.h"
U8GLIB_SSD1351_128X128_332 u8g(13, 11, 8, 9, 7); // Arduino UNO: SW SPI Com: SCK = 13, MOSI = 11, CS = 8, DC = 9, RESET = 7



#define u8g_logo_sat_width 20
#define u8g_logo_sat_height 20

//satellite logo
const unsigned char u8g_logo_sat[] = {
  0x00, 0x01, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x06, 0x00, 0x60, 0x30, 0x00,
  0x60, 0x78, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xff, 0x01,
  0x80, 0xff, 0x00, 0xc0, 0x7f, 0x06, 0xc0, 0x3f, 0x06, 0x80, 0x1f, 0x0c,
  0x80, 0x4f, 0x06, 0x19, 0xc6, 0x03, 0x1b, 0x80, 0x01, 0x73, 0x00, 0x00,
  0x66, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00
};

// The serial connection to the GPS device
#include <SoftwareSerial.h>
static const int RXPin = 10, TXPin = 15;
static const uint32_t GPSBaud = 9600;
SoftwareSerial ss(RXPin, TXPin);

//GPS Library
#include <TinyGPS++.h>
TinyGPSPlus gps;

//Program variables
double Lat;
double Long;
//int day, month, year;
//int hour, minute, second;

int num_sat, gps_speed;
String heading;


const int ledCount = 10;    // the number of LEDs in the bar graph

int ledPins[] = {
  2, 3, 4, 5, 6, 14, A5, A4, A3, A2
};   // an array of pin numbers to which LEDs are attached



void setup() {

  ss.begin(GPSBaud);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }

  //Define ledpins as OUTPUT's
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    pinMode(ledPins[thisLed], OUTPUT);
  }


}

void loop() {

  Get_GPS(); //Get GPS data


  Led_Bar();//Adjust the LED bar


  //Display info in the OLED
  u8g.firstPage();
  do {
    print_speed();
  } while ( u8g.nextPage() );




}

void print_speed() {

  u8g.setFont(u8g_font_helvR24r);
  u8g.setPrintPos(2, 70);

  u8g.print(gps_speed , DEC);
  u8g.setPrintPos(60, 70);
  u8g.print("km/h");


  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(85, 15);
  u8g.print( num_sat, 5);


  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(15, 100);
  u8g.print("Lat:");

  u8g.setPrintPos(50, 100);
  u8g.print( Lat, 6);


  u8g.setPrintPos(10, 120);
  u8g.print("Long:");

  u8g.setPrintPos(50, 120);
  u8g.print( Long, 6);



  u8g.setFont(u8g_font_unifont);

  u8g.setPrintPos(0, 15);
  u8g.print( heading);


  u8g.drawXBM(108, 0, u8g_logo_sat_width, u8g_logo_sat_height, u8g_logo_sat);


}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}


void Get_GPS()
{


  num_sat = gps.satellites.value();

  if (gps.location.isValid() == 1) {

    Lat = gps.location.lat();
    Long = gps.location.lng();


    gps_speed = gps.speed.kmph();

    heading = gps.cardinal(gps.course.value());
  }



  /*
    if (gps.date.isValid())
    {
      day = gps.date.day();
      month = gps.date.month();
      year = gps.date.year();
    }

    if (gps.time.isValid())
    {

      hour = gps.time.hour();
      minute = gps.time.minute();
      second = gps.time.second();
    }

  */

  smartDelay(1000);


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

  }



}

void Led_Bar()
{

  int ledLevel = map(gps_speed, 0, 190, 0, ledCount);

  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel) {
      digitalWrite(ledPins[thisLed], HIGH);
    } else { // turn off all pins higher than the ledLevel:
      digitalWrite(ledPins[thisLed], LOW);
    }
  }
}

And i have changed to this :

// The serial connection to the GPS device
#include <SoftwareSerial.h>
static const int RXPin = 10, TXPin = 15;
static const uint32_t GPSBaud = 9600;
SoftwareSerial ss(RXPin, TXPin);

//GPS Library
#include <TinyGPS++.h>
TinyGPSPlus gps;

//Program variables
double Lat;
double Long;
//int day, month, year;
//int hour, minute, second;

int num_sat, gps_speed;
String heading;


const int ledCount = 10;    // the number of LEDs in the bar graph

int ledPins[] = {
  2, 3, 4, 5, 6, 14, A5, A4, A3, A2
};   // an array of pin numbers to which LEDs are attached



void setup() {

  //ss.begin(GPSBaud);
  //Define ledpins as OUTPUT's
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    pinMode(ledPins[thisLed], OUTPUT);
  }


}

void loop() {

  Get_GPS(); //Get GPS data


  Led_Bar();//Adjust the LED bar


  //Display info in the OLED




}



// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}


void Get_GPS()
{


  num_sat = gps.satellites.value();

  if (gps.location.isValid() == 1) {

    Lat = gps.location.lat();
    Long = gps.location.lng();


    gps_speed = gps.speed.kmph();

    heading = gps.cardinal(gps.course.value());
  }



  /*
    if (gps.date.isValid())
    {
      day = gps.date.day();
      month = gps.date.month();
      year = gps.date.year();
    }

    if (gps.time.isValid())
    {

      hour = gps.time.hour();
      minute = gps.time.minute();
      second = gps.time.second();
    }

  */

  smartDelay(1000);


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

  }



}

void Led_Bar()
{

  int ledLevel = map(gps_speed, 0, 190, 0, ledCount);

  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:

    if (thisLed < ledLevel) {
      digitalWrite(ledPins[thisLed], HIGH);
    } else { // turn off all pins higher than the ledLevel:
      digitalWrite(ledPins[thisLed], LOW);
    }
  }
}

I hope anyone can help me out thanks.

Are you using the latest version of TinyGPS++ ?

Did the examples in the TinyGPS++ library work OK ?

srnet:
Are you using the latest version of TinyGPS++ ?

Did the examples in the TinyGPS++ library work OK ?

Yes, i used the latest version.
I don't know about the examples i just install TinyGPS++

What do you get if you serial.print your gpsspeed variable?

jordy82:
I don't know about the examples i just install TinyGPS++

The library has folder called \examples, it contains tested programs that work.

Your program has a lot of other stuff that may be causing the problem, so you need a simple program to prove the GPS part works. Set the GPS baud rate in the examples to 9600.

if i open FullExample and i upload that script and open serial monitor a see this :

**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 15714 0 0
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 16039 0 0
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 16274 0 0
**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 16559 0 0

That looks like the gps doesn't have a lock. Are you trying to use it indoors?

wildbill:
That looks like the gps doesn't have a lock. Are you trying to use it indoors?

yeah its not the best weather now to sit out side hahah
but i am close to a window.

Well, apparently, that's not enough. No surprise, the only place mine works in the house is under a big skylight.

Of course, even if it did get signal, your speed would be zero, so your leds wouldn't light.

Try this simple echo program, which will immediately tell you if the GPS is working, and whether it has a lock. For a new module, you need to be outdoors, with a clear view of the sky and wait up to 15 minutes for a "factory fresh" cold start satellite fix.

Make sure the Baud rates and pin assignments are correct for your setup.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //(RX, TX) check correct pin assignments.

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("GPS start");
}

void loop() {
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

jremington:
Try this simple echo program, which will immediately tell you if the GPS is working, and whether it has a lock. For a new module, you need to be outdoors, with a clear view of the sky and wait up to 15 minutes for a "factory fresh" cold start satellite fix.

Make sure the Baud rates and pin assignments are correct for your setup.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //(RX, TX) check correct pin assignments.

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("GPS start");
}

void loop() {
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

I try your code when i run it inside my house i get this :

$G0329.00,V,,,,,,,110819,,,N76
$GPVTG,,,,,,,,,N
30
$GPGG0$G1G$GPRMC,210331.00,V,,,,,,,110819,,,N7F
$GPVTG,,,,,,,,,N
30
$GPGGA,210331.00,,,,,0,00,99.99,,,,,,64
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
30
$GPGSV,3,1,10,02,23,234,,05,61,283,,06,01,195,,07,59,072,73
$GPGSV,3,2,10,09,28,089,,13,29,268,,16,03,016,,27,00,043,7F
$GPGSV,3,3,10,28,08,153,,30,71,162,7D
$GPGLL,,,,,210331.00,V,N
48
$GPRMC,210332.00,V,,,,,,,110819,,,N
7C
$GPVTG,,,,,,,,,N
30

and so on...

$GPRMC,210332.00,V,,,,,,,110819,,,N*7CThe "V" means no satellite fix.

Take it outside.

jremington:
$GPRMC,210332.00,V,,,,,,,110819,,,N*7CThe "V" means no satellite fix.

Take it outside.

oke, i was out side now i get this :

$GPRMC,212508.00,A,5202.73633,N,00422.99896,E,0.069,,110819,,,A77
$GPVTG,,T,,M,0.069,N,0.128,K,A
27
$GPGGA,212508.00,5202.73633,N,00422.99896,E,1,07,1.54,2.5,M,45.9,M,,5C
$GPGSA,A,3,30,07,05,09,02,13,28,,,,,,2.39,1.54,1.82
03
$GPGSV,3,1,10,02,15,228,12,05,66,263,29,07,51,064,38,09,20,094,3776
$GPGSV,3,2,10,13,37,273,09,15,03,280,,21,05,341,,27,04,036,79
$GPGSV,3,3,10,28,17,149,31,30,76,130,40
7E
$GPGLL,5202.73633,N,00422.99896,E,212508.00,A,A
61

jordy82:
oke, i was out side now i get this :

$GPRMC,212508.00,A,5202.73633,N,00422.99896,E,0.069,,110819,,,A77
$GPVTG,,T,,M,0.069,N,0.128,K,A
27
$GPGGA,212508.00,5202.73633,N,00422.99896,E,1,07,1.54,2.5,M,45.9,M,,5C
$GPGSA,A,3,30,07,05,09,02,13,28,,,,,,2.39,1.54,1.82
03
$GPGSV,3,1,10,02,15,228,12,05,66,263,29,07,51,064,38,09,20,094,3776
$GPGSV,3,2,10,13,37,273,09,15,03,280,,21,05,341,,27,04,036,79
$GPGSV,3,3,10,28,17,149,31,30,76,130,40
7E
$GPGLL,5202.73633,N,00422.99896,E,212508.00,A,A
61

So, what does that tell you? Have you tried Googling "gps nmea sentences"?

It tells us where you are.

jremington:
It tells us where you are.

That is great that means it's working :slight_smile:

Put the coordinates 50 degrees 2.736 minutes N, 4 degrees 22.999 minutes E into Google maps and see what you get.

jordy82:
I try your code when i run it inside my house i get this :

Which also tells you that there are 10 satellites in view, but the signals are all very weak, so no fix information is seen.

Thats the signals are weak is consitent with being next to a Window and not outside.