Pages: [1]   Go Down
Author Topic: Problem reading serial data  (Read 682 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-br
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds similar to this post:

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

-br
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

-Steve
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Best,

-br
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-br
Logged

Pages: [1]   Go Up
Jump to: