Getting zeros from gps

Hello .
I'm new here so I don't know yet about forum categories , and I've just started to learn about Arduino and Blynk.

I'm trying to make a GPS tracker using UNO, sim900a and Neo6m
I'm getting zeros( lat lng speed...)

I started by using 2 software serials but it seems like it was not right so I connected gsm to 2,3 pins and gps to 0,1 pins.

`please help this is the code:

//Blynk is a platform with iOS and Android apps to control
//Arduino
//You can build graphic interfaces for all your
//projects
//Blynk library is licensed under MIT license

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLnQQU3hwl"                          //my ID template
#define BLYNK_DEVICE_NAME "Quickstart Device"                     //my device name
#define BLYNK_AUTH_TOKEN "I99WJAJ4IpS0SwgJnq-uziuXIBL8juVS       
                                                                //my Authentication token
#define TINY_GSM_MODEM_SIM900                                     //my modem is SIM900a
#include <TinyGsmClient.h>                                        //including GSM library
#include <BlynkSimpleTinyGSM.h>                                   //including GSM IoT library
char auth[] = "I99WJAJ4IpS0SwgJnq-uziuXIBL8juVS";                 //setting Auth number
                                                                //settings of sudani internet using 2G GPRS
char apn[]  = "sudaninet";                                        //sudani apn
char user[] = "sudani";                                           //username
char pass[] = "sudani";                                           //password

int SerialBaud = 9600;                            // Baud rate 9600
int GSMBaud = 9600;                              // Baud rate 9600
int GSMDelay = 3000;                              // GSM delay 5 seconds
const unsigned long eventInterval = 10000;
unsigned long previousTime = 0;

#include <SoftwareSerial.h>                                       //Software Serial on Uno

SoftwareSerial mygsm(2,3);                                    // RX, TX 
TinyGsm modem(mygsm);                                          //assigning GSM module
#include <TinyGPS++.h>
#include <TinyGPSPlus.h>
TinyGPSPlus mygps;                                                //the tiny gps object                          //RX , TX
WidgetMap myMap(V0);                                             //map display
double latitude;                                                 //storing latitude
double longitude;                                                //storing longitude
double speed;                                                    //storing speed
double satellites;                                               //storing sat number
String direction;                                                //storing direction
unsigned int move_index=1;                                       //fixed location for now


void setup()
{
  
Serial.begin(SerialBaud);                                            //baud rate of serial 9600 default
Serial.println();
delay(10);
mygsm.begin(GSMBaud);                                          // Set GSM module baud rate
delay(GSMDelay);


Serial.println("Initializing modem...");
modem.init();
//modem.restart();                                       //restart modem ,takes some time

//modem.simUnlock("1234");                            //if i have PIN code                                 //start record gps data
Blynk.begin(auth, modem, apn, user, pass);            //start blynk Iot server connection


}


void loop()
{  

    

unsigned long currentTime = millis();
if (currentTime - previousTime >= eventInterval) {

      
satellites=(mygps.satellites.value());                         //get number of satellites
latitude=(mygps.location.lat());                               //get latitude
longitude=(mygps.location.lng());                              //get longitude
speed=mygps.speed.kmph();                                      //get speed
direction=TinyGPSPlus::cardinal(mygps.course.value());       //get direction
myMap.location(move_index, latitude, longitude, "GPS_Location");
Blynk.run();
Serial.print("SATS:  ");
  Serial.println(satellites);  // float to x decimal places
  Serial.print("LATITUDE:  ");
  Serial.println(latitude, 6);  // float to x decimal places
  Serial.print("LONGITUDE: ");
  Serial.println(longitude, 6);
  Serial.print("SPEED: ");
  Serial.print(speed);
  Serial.println("kmph");
  Serial.print("DIRECTION: ");
  Serial.println(direction);

Blynk.run();
Blynk.virtualWrite(V0, longitude, latitude);
Blynk.virtualWrite(V1,String(latitude,6));
Blynk.virtualWrite(V2,String(longitude,6));
Blynk.virtualWrite(V3,satellites);
Blynk.virtualWrite(V4,speed);
Blynk.virtualWrite(V5,direction);

Serial.println();
Blynk.run();
previousTime = currentTime;
}

}

fail

Using the same GPS and using the example code as the base that never happend.

Copies some line of code showing library and some more.

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

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

#define BACKLIGHT_PIN     13

hd44780_I2Cexp mylcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

// The TinyGPS++ object
TinyGPSPlus gps;

//Create GPS channel
#define RX 2
#define TX 3
SoftwareSerial mySerial(RX, TX);  // pick any 2 unused digital pins (not pins 0 or 1)

void setup()
{
int status;

  // initialize LCD with number of columns and rows: 
  // hd44780 returns a status from begin() that can be used
  // to determine if initalization failed.
  // the actual status codes are defined in <hd44780.h>
  // See the values RV_XXXX
  //
  // looking at the return status from begin() is optional
  // it is being done here to provide feedback should there be an issue
  //
  // note:
  //  begin() will automatically turn on the backlight
  //
  status = mylcd.begin(LCD_COLS, LCD_ROWS);
  if(status) // non zero status means it was unsuccesful
  {
    status = -status; // convert negative status value to positive number

    // begin() failed so blink error code using the onboard LED if possible
    hd44780::fatalError(status); // does not return
  }

  // initalization was successful, the backlight should be on now

  // Print a message to the LCD
//  mylcd.print("Hello, World!");

  mySerial.begin(9600);  // 9600 is the default baud rate for my Neo6m units
  
  Serial.begin(9600);// For PC, serial monitor

  Serial.println("Started.");//sent to PC
  
  mylcd.begin(20,4);//defining I2C LCD
  mylcd.clear();
  mylcd.print("Starting...");
}

and 

//Serial.println(gps.location.lat(), 6); // Latitude in degrees (double)
//Serial.println(gps.location.lng(), 6); // Longitude in degrees (double)
//Serial.print(gps.location.rawLat().negative ? "-" : "+");
//Serial.println(gps.location.rawLat().deg); // Raw latitude in whole degrees
//Serial.println(gps.location.rawLat().billionths);// ... and billionths (u16/u32)
//Serial.print(gps.location.rawLng().negative ? "-" : "+");
//Serial.println(gps.location.rawLng().deg); // Raw longitude in whole degrees
//Serial.println(gps.location.rawLng().billionths);// ... and billionths (u16/u32)
//Serial.println(gps.date.value()); // Raw date in DDMMYY format (u32)
//Serial.println(gps.date.year()); // Year (2000+) (u16)
//Serial.println(gps.date.month()); // Month (1-12) (u8)
//Serial.println(gps.date.day()); // Day (1-31) (u8)
//Serial.println(gps.time.value()); // Raw time in HHMMSSCC format (u32)
//Serial.println(gps.time.hour()); // Hour (0-23) (u8)
//Serial.println(gps.time.minute()); // Minute (0-59) (u8)
//Serial.println(gps.time.second()); // Second (0-59) (u8)
//Serial.println(gps.time.centisecond()); // 100ths of a second (0-99) (u8)
//Serial.println(gps.speed.value()); // Raw speed in 100ths of a knot (i32)
//Serial.println(gps.speed.knots()); // Speed in knots (double)
//Serial.println(gps.speed.mph()); // Speed in miles per hour (double)
//Serial.println(gps.speed.mps()); // Speed in meters per second (double)
//Serial.println(gps.speed.kmph()); // Speed in kilometers per hour (double)
//Serial.println(gps.course.value()); // Raw course in 100ths of a degree (i32)
//Serial.println(gps.course.deg()); // Course in degrees (double)
//Serial.println(gps.altitude.value()); // Raw altitude in centimeters (i32)
//Serial.println(gps.altitude.meters()); // Altitude in meters (double)
//Serial.println(gps.altitude.miles()); // Altitude in miles (double)
//Serial.println(gps.altitude.kilometers()); // Altitude in kilometers (double)
//Serial.println(gps.altitude.feet()); // Altitude in feet (double)
//Serial.println(gps.satellites.value()); // Number of satellites in use (u32)
//Serial.println(gps.hdop.value()); // Horizontal Dim. of Precision (100ths-i32)


Hope You find something...

Please edit your post to add code tags ("</>" editor button).

To check whether the GPS has a satellite fix, run this simple echo program and post a bit of the output. Of course you must be outdoors, with a clear view of the sky, and give the GPS a few minutes for a "cold start".

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //GPS (RX, TX) check correct pin assignments and baud rate

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

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

sorry , I edited the post.
thanks for your response .I tried your code

Please do not post pictures of code and text. Use cut and paste instead.

In this case it is possible to see that the GPS module is working fine, and has a satellite fix. So if the code posted earlier continues to return zeros (while outside, with a clear view of the sky), there is a problem with that code or the wiring.

You seem to be missing the lines that read from Serial (the GPS) and update the 'mygps' object. Try:

void loop()
{  
  if (Serial.available())
    mygps.encode(Serial.read());

  unsigned long currentTime = millis();
  if (currentTime - previousTime >= eventInterval) {
    satellites=(mygps.satellites.value());                         //get number of satellites
    latitude=(mygps.location.lat()); 
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.