ADAFRUIT GPS programming

Hello all,
i got adafruit GPS breakout board that i need to program with out a library!
i can receive data from it with no problems.
but how can i send commands to it so i can control things like baud rate, NMEA type and other!

here is my code:

#include <SoftwareSerial.h>

SoftwareSerial GPSModule(8, 7);
SoftwareSerial HC12(10, 11);

bool x = 0;
String GPRMC_Rcvd = "";

void setup()
{
HC12.begin(9600);
GPSModule.begin(9600);

GPSModule.print("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); //this command to tell the chip to send only RMC NMEA senetence
HC12.println("");
HC12.println("START");
delay(2000);
}

void loop()
{
while (GPSModule.available() > 0) // if While here affect IR Recieveing proccess find a way to use IF
{
GPSModule.read();
x = 1;
}

if(x == 1)
{
  GPRMC_Rcvd = GPSModule.readStringUntil('\n');
  HC12.println(GPRMC_Rcvd);
  x = 0;
}

}

just use GPSModule.write() and/or GPSModule.print() and send what's required based on the specification of the module

having 2 SoftwareSerial is usually calling for trouble if you need to read and write at the same time... get an Arduino Mega or a board with more Hardware Serial ports

I cannot see how using two instances of softeware serial in that way, reading from one and transmitting the received character to another will work.

So did the program work ?

my point was (as written) if the intent is read and write at the same time.

It would usually work, I would say you need to complete the sentence: will work... if the volume of data received and sent stays reasonable
at 9600 bauds you lock up interrupts for quite some time, so if you do that twice for receiving and sending, you might get into trouble.

also it looks like OP wants to broadcast the NMEA sentence, the role of the arduino is quite limited... I would just configure once the GPS to only emit the RMC NMEA sentence and connect the HC-12 pre-configured with the right settings to the GPS directly... no arduino, no code to maintain, less power consumption...

It worked, the thing that GPS needs time to load up,
i gave it a delay of 2000 and it worked,
here is the modified version:

#include <SoftwareSerial.h>

SoftwareSerial GPSModule(8, 7);
SoftwareSerial HC12(10, 11);

bool x = 0;
String GPRMC_Rcvd = "";

void setup()
{
HC12.begin(9600);
GPSModule.begin(9600);

HC12.println("");
HC12.println("START");

delay(2000); //GPS needs some time to start correctly, so add a DELAY before at least 1000
GPSModule.println("$PGCMD,33,06D"); delay(50); //Turn off antenna update data
GPSModule.println("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
29"); delay(50); //Request GPRMC and RMCGGA Sentences only
GPSModule.println("$PMTK220,10001F"); delay(50); //Set Refresh Rate @ 1Hz
//GPSModule.println("$PMTK251,57600
2C"); delay(50); //Set Baud Rate @ 57600, though 9600 gives best result

//GPSModule.end();
//GPSModule.begin(57600);
}

void loop()
{

while (GPSModule.available() > 0) // if While here affect IR Recieveing proccess find a way to use IF
{
  GPSModule.read();
  x = 1;                
} 

if(x == 1)
{
  GPRMC_Rcvd = GPSModule.readStringUntil('\n');
  HC12.println(GPRMC_Rcvd);
  x = 0;
}

}

glad you got it to work but this looks highly suspicious in the loop...

while (GPSModule.available() > 0) // if While here affect IR Recieveing proccess find a way to use IF
{
  GPSModule.read();
  x = 1;                
} 

please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's unreadable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)

You may run into problems with Serial.prints() interfering with the GPS data reads, particularly if you add debug statements
See my tutorial on Arduino Serial I/O for the Real World which includes a detailed GPS read/parse example.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.