Go Down

Topic: Problem getting SoftwareSerial to work (Read 1 time) previous topic - next topic


Hello All

I have just started on a serial communication project and have an issue which I need some help with. Most likely it is at a fundamental level.

My platform is - Eleven (100% Arduino Uno Compatible) not user what revision.
I am using IDE version 1.0.4

For initial debugging I am use a Garmin GPS 72 in simulator mode, as a source of serial data. This provides me with a constant stream of serial data in a known format. I have set up the GPS to send "Text Out" at "4800" Baud and I get the following data when I use putty and a Serial to USB converter:


Where only the time changes.

I got data above by:

1) Connecting a laptop and GPS together with a USB to Serial converter
2) Using Putty set to 8 (bits) No (parity) 1 (stop bit) XON/XOFF (flow control) at 4800 baud

Then I uploaded the following code to my Arduino. This is based in the Software Serial example code:
Code: [Select]
Receives from software serial, sends to hardware serial.
The circuit:
* Arduino RX is digital pin 10 - connect to TX of GPS 72 Brown, Pin 2 of DB 9   (Green)
* Arduino TX is digital pin 11 - connect to RX of GPS 72 White, Pin 3 of DB 9  (Red)

#include <SoftwareSerial.h>

#define rxPin 10
#define txPin 11
SoftwareSerial GarminSerial =  SoftwareSerial(rxPin, txPin);

int  counter=0;
char  CharFromGPS;
void setup() 
Serial.println("It's Alive!");

pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);

void loop() // run over and over
  if (GarminSerial.available())

My problem is that I get nothing like the output from Putty

The output I get on the Serial Monitor is: (casting the output to int)




This look almost like ASCII codes, by do not translate to correct text output.

So I have a fundamental error somewhere in my setup.

This gives the correct output:
Garmin-> serial cable -> serial 2 USB converter -> laptop USB port -> putty

This gives the incorrect output
Garmin-> serial cable -> GND to GND, TX on Garmin to Arduino RX pin 10

I original posted this in the devices forum but this is probably a better place for it.

Happy to try anything to get this to work.


Does the Garmin use TTL (5V) Serial or RS232?  The logic levels would be inverted if you tried to connect an RS232 signal to an Arduino TTL Serial input.  That would produce strange results.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

James C4S

Turn your Serial up to 9600 or faster.

Code: [Select]

Not every character your Garmin sends is printable.  Serial.write() makes no attempt to make the bytes it sends to Serial monitor printable, while Serial monitor expects ASCII characters. 

You wanted Serial.print(), not write().
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


Does the Garmin use TTL (5V) Serial or RS232?  The logic levels would be inverted if you tried to connect an RS232 signal to an Arduino TTL Serial input.  That would produce strange results.

I did not know that there was a difference. The Garmin uses RS232. Looking at the binary results it does not look like a simple inversion. However I guess that the stop bit would also be inverted. Also the correct string contains 440 bit and the corrupt ones has 464.

Would this also mean that using the hardware serial chip on pins 0 and 1 would also fail?

If this is the problem is there any easy way to find out. Or will I need to build a RS232 to TTL converter like this one


Yes, you should use a RS232 to TTL level shifter.  RS232 can go as high as +/-12V which would be bad for an Arduino input.

As an experiment you turn on the (undocumented?) data inversion feature in SoftwareSerial:
Code: [Select]
SoftwareSerial GarminSerial =  SoftwareSerial(rxPin, txPin, true);
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp



A simple voltage divider?...

...won't work to make negative voltages safe for the Arduino.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


A simple voltage divider?...

...won't work to make negative voltages safe for the Arduino.

A diode in Series to only allow a positive or near 0v voltage then?


May 04, 2013, 04:48 am Last Edit: May 04, 2013, 04:50 am by clyn001 Reason: 1

Does the Garmin use TTL (5V) Serial or RS232?  The logic levels would be inverted if you tried to connect an RS232 signal to an Arduino TTL Serial input.  That would produce strange results.

You hit the nail on the head with this answer John. I found a tutoral on the Arduino site (which I can not find now) and breadboarded a MAX232 chip. After a little tweaking of the code I got exatcly what I was expecting.

Thanks for your time and effort.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131