Hey. So I just recently bought a Parallax GPS and and Arduino Mega2560 to do one of my projects. Right now I am trying to get the basic GPS readout from the serial monitor. However when I run the code I am using, all I get on the serial monitor is just the letter "y" repeated. Does anyone have a clue what might be going on? Any help is appreciated. I am using the simple code below:
So I switched pins so my code reads:
SoftwareSerial GPS = SoftwareSerial (2,3)
but it still comes up with a repeated "y" in the serial monitor. Should I use another command besides the SoftwareSerial function? Maybe something like a hardware interface function. I'm open to any ideas.
Is the convention with Software Serial that different from using the UART?
I successfully wrote a programme recently to read a GPS and store the results in an array.
I think that you have to check for Serial.available each time? id est:
So that's what that character was. That makes sense then. The whole point behind this simple code was to see if I could get the gps data to appear on my serial monitor. It was a simple test before I got into more complex coding. This simple code actually comes from watching a youtube video at this link - YouTube. I'm a beginner at this and I knew that this arduino has hardware ports. If the easier route is to use those, then could someone briefly tell me how? Thanks.
If you are only going to use one serial port, why not use Serial? I thought you want to read from the GPS and print/write to the PC.
If you are getting ASCII data from the GPS, why are you sending binary data? Why are you sending the GPS data back to the GPS? It already knows what it sent.
I do want to read from the GPS and print/write to the PC. I'm a complete novice at stuff like this and I was just following an example. I guess I am just confused on how to write the code to complete such a task.
You have 4 "phones" labeled Serial, Serial1, Serial2, and Serial3. You want the GPS to call you on one "phone" and you want to talk to the PC on another "phone".
The only "phone" that can talk to the serial port on the PC is the one labeled Serial.
It really isn't rocket surgery to figure out what "phone" the GPS has to be connected to, pin wise, and what "phone" you use to talk to it.
I wrote this for use with a 328P - GPS output to D0. I think it'll work with your Mega, too. (If the Megas don't have the D13 LED then you can comment those lines out.)
My only interest was the RMC sentence, specifically the time characters.
The following captures the time characters, and knocks the seconds characters back out to Serial Monitor.
Kindly let me know how you fare.
// serialexper05
// trying to trigger event resulting from successful
// capture of $GPRMC header
// trying to capture seconds i.e. -- bytes 11,12
// and print them out works 03/08/2012
byte serial_idx;
byte GPSchar [13];
byte GPSchk [7] = {36,71,80,82,77,67,44};
// $ G P R M C ,
void setup()
{
Serial.begin(4800);
pinMode(13, OUTPUT);
}
void loop() // wait for $GPRMC,
{
while (serial_idx < 7)
{
if(Serial.available() > 0)
{
GPSchar[serial_idx] = Serial.read();
if(GPSchar[serial_idx] == GPSchk[serial_idx])
{
serial_idx++;
}
else
{
serial_idx = 0; //
}
}
}
while (serial_idx < 13) // loop - capture hhmmss bytes
// GPSchar[07]..[12]
{
if(Serial.available() > 0)
{
GPSchar[serial_idx] = Serial.read();
serial_idx++;
}
}
successblink();
}
void successblink() // may leave unused
{
digitalWrite(13, HIGH);
delay(75);
digitalWrite(13, LOW);
Serial.print(GPSchar[11],DEC);
Serial.print(" ");
Serial.println(GPSchar[12],DEC);
for (int ax=0; ax<13; ax++) //clear GPSchar array
{
GPSchar[ax]=0;
}
serial_idx = 0;
}
So I've tried your code, and other codes, and nothing really seems to be working. At some points it seems like the above code is working because LED 13 is blinking, but whenever I pull up the serial monitor, LED 13 goes solid and nothing appears on the serial monitor. In general, the GPS LED is a solid red but whenever I try to get information out of it, it always fails. I'm at a lost at what to do. It might be a problem with the GPS TX cable or with something in the software. Does anyone have any suggestions?
My only connections are GPS output [yellow wire from its supplied lead dress] to Arduino "D0" (and, of course, their Ground/common together.) Is D0 = RX on the Mega, too?
When I power up the arduino without the serial monitor it still goes, but when I push the Serial Monitor button in the IDE it resets the arduino, and then it's off to the races (data out each second).
And I do not have the GPS input (its blue wire) connected to D1.
I set it up again here on the bench, before posting just now, and it runs along without a hitch. One thing is, though, the output is the Decimal value of the ASCII code for the seconds digits (e.g. "48 48" for secs = 00, "48 57" for secs = 09).
*** The Arduino is running off the USB but the GPS is on a separate 5V. ***