Go Down

Topic: Changing GPS Baud Rate with minimal NMEAGPS and GPSPort (Read 205 times) previous topic - next topic

PalmerEng4

I currently have an Uno project that requires my GPS module (Adafruit GPS Shield) to run at 57600 baud.

As every time the Arduino is un-powered it resets back to 9600 (pretty sure it doesn't have an EEPROM), I have been using this code (edited from something courtesy of adafruit_support_rick) to turn it back to 57600;

Code: [Select]
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);

void setup() 
{
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
//  GPS.sendCommand(PMTK_SET_BAUD_115200);  //set baud rate to 115200 hopefully!
  GPS.sendCommand("$PMTK251,57600*2C");  //set baud rate to 57600
//  GPS.sendCommand(PMTK_SET_BAUD_57600);  //set baud rate to 57600
//  GPS.sendCommand("$PMTK2u51,38400*27");  //set baud rarte to 38400
//  GPS.sendCommand("$PMTK251,19200*22");  //set baud rate to 19200
//  GPS.sendCommand("$PMTK251,9600*17");  //set baud rate to 9600
  mySerial.end();
  delay(500);
  GPS.begin(57600);
}

void loop(){
 
}


I'd like to put the baud change code into the setup of my actual code though, and I'm unsure how to do so with different library's to those above.

How could I change the baud rate using just NMEAGPS.h and GPSPort.h?

Thank you in advance.

----------------------------------

EDIT: In the GPSPort header it defaults to using AltSoftSerial, which are pins 8 and 9 on the Uno. The GPS shield is set to using 7 and 8 when on soft serial mode... In testing I have had them working together at 9600, I don't understand how two different sets of rx ant tx pins can communicate?

J-M-L

I'd like to put the baud change code into the setup of my actual code though, and I'm unsure how to do so with different library's to those above.
just as it is, get rid of the commented lines as they are useless and confusing

----

EDIT - misread what you said.

you basically need to open up a Serial port set up at 9600 bauds, send the $PMTK251,57600*2C command to your device, then terminate the connexion and reopen at 57600
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

PaulS

Quote
How could I change the baud rate using just NMEAGPS.h and GPSPort.h?
The NMEAGPS header file defines a class that knows how to read data from, and parse the data from, some specified stream. By itself, you can not do anything to set up the stream.

The GPSPort header file is a complete mystery, since you failed to post a link.

But, it is unlikely that you can make the header file do anything to make the GPS output data at a different baud rate. YOU will need to write the code to call the appropriate methods, to do that.
The art of getting good answers lies in asking good questions.

PalmerEng4

The NMEAGPS header file defines a class that knows how to read data from, and parse the data from, some specified stream. By itself, you can not do anything to set up the stream.

The GPSPort header file is a complete mystery, since you failed to post a link.

But, it is unlikely that you can make the header file do anything to make the GPS output data at a different baud rate. YOU will need to write the code to call the appropriate methods, to do that.
I didn't think to link the library sorry; here it is.

PalmerEng4

just as it is, get rid of the commented lines as they are useless and confusing

----

EDIT - misread what you said.

you basically need to open up a Serial port set up at 9600 bauds, send the $PMTK251,57600*2C command to your device, then terminate the connexion and reopen at 57600
I've tried this;

Code: [Select]

#include <NMEAGPS.h>
#include <GPSPort.h>

NMEAGPS gps;

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

  gps.send_P( &gpsPort, F("$PMTK251,57600*2C") );

  delay(200);
 
  gpsPort.begin(57600);

}

void loop()
{
 
}


but it still stays at 9600...

Have I made any obvious mistakes? Thanks.

PalmerEng4

Also tried this code;


Code: [Select]
#include <NMEAGPS.h>
#include <GPSPort.h>

NMEAGPS gps;

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

  gpsPort.print("$PMTK251,57600*2C");

  gpsPort.end();

  delay(500);
 
  gpsPort.begin(57600);

}

void loop()
{
 
}


but no joy...

wildbill


PalmerEng4

How did you test it?
I've been checking the current baud rate with the "NMEAdiagnostic" example code. Tried to post it here but it exceeds the character length sorry, it runs through each normal baud rate checking which it is.

As above, when the unit (just the Uno with the GPS shield) is powered the baud is at 9600. I still have to use the code in the original post to change it.

When I'm testing new code like those in the replies, I will upload it, wait a second just in case, then upload the diagnostic program to check the baud.

Go Up