PMODGPS Update Rate from 1 to 10 Hz

Hi All,

I am using a PMODGPS with an Arduino Mega, to make a follow me robot. I have a transmitter code and receiver code using the NeoGPS library. We're almost done with the integration of the whole project, but I would like to somehow increase the update rate of the both GPS receivers. By default, they're at 1 hz and this works fine, but its not as reliable. I tried looking online and I found neogps code to update rate for Ublox, but not for any other general GPS. I'm not too good at this so I'm not really sure how to go along with this.

I'm using ultrasonic sensors and an XBee, but I don't think that's relevant to what I'm asking. I thought I'd give out as much information so get people started.

If anyone could help me increase the update rate of the GPS from 1 Hz to anything above that (max 10Hz) that would be great.

High Regards

Transmitter code:

#include <NMEAGPS.h>

NMEAGPS gps;
gps_fix fix;

#define gpsPort Serial1

void setup()
{
  Serial.begin(9600);
  gpsPort.begin( 9600 );
  gps.send_P( &gpsPort, F("PMTK220,200") ); //set update rate to 5Hz set update rate to 5Hz (added this while trying various 
                                            //codes)
  
//  Might be needed:
//
//  #define RSTpin    37 //pin 37, JE-08
//  pinMode(RST, OUTPUT);
//  digitalWrite(RST, LOW);
}

void loop()
{

  if (gps.available( gpsPort )) 
  {
    fix = gps.read();
    
    if (fix.valid.satellites) 
    {
      Serial.print( fix.satellites );
    }
    Serial.print(',');

    if (fix.valid.location)
      Serial.print( fix.latitude(), 6 );
      Serial.print(',');

    if (fix.valid.location)
      Serial.print( fix.longitude(), 6 );

    Serial.println();

  }
}

I'll post the receiver code in the next post as I've exceeded the char limit.

Right I can't paste the code here so I'll attach it. Apologies for making two posts:

TrolleyReceiveTest.ino (8.58 KB)

Some devices will not allow you to set an update rate that is too high for the baud rate. Try setting the GPS baud rate to 19200 or 38400:

  gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA
  delay( 100 );
  gps.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status messages needed
  delay( 100 );
  gps.send_P( &gps_port, F("PMTK251,19200") );  // set baud rate
  gps_port.flush();                              // wait for the command to go out
  delay( 100 );                                  // wait for the GPS device to change speeds
  gps_port.end();                                // empty the input buffer, too
  gps_port.begin( 19200 );                      // use the new baud rate

  gps.send_P( &gps_port, F("PMTK220,200") );     // set the GPS update interval

(Excerpt from this thread)

Have you read the Digilent datasheet?

The command for changing the data acquisition from 1Hz to 10Hz
is:
“$PMTK226,3,30*4”

Pete

-dev:
Some devices will not allow you to set an update rate that is too high for the baud rate. Try setting the GPS baud rate to 19200 or 38400:

  gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA

delay( 100 );
  gps.send_P( &gpsPort, F("PGCMD,33,0") );  // No antenna status messages needed
  delay( 100 );
  gps.send_P( &gps_port, F("PMTK251,19200") );  // set baud rate
  gps_port.flush();                              // wait for the command to go out
  delay( 100 );                                  // wait for the GPS device to change speeds
  gps_port.end();                                // empty the input buffer, too
  gps_port.begin( 19200 );                      // use the new baud rate

gps.send_P( &gps_port, F("PMTK220,200") );    // set the GPS update interval





