MG2639_Cellular Shield + Cell + GPS (GPS doesn't work)

Hey, I am stuck in my project and decided to write my problem here because i tried all my solutions and can not find any help or examples for the GPS Modul on this page:

I having a:

  • MG2639 Cellular (with all Assets like on the picture)

https://learn.sparkfun.com/tutorials/mg2639-cellular-shield-hookup-guide

The GPRS is working, i can send and receive Data from a Web Server fine, but i have troubles getting the GPS working:

  1. I don't get a Fix on the GPS Status Indicator LED (Already tried to change Shield, Cable and GPS Modul)
  2. If i connect an Ultimate GPS Modul from Adafruit it works, so it seems to be a Problem with my code

In the description i found that:

Communication with the cellular and GPS module’s occurs on two separate serial UARTs. To leave the Arduino’s hardware UART free for debugging and uploading sketches, both UARTs are broken out to digital pins – intended for use with the SoftwareSerial library.

Because the SoftwareSerial library can’t reliably support high-ish baud rates, we’ve intentionally slowed down the MG2639’s cellular UART to 4800 bps, rather than the module’s default bit rate of 115200. This slower rate ensure data reliability, and gives the Arduino some extra time to process large strings.

The GPS UART is hard-coded to 115200 baud, which make it harder to use with SoftwareSerial. Instead, we recommend using the AltSoftSerial library with this part of the module.

So my first Code Option was with AltSoft. But i don't recieve any data with my MG2639. When i played around i found out that if i plug the TX Port from an Ultimate GPS Modul from Adafruit to the RX Port of the MG2639 Module, i get the Coordinates over the Ultimate GPS Modul from Adafruit. But i think its not the idea to put two gps modules on a board:

#include <TinyGPS++.h>
#include <SFE_MG2639_CellShield.h>
TinyGPSPlus gps;

//RX=8 TX=9
#include <AltSoftSerial.h>
AltSoftSerial ss;

void setup()
{
  Serial.begin(9600);
  ss.begin(9600);
  Serial.println(F("Start:"));
}


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

}

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

btw., as soon i add int beginStatus = cell.begin(); to the code, the script doesn't give me any coordinates anymore, so i think there is a conflict with the ports between Software Serial&Cell Funktion and AltSoftSerial.

Next option:
I found an example from TinyGPS++, should it work with it?
If it set GPSBaud to 115200 i get at least an output:
Location: INVALID Date/Time: INVALID INVALID
with this code:

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

static const int RXPin = 8, TXPin = 9;
static const uint32_t GPSBaud = 115200;

// 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."));
    while(true);
  }
}

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

My Question is:

  1. What is the GPSBaud from MG2639 GPS: 4800 or 9600 or 115200?
  2. Can i only use AltSoftSerial or is there a way how it works with Software Serial?
  3. Is there any Test Script to test the GPS Modul for MG2639? I searched all Web an can not find any test script, just for GPRS.
  1. I don't get a Fix on the GPS Status Indicator LED (Already tried to change Shield, Cable and GPS Modul)

Are you inside? If the GPS does not have good reception of the satellites, it won't get a "fix". It may be sending data over the TX line, but most of the fields are probably empty. But...

  1. If i connect an Ultimate GPS Modul from Adafruit it works

... are you getting valid locations with this shield, from the same spot? The modules could have different sensitivities, so it's really best to test this outside. Try it for 10-20 minutes to see the the fix LED starts blinking.

Can i only use AltSoftSerial or is there a way how it works with Software Serial?

On pins 8 & 9, you should only use AltSoftSerial. On other pins, you can use NeoSWSerial (not needed here). SoftwareSerial is very inefficient and should never be used.

  1. Is there any Test Script to test the GPS Modul for MG2639? I searched all Web an can not find any test script, just for GPRS.

There is a diagnostic program described here that uses my library, NeoGPS. If you'd like to try it, change these lines at the top of NMEAdiagnostic.INO:

#if defined( UBRR1H )
  // Default is to use Serial1 when available.  You could also
  // use NeoHWSerial, especially if you want to handle GPS characters
  // in an Interrupt Service Routine.
  //#include <NeoHWSerial.h>
