NMEA serial write problem

Hello!

i hooked up a gps to my arduino to be able to logg the NMEA signal. after hours of trying, i pushed down the reset button on the arduino and suddenly the nmea came inn! but when i release the button and the arduino boots up, it all goes blank. below you see the setup, and i cant se any reason for it not to be able to read it. when i press and hold reset it all works.

void setup() { Serial.begin(9600); }

void loop() { if(Serial.available() > 0 ) { Serial.write(Serial.read()); } }

any advice would be grate!

Several problems with that code. First, GPS send character (ASCII) data. The Serial.write() function sends binary data. It is not the correct function to use to send ASCII data. Why are you using it?

Second, the GPS know what data it sent you. Why are you echoing the data back to the GPS?

If you want to read data from the GPS and send it to the Serial Monitor, you need two serial ports. If you do not have a Mega, the GPS should be connected to two other pins, and you should be using NewSoftSerial (0023 or earlier) or SoftwareSerial(1,0+) to connect to those two pins.

Finally, very few GPS actually use 9600 baud.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(3,4); // signal på pin 3

void setup()
{
Serial.begin(115200); // seriell-monotoren skal ha 115200 baud
Serial.println(“Test linje, dette skal komme før alt”); //sjekk når du starter hele greiene
mySerial.begin(9600); //serieport for gps-en
}

void loop()
{
if(mySerial.available() > 0)
{
Serial.write(mySerial.read());
}
}

got it to work :slight_smile: thanks for the reply:)

SoftwareSerial mySerial(3,4); // signal på pin 3

Did you connect a mySerial to these pins? Why not give the instance a meaningful name? Like, I don't know maybe Fred. Or even, gps.

    Serial.write(mySerial.read());

Why? You aren't sending binary data anywhere.

well! the answer to your questions there are the fact that i´m really new to arduino:P i have a friend who helps me with the coding, and we will look over it tomorrow, and correct the wrongs. what we are trying to make, is a logger to show us the NMEA sentances on a lcd screen. not the coordinats, but the sentences :) will come back with more info tomorrow, and probably alott more questions :P

thanks :)