Go Down

Topic: Problem reading serial data (Read 890 times) previous topic - next topic

Steve Meuse

I have a strange problem, I hope I'm just missing something simple. I have a GPS unit that spits out NMEA data at 4800 baud, N-8-1. I have no problem reading the data on a PC running Putty:

 
and


I've made several attempt to read the data but each time I end up with garbage input.



I've tried different combinations of baud rates, but nothing seems to change the fact that I'm not getting valid input. I've tried several pairs of input pins, etc.

Here is some sample code that I was most recently using, but other example sketches also failed:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4,5);

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


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


I'm hoping it's just something simple that I'm missing. I've searched the forums, but haven't found anything relevant.

-Steve


billroy

Try Serial.begin(4800) in the arduino program.  The baud rates have to match or you get garbage like that.

-br

Steve Meuse


Try Serial.begin(4800) in the arduino program.  The baud rates have to match or you get garbage like that.

-br



Didn't do anything. I had tried that previously...



-Steve

billroy

Looks like it should work.  Might help to know a little more about the hardware setup.   What kind of electrical output does the GPS have (RS-232, 5V TTL serial, or 3.3V TTL serial), and how do you have it connected?

-br

billroy

Sounds similar to this post:

http://arduino.cc/forum/index.php/topic,135973.msg1022262.html#msg1022262

-br

Steve Meuse


Looks like it should work.  Might help to know a little more about the hardware setup.   What kind of electrical output does the GPS have (RS-232, 5V TTL serial, or 3.3V TTL serial), and how do you have it connected?

-br



Basically just TX out of the GPS going to to RX in on the Arduinio Duemilenove, plus ground. I tried lifting ground, thinking maybe there was a loop issue, but nothing changed.

Standard rs-232. If I'm reading the docs correctly, I don't need hardware ttl/rs-232 decoding using softserial, correct?

-Steve




Steve Meuse


Sounds similar to this post:

http://arduino.cc/forum/index.php/topic,135973.msg1022262.html#msg1022262

-br



I'm not sure I follow. The compiler works fine?

-Steve

billroy

Voltage is voltage, yes?  Standard RS-232 is +/- 12 volts and extremely toxic to Arduino inputs, which are rated 0-5V max.  You need level shifting.  Search the forums, this is a well-worked topic.

It's possible you have damaged the inputs on your Arduino, but you might have gotten lucky.  If you see weird results once you've resolved the voltage level situation, try moving to other pins.

Good luck!

-br

billroy

Sorry, the compiler comment was intended for another thread.  Need coffee.

Best,

-br

Steve Meuse


Voltage is voltage, yes?  Standard RS-232 is +/- 12 volts and extremely toxic to Arduino inputs, which are rated 0-5V max.  You need level shifting.  Search the forums, this is a well-worked topic.

It's possible you have damaged the inputs on your Arduino, but you might have gotten lucky.  If you see weird results once you've resolved the voltage level situation, try moving to other pins.

Good luck!

-br



Ahh, ok, so I did misunderstand! BAH! Thank you....I wasn't thinking this one through. I should have known that.....

-Steve

Steve Meuse


Voltage is voltage, yes?  Standard RS-232 is +/- 12 volts and extremely toxic to Arduino inputs, which are rated 0-5V max.  You need level shifting.  Search the forums, this is a well-worked topic.



Today is my lucky day, I just found a max232 in the parts bin!

-Steve

billroy

You have a good parts bin.  Let us know how it turns out.

-br

Go Up