#else  
  // Only one serial port is available, uncomment one of the following:
  //#include <NeoICSerial.h>
  #include <AltSoftSerial.h>                <---- uncomment
  //#include <NeoSWSerial.h>                <---- comment out
  //#include <SoftwareSerial.h> /* NOT RECOMMENDED */
#endif
#include "GPSport.h"

It will try all baud rates and list what information is being received.

BTW, I have seen other people have problems with the GPS @ 115200 with AltSoftSerial. Too bad SparkFun set it that high. You might be able to send a configuration command to change the GPS baud rate to something more reliable. 38400 or 19200 would be much better:

ss.print( F("$PMTK251,38400*27\r\n") );
ss.end();
ss.begin( 38400 ); // change to match above command

Cheers,
/dev

Thank you for your fast answer:

Are you inside? If the GPS does not have good reception of the satellites, it won't get a "fix". It may be sending data over the TX line, but most of the fields are probably empty. But...

Yes we already tried it outside, different times, with different gps modules. We didn’t get the fix light for gps even after 30 minutes on the board.
With Adafruit we got a fix after 1 to 4 Minutes from the same spot.

I tried you Diagnostic Tool and got this:

NMEAdiagnostic.INO: started
Looking for GPS device on AltSoftSerial

____________________________

Checking 9600 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
0000003F00000000000000000000000000000000000000000000000000000000 ...?............................
0000000000000000000000000000000000000000000000000000000000000000 ................................
0000000000000000130000000000000000000000000000000000000000000000 ................................
0000000000000000000000000000000000000000000000000000000000000000 ................................
0000001300000000000000000000000000000000000000000020000000000000 ......................... ......
0000000000000000000000000000000000000000000000000000000000000000 ................................
0000000000000000000000000000000000000000000000000000000000000000 ................................
00000000000000000000000000000000000000000000000000FF             ..........................



Checking 14400 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
000000C6CA8C52000000000000000000870000004E0000000000000000000000 ......R.............N...........
0000000000000000000000000000000000000000000000000000000000000000 ................................
0000000000000000000000007300C70000006A000000C684DA00000000000084 ............s.....j.............
DA8A00FA                                                         ....

____________________________

Checking 19200 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
10420088004A0048000019008C00100000CE00004A00004A0000008D00100000 .B...J.H............J..J........
8A00008900000000CC00000000000800008A000048001A320000000041       ....................H..2....A

____________________________

Checking 28800 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
EE004A4200232B004A42004A008C005856005F00E8004A004A004A008A1AEE00 ..JB.#+.JB.J...XV._...J.J.J.....
4FC26A0A2100100B004B2A004A00CE624A0062CA5200F8                   O.j.!....K*.J..bJ.b.R..

____________________________

