GPS Receiver for Arduino (Model B)

arduino

#1

I have received the GPS receiver and I am attempting to get some sample TinyGPS code working.
I have wired it up as per the Wiki and the Blue LED on the unit is on, with a blink off every now and then. The software serial gets initialized but the GPS never seems to send any data.

I am not sure what is going on.


#2

Can you give a link to how you wired it up?

I’ve tried searching myself, and the product page has a bad link to Wiki.

http://littlebirdelectronics.com.au/products/gps-receiver-for-arduino-model-b
https://www.dfrobot.com/wiki/index.php?title=GPS_Receiver_for_Arduino_(Model_A) “There is currently no text in this page.”


#3

I used the information here https://www.dfrobot.com/wiki/index.php?title=GPS_Receiver_for_Arduino_(Model_A)_(SKU:TEL0083-A)

However I used the sample code directly from TinyGPS (modifying the serial pins and baud rate)
I have the power connection right as the blue LED on the device powers up.


#4

Thanks. Sorry, but still a lot of ambiguity, and it would waste your time if I made guesses. The page shows the pinout of the GPS receiver cable, and gives an example wiring to an unnamed Arduino with an LCD shield. How have you attached it to an Arduino? What Arduino is it? What is your sketch?


#5

Not a problem… I have got out of practice with development forums, sorry

I am using an Arduino Mega and have connected it the following way:
Black: RxD -> Pin 19
White: TxD -> Pin 18
Red: VCC -> 5v
Black (thick): GND -> Gnd

Using the “DeviceExample” code in codebender.cc for TinyGPS++


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

static const int RXPin = 19, TXPin = 183;
static const int GPSBaud = 38400;

// The TinyGPS++ object
TinyGPSPlus gps;

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

void setup()
{
Serial.begin(115200);
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();
}

void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();

if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F(“No GPS detected: check wiring.”));
delay(100000;
}
}

void displayInfo()
{
Serial.print(F(“Location: “));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(”,”));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F(“INVALID”));
}

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”));
}

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”));
}

Serial.println();
}

I have tried other sample code but all behave the same… No GPS detected: check wiring… or similar.
I have also tried reversion the Tx Rx wires… still the same.


#6

my reply to remove the ambiguity is awaiting moderation as it could be “spam”


#7

Thanks, very useful.

Indenting and some other data in your code was lost, so very hard to read. In future, for quoting code, use three backticks (`) on a line before and after pasting, which shows up like this;

#include <TinyGPS++.h>

I’ve figured out your most likely problem:

Other things:

  • since the GPS RxD is on Arduino pin 19, that means the Arduino sketch should have TXPin set to 19, and RXPin set to 18, (subject to using the right pins),
  • you have TXPin set to 183, perhaps you mean 18?
  • you might also try testing the GPS alone, with a serial adapter, like an FTDI cable, that will help you isolate the GPS as working.

#8

Cool thanks… Couldn’t figure out how to mark the code block.

Yep I did mean 18 (cut paste error). I also changed them over at one point, but I think the unsupported pins is the most likely.

I will test when I get home and I will also connect to my FTDI cable as well.
Thanks again.


#9

No worries.

Another trick I’ve used is to only connect TxD on the GPS to RxD on the FTDI cable, so that I’m sure the module is able to work without any configuration data sent to it. Oh, and GND of course.


#10

Ok on the FTDI cable I can get data from the GPS device… only if I select a baud rate of 115200 bps.
This is with only TxD on the module connected to the Rx of the FTDI cable.

So the module works. :smiley:

Trying to get the Arduino Mega 2560 to work however seems more of an issue.
So I have moved the code like this

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <AltSoftSerial.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).
*/
static const int RXPin = 10, TXPin = 11;
static const int GPSBaud = 11520;

// The TinyGPS++ object
TinyGPSPlus gps;

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

void setup()
{
  Serial.begin(9600);

  pinMode(RXPin, INPUT);
  pinMode(TXPin, OUTPUT);
  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();
  
  delay(5000);
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  	while (ss.available() > 0)
  	{
  		gps.encode(ss.read());
    	displayInfo();
	}
	if (millis() > 5000 && gps.charsProcessed() < 10)
  	{
    	Serial.println(F("No GPS detected: check wiring."));
  	} 
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  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"));
  }

  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"));
  }

  Serial.println();
}

Using AltSoftSerial it seems I am getting something… however although it has recieved characters the parsing is failing.

Thanks for your help I will continue along the debug path.


#11

Looks like you’re pretty much set on the way to debugging.

The parser probably verifies the per-line checksums inherent in NMEA sentences. You might try avoiding the parser and dumping the data to Serial, so that you can check the data manually, looking for missing bytes.

My gut feel is that 115200 bps will be closer to overrun for software serial, and you might have to use the hardware serial pins. But I’ve not yet used the AltSoftwareSerial library on a Mega.


#12

Ok reverting to hardware serial. I have a few of devices to hookup for this solution and probably jumped too far in. :smile:

I have tried a bit of code like…

void setup()
{
   Serial.begin(115200);
   Serial1.begin(115200);
   Serial.print("TingGPS++ Version: "); 
   Serial.println(TinyGPSPlus::libraryVersion());
   Serial.println();
}

void loop()
{
   char c;
   while (Serial1.available() > 0)
   {
      c = Serial1.read();
      Serial.print(c);
   }

This is now showing me the NMEA sentences. 1 step closer.


#13

Ok sorted… some little hacky stuff here.


// The TinyGPS++ object
TinyGPSPlus gps;


void setup()
{
	Serial.begin(115200);
	Serial1.begin(115200);
  	
  	Serial.print("TingGPS++ Version: "); Serial.println(TinyGPSPlus::libraryVersion());
  	Serial.println();
}

void loop()
{
	char c;
  	while (Serial1.available() > 0)
  	{
 		gps.encode(Serial1.read());
 		if (gps.passedChecksum() > 0)
    		displayInfo();
	}
	if (millis() > 5000 && gps.charsProcessed() < 10)
  	{
    	Serial.println(F("No GPS detected: check wiring."));
  	} 
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  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"));
  }

  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"));
  }

  Serial.println();
}

Now gives me good output.

Location: -x5.199901,1x9.048370  Date/Time: 11/10/2015 10:25:09.00
Location: -x5.199901,1x9.048370  Date/Time: 11/10/2015 10:25:09.00
Location: -x5.199901,1x9.048370  Date/Time: 11/10/2015 10:25:09.00
Location: -x5.199901,1x9.048370  Date/Time: 11/10/2015 10:25:09.00
Location: -x5.199901,1x9.048370  Date/Time: 11/10/2015 10:25:09.00

Happy man.

I was wondering about the locked time, I realized that with a 10hz GPS and a 115200 baud connection the code was running the display for every character received, so it appeared that the time did not change.

I added the following condition to the top of the displayInfo function

  if (!gps.location.isValid() || !gps.location.isUpdated())
  	return;
  	

to ensure that only if I had a valid location that was updated (not necessarily changed) would then write an output.

so now I get

Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.30
Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.30
Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.40
Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.40
Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.50
Satellites: 8  Location: -x5.199913,1x9.048324  Date/Time: 11/10/2015 10:53:55.50

Perfect!!!