(Excerpt from [this thread](http://forum.arduino.cc/index.php?topic=515350.msg3516862#msg3516862))

Thanks for the reply. Could you please help me understand this a bit more? I just got to work so I'll try using the code, but kind of unsure where to put it and what PMTK and other stuff is doing.

el_supremo:
Have you read the Digilent datasheet?
Pete

Yeah, I saw this but I couldn't make sense out of it. Could you please explain a bit as to how its supposed to work?

High Regards

-dev:
Some devices will not allow you to set an update rate that is too high for the baud rate. Try setting the GPS baud rate to 19200 or 38400:

  gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA

delay( 100 );
 gps.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status messages needed
 delay( 100 );
 gps.send_P( &gps_port, F("PMTK251,19200") );  // set baud rate
 gps_port.flush();                              // wait for the command to go out
 delay( 100 );                                  // wait for the GPS device to change speeds
 gps_port.end();                                // empty the input buffer, too
 gps_port.begin( 19200 );                      // use the new baud rate

gps.send_P( &gps_port, F("PMTK220,200") );     // set the GPS update interval




(Excerpt from [this thread](http://forum.arduino.cc/index.php?topic=515350.msg3516862#msg3516862))

I tried putting your code in my transmitters code void setup loop, but it has stopped giving any serial monitor data. I changed the baud rate on the serial monitor and tried messing around with it, but it doesn't seem to do much. Any ideas?

Thanks

I tried putting your code in my transmitters code void setup loop,

I'm not sure what that means...

The code snippet I provided should go in the setup routine:

void setup()
{
  Serial.begin(9600);
  Serial.println("Start");
  
  gpsPort.begin( 9600 );
  gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA
  delay( 100 );
  gps.send_P( &gpsPort, F("PGCMD,33,0") );     // No antenna status messages needed
  delay( 100 );
  gps.send_P( &gps_port, F("PMTK251,19200") ); // set baud rate
  gps_port.flush();                            // wait for the command to go out
  delay( 100 );                                // wait for the GPS device to change speeds
  gps_port.end();                              // empty the input buffer, too
  gps_port.begin( 19200 );                     // use the new baud rate

  gps.send_P( &gps_port, F("PMTK220,200") );   // set the GPS update interval

  //set all motor pins to output
  pinMode(DriveF, OUTPUT);
  pinMode(DriveB, OUTPUT);
  pinMode(SteerR, OUTPUT);
  pinMode(SteerL, OUTPUT);
  pinMode(SWITCH, INPUT);

  mag.begin();

}

Could you please help me understand this a bit more?

The GPS device sends NMEA sentences to the Arduino. The Arduino parses them (with NeoGPS) to get various GPS data members (lat, lon, alt, etc.).

The Arduino can send configuration commands to the GPS. The GPS device parses them to set various modes of its own operation:

* which sentences it should send (RMC and GGA only),

* whether it should send antenna status sentences to the Arduino (NO),

* what baud rate it should use (19200, not the default 9600),

* how often it should send sentences (5 times per second = 200ms interval between updates).

I hoped the comments after each send_P would describe that.

You might try 2Hz update first. Change that last command to have 500 instead of 200.

I changed the baud rate on the serial monitor and tried messing around with it, but it doesn't seem to do much.

These commands were supposed to change the baud rate of the Arduino-GPS link (the Serial2 variable). They have nothing to do with the Serial Monitor speed (i.e., Arduino-PC link, via the Serial variable).

If you still cannot get any data from the GPS device, try the NMEAdiagnostic.ino example. You must the edit the GPSport.h file to use your Serial2 port:

#ifndef GPSport_h
#define GPSport_h

#define gpsPort Serial2
#define GPS_PORT_NAME "Serial2"
#define DEBUG_PORT Serial

#endif

That is the entire file. Delete everything else.

Have you read the Digilent datasheet?
Pete

Yeah, I saw this but I couldn't make sense out of it. Could you please explain a bit as to how its supposed to work?

The Digilent GPS module uses the MediaTek 3329 chip. If you look for the "Output Sentences", you will see that it can send RMC, GGA, GSA, GSV and VTG sentences. Your code sends a command that makes it send only RMC and GGA.

The Digilent PMod spec says to see the MediatTek PMTK command spec for the configuration commands you can send to the GPS device.

The MediaTek PMTK documentation says that a PMTK251 command can be used to change the baud rate, and a PMTK220 command can be used to change the update interval.

El_supremo points out that the Digilent document says that a PMTK226 command can be used to change the baud rate. I can find no other documents that list a PMTK226 command. The "3,30" parameters don't seem related to 10Hz, so that's a little confusing, too. You could try sending "PMTK226,3,30" instead of "PMTK251,500", but I'm a little skeptical. I think "PMTK251" is the correct command.

1 Like

Good afternoon. I have a doubt specialized in this topic. I appreciate if someone can answer.

I'll explain first what I want to do:
I want to connect an ublox module with its maximum update rate 18 hz and 10 hz (Max-m8q or 6m) to the arduino or to a stm32 to filter the nmea sentences (GN-GP) and transmit via bluetooth to another device.

My doubts:
What is the best bluetooth module? HC-06 HC-05 RN42?

How to choose the best baud rate so you don't have to miss packages?