I have an Arduino Pro Mini along with a GPS Unit - ATGM336H. Below is the sketch I'm currently using:

#include <SoftwareSerial.h>
#include "Ublox.h"
SoftwareSerial GPS(4,5);
Ublox serial_gps;

void setup(){

void loop(){
  char c = GPS.read();

I'm able to receive NMEA stream from the GPS Unit and parse (tried TinyGPS++, TinyGPS and Ublox) the stream but the data is not valid nor does it ever change. I've read that this GPS unit can take up to 32 seconds to get a fixed position and deliver valid co-ords but I cannot receive any.

Serial Monitor

Is there anything obviously wrong with my sketch or hardware setup?

Any and all help would be greatly appreciated!

  • remove the if(serial_gps.encode(c)){ Serial.println(serial_gps.longitude); } .... instead, use Serial.println(c); to see if there is any actual data ...... I think that you are sending individual characters to gps.encode(), so you get nothing back
    – jsotola
    Jun 30, 2018 at 18:45

1 Answer 1


while(GPS.available() > 0) {....

Also is the GPS unit outside?

  • I have tested the project both indoors and outdoors. I do receive NMEA streams but they seems to be lacking critical info. I will include the >0 and get back to you with a result Jun 29, 2018 at 8:56
  • 1
    There is no difference between while(GPS.available()) and while(GPS.available() > 0). 0 is false anything else is true and GPS.available() doesn't return negative values.
    – gre_gor
    Jun 29, 2018 at 10:49
  • available() returns the number of bytes in the RX buffer, so if you juts use available() zero will be returned and the sub will run and return zeros which is what his output looks like. If you use available() > 0 then only when 1 or more bytes exist then the sub will run. Jun 29, 2018 at 15:58
  • If available() returns zero then the while loop will not run, since zero is false.
    – gre_gor
    Jul 4, 2018 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.