Problem reading serial data

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:

#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

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

-br

billroy:
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

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

Sounds similar to this post:

-br

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

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

billroy:
Sounds similar to this post:

Compiler freezes with no erorrs, changes since last compile remove - #5 by Apothus - Programming Questions - Arduino Forum

-br

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

-Steve

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

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

Best,

-br

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

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

-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.

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

-Steve

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

-br