Hi all,
I have just got a arduino, they are fantastic! But i have encountered a problem.
I want to send NMEA data from my gps into the serial(usb) so i can read it on the screen, once i have done that i will hook it up to a radio for wireless transmission!!
But i cannot get it to Serial print a string (the nmea string)? It only prints numbers, argh!
How do i go about reading a string from the serial rx?
Many Thanks, help would be much appreciated,
Adam ;D
There are a couple of in depth projects that work with GPS data, and can parse the NMEA sentences. Even if you don't use the projects, they should give you an idea of how to work with the data.
TinyGPS is a lib for retrieving data from the sentences TinyGPS | Arduiniana and has a good sample.
Ladyada.net has a couple of samples that go with the GPS logging shield. I'm pretty sure that one of them just streams the data from the GPS to the serial port.
GPS datalogging shield for Arduino Use the menu on the right to navigate through the different sections and find the code.
thanks for the reply,
I have searched the pages but still could not find an answer. Is there just a way to print out all the data received through the serial?
Is there just a way to print out all the data received through the serial?
Yes. Can you post your code?
I think that you may be looking for something like this:
void loop(){
char c;
c = Serial.read(); // read one character from the serial
Serial.print(c, BYTE); //write one character to the serial, as ascii byte
}
this reads the data from my GPS on serial (on pins 0/1), and prints the characters directly to the serial port. I see raw NMEA strings in the serial monitor.
Also take a look at :Serial.print() - Arduino Reference
The BYTE argument is not needed if the type being printed is char or byte. The following should provide the same output as the code posted above
char c ;
c = Serial.read();
Serial.print (c) ;
However if c is an int then the BYTE form posted above is needed so it probably makes sense to use that form in any case where the rawl 8 bit value is desired.
Good point, I threw that together quickly.
Thanks everyone,
This is the code i am now using:
void setup() {
Serial.begin(4800);
}
void loop(){
char c;
c = Serial.read();
Serial.print(c);
}
When i listen in though it just looks all gobbledygutch! :o Would i have to decode this data to read NMEA?
Thanks
if you want to decode the NMEA sentences, I highly recommend the TinyGPS library mentioned in reply#1. If you want to learn how to decode them, have alook at that libarys source code
you should be seeing something like this:
$GPGRMC,211420.565,A,4042.3932,N,07400.4680,W,,260608,,*19
as mem pointed out, the tinyGPS lib does a good job of parsing through functions.
This sketch: http://www.ladyada.net/make/gpsshield/GPStest_RMC.pde shows how to parse the sentence as well.
For general GPS knowledge, there are a lot of good links here GPS datalogging shield for Arduino.
Hi everyone,
Thanks for the replies. There must be a problem because i am not seeing the NMEA sentences!
I have checked the baud rates and they are all set at 4800 and the garmin is outputting NMEA at 4800?
Strange!
Any thoughts?
Thanks
It would be easer to help if you posted the output you are getting.
A lesson I learned the hard way...
Cuddy, (as in Cabin?)
your problem is you are trying to read rs232 with a TTL device
The gods can give you the blow by blow but suffice to say what your GPS is spitting out is not what arduino expects as serial. baud is not the issue the voltage is.
You need the trusty MAX232 chip and som capacitors...
(one normal post...)
...(continued with links)
Get one of these...
//http://www.nkcelectronics.com/rs232-to-ttl-5v-converter.html
and read up on it here:
Beginning Embedded Electronics - 4 - SparkFun Electronics
hope this helps... I went crazy until I was enlightend with these very links... cheap fix..less than $10 solder up yourself for 5
Road