Checking 31250 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
56A3161B00363A00563B005C00A500467A00333244005E3A005E7AD288007600 V....6:.V;.\...Fz.32D.^:.^z...v.
1E5A00187A003A1A5E1A4E3A003E1B00561F640060003A00FA               .Z..z.:.^.N:.>..V.d.`.:..

____________________________

Checking 38400 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
A8002A00B1B0B894720062007000520052006200D151002900210C0072007200 ..*.....r.b.p.R.R.b..Q.).!..r.r.
720072009AD55100A9008871E0D351003B00B1B0B83074007200187062E26070 r.r...Q....q..Q.;....0t.r..pb.`p
00D20060F3                                                       ...`.

____________________________

Checking 57600 baud...
No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
2440020C292BAF29294A4A52524A6ECA0B4221312440020C6CA5A5A5A5A5A5A5 $@..)+.))JJRRJn..B!1$@..l.......
A5D6109400083062C484A746830182822929E92529A5184A4A25A9A929252D2B ......0b...F....)).%)..JJ%..)%-+
A9A56AB420F3                                                     ..j. .

____________________________

Checking 115200 baud...
Received RMC
Received GGA
Received GSA
Received GSV
Received GGA
Received GSA
Received GSV
Received GGA


**** NMEA sentence(s) detected!  ****
Received data:
24C7504747412C3030303130382E3830302C2C2C2C2C302C302C2C2C4D2C2C4D $.PGGA,000108.800,,,,,0,0,,,M,,M
2C2C2A34390D0A2447504753412C412C312C2C2C2C2C2C2C2C2C2CEC2C2C2C2C ,,*49..$GPGSA,A,1,,,,,,,,,,.,,,,
2A31450D0A2447504753562C312C312C3030EA37390D0A244750524D432C3030 *1E..$GPGSV,1,1,00.79..$GPRMC,00
303130382E3830302C562C2C2C2C2C302E30302C302E30302C3036303138302C 0108.800,V,,,,,0.00,0.00,060180,
2C2C4E2A34330D0A2447504747412C3030303130392E3830302C2C2C2C2C302C ,,N*43..$GPGGA,000109.800,,,,,0,
302C2C2C4D2C2C4D2C2C2A34380D0A2447504753412C412C312C2C2C2C2C2C2C 0,,,M,,M,,*48..$GPGSA,A,1,,,,,,,
2C2C2C2C2C2C2C2C2A31450D0A2447504753562C312C312C30302A37394321D2 ,,,,,,,,*1E..$GPGSV,1,1,00*79C!.
1425D50DB13030303130392E3830302C562C2C2C2C2C302E30302C302E30302C .%...000109.800,V,,,,,0.00,0.00,

Device baud rate is 115200

GPS data fields received:

  Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,
  0,2080-01-06 00:01:11.80,,,0,0,,0,8,1,2087,

** NMEAdiagnostic completed **

I tried it then a second time and got as well this note:

GPS data fields received:

  Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,
  0,2000-01-01 00:07:03.80,,,,,,0,8,0,2041,

Warning: LAST_SENTENCE_IN_INTERVAL defined to be RMC, but was never received.
  Please use NMEAorder.ino to determine which sentences your GPS device sends, and then
  use the last one for the definition in NMEAGPS_cfg.h.

** NMEAdiagnostic completed **

1 warnings

With NMEAorder and the baut rate changed to 115200 i got this

NMEAGPS object siNMEAorder.INO: started
fix object size = 31
NMEAGPS object size = 84
Looking for GPS device on AltSoftSerial
......
Sentence order in each 1-second interval:
  GSA
  GSV
  RMC

If i try to add: ss.write( F("$PMTK251,38400*27\r\n") );
to my program i postet last time i get following error:

exit status 1
invalid conversion from 'const __FlashStringHelper*' to 'uint8_t {aka unsigned char}' [-fpermissive]

So for my program with AltSoft i still get just the following output with Arduino :frowning:

Location: INVALID  Date/Time: 1/6/2080 20:46:46.08
Location: INVALID  Date/Time: 1/6/2080 20:46:47.08
Location: INVALID  Date/Time: 1/6/2080 20:46:47.08
…

If i try to add "ss.write" to my program i posted last time i get following error...

invalid conversion from 'const __FlashStringHelper*' to 'uint8_t

Sorry, that should have been print, not write.

ss.print( F("$PMTK251,38400*27\r\n") );
ss.end();
ss.begin( 38400 ); // change to match above command

I corrected my earlier post.

From the NeoGPS programs, it looks like the GPS baud rate is 115200 and it is sending 3 sentences, ending with an RMC. It is getting some errors, so the 115200 baud rate is definitely too high. That's why NMEAdiagnostic didn't see the RMC one time.

The next NeoGPS program to try is NMEA.ino, with the following changes:

1) Uncomment the include of AltSoftSerial (comment out NeoSWSerial).

2) Add the same code to NMEA.ino to change the baud rate, but using the gps_port variable:

  // Start the UART for the GPS device
  gps_port.begin( 115200 );  // just for a little bit...
gps_port.print( F("$PMTK251,38400*27\r\n") );
gps_port.flush(); // make sure the command gets out
gps_port.end(); // change baud
gps_port.begin( 38400 );

I think that will make NMEA.ino work, but it will still print empty fields, because...

The GPS device is not receiving any satellites. The time is a default value, and all the other fields are empty. NMEAdiagnostic shows the raw data, and it confirms that the antenna, antenna cable or GPS device is not working.

Sorry,
/dev

Hello,

at the moment I'm also struggeling with the gps of the mg2639.

First I tried the NMEAdiagnostic.ino and it gave me 115200 as the matching baudrate for the gps. So far nothing new.

Then I used the NMEA.ino with:

gpsPort.begin( 115200 );

gpsPort.print( F("$PMTK251,38400*27\r\n") );
gpsPort.flush(); // make sure the command gets out
gpsPort.end(); // change baud
gpsPort.begin( 38400 );

But I just get this in the serial monitor:

NMEA.INO: started
fix object size = 31
gps object size = 84
Looking for GPS device on AltSoftSerial( RX pin -1, TX pin -1 )

GPS quiet time is assumed to begin after a RMC sentence is received.
You should confirm this with NMEAorder.ino

Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,

Nothing happens after that. If I change back to the 115200 baud, I'll get blank messages with the timestamps.

NMEA.INO: started
fix object size = 31
gps object size = 84
Looking for GPS device on AltSoftSerial( RX pin -1, TX pin -1 )

GPS quiet time is assumed to begin after a RMC sentence is received.
You should confirm this with NMEAorder.ino

Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,
0,2080-01-06 01:23:38.800,,,0,0,,0,4,0,134,
0,2080-01-06 01:23:40.800,,,0,0,,0,11,0,406,
0,2080-01-06 01:23:41.800,,,0,0,,0,15,0,542,
0,2080-01-06 01:23:42.800,,,0,0,,0,18,0,677,

So I tried to trick the NMEAdiagnostic a bit. In the setup I've added the command for changing the baudrate to 38400 in the beginning of the programm.

void setup()
{
DEBUG_PORT.begin(9600);
while (!DEBUG_PORT)
;
gpsPort.begin( 115200 );
gpsPort.print( F("$PMTK251,38400*27\r\n") );
gpsPort.flush(); // make sure the command gets out
gpsPort.end(); // change baud

DEBUG_PORT.print( F("NMEAdiagnostic.INO: started\n") );
DEBUG_PORT.println( F("Looking for GPS device on " GPS_PORT_NAME) );

if (sizeof(gps_fix) <= 2) {
warnings++;
DEBUG_PORT.print( F("\nWarning: no fields are enabled in GPSfix_cfg.h.\n Only the following information will be displayed:\n ") );
trace_header( DEBUG_PORT );
}

#if !defined( NMEAGPS_PARSE_GGA ) & !defined( NMEAGPS_PARSE_GLL ) &
!defined( NMEAGPS_PARSE_GSA ) & !defined( NMEAGPS_PARSE_GSV ) &
!defined( NMEAGPS_PARSE_RMC ) & !defined( NMEAGPS_PARSE_VTG ) &
!defined( NMEAGPS_PARSE_ZDA ) & !defined( NMEAGPS_PARSE_GST )
warnings++;
DEBUG_PORT.println( F("\nWarning: no messages are enabled for parsing in NMEAGPS_cfg.h.\n No fields will be valid, including the 'status' field.") );
#endif

DEBUG_PORT.flush();

tryBaud();

} // setup

I've expected that the diagnostic tool would find the correct baud at 38400 but it is still 115200. Am I missing something?

hoffma0901

I've expected that the diagnostic tool would find the correct baud at 38400 but it is still 115200. Am I missing something?

Either the GPS does not receive the command correctly, or it refuses the command.

Try sending other MTK commands, like changing which sentences it sends. Try a few of these and see if it obeys:

gpsPort.print( F("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29") ); // RMC and GGA
gpsPort.print( F("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28") ); // RMC only
gpsPort.print( F("$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28") ); // everything

If it doesn't obey those commands, it is not receiving them correctly. I would guess that the AltSoftSerial timing is not quite good enough for it to work.

If it does obey those commands, the Arduino TX to GPS RX is working correctly, and is at the correct baud rate. In which case, this sentence from the product page is ominous:

The GPS UART is hard-coded to 115200 baud, which make it harder to use with SoftwareSerial.

So... you may not be able to change the GPS baud rate.

On one hand, it's good that the shield uses AltSoftSerial, the best alternative to a HardwareSerial port. OTOH, it's bad that the default GPS baud rate is 115200. Software serial ports are not reliable at those speeds.

If you're up to some hardware hacking, I would suggest jumpering from 8/9 to 0/1. That would let you use Serial for the gpsPort. It will work reliably at 115200, but you'll have to disconnect pin 0 to upload new sketches. If you want to solder that wire in, put a switch in series so it's easy to upload.

If this lets you change the baud rate to 38400, then it was an AltSoftSerial reliability problem.

If the baud rate still does not change, then the GPS device baud rate is truly "hard-coded".