Problem reading serial data


I’d like to build a device wit Arduino that reads data from a serial TomTom GPS and, managing string, displays some informations on a LCD.
As a first step I’ve tried to connect Arduino an the GPS device in order to see if the strings where read correctly. The GPS display sends strings at 4800 baud and I’ve tested it with a pc and a serial connection and everything was ok. When I’ve connected it to Arduino I’ve put this circuit between the gps and the arduino:

My idea to check the data strings was to read from the device and to send it to the “serial monitor” and I’ve used this code:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
#define ledPin 13

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte pinState = 0;

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  // set the data rate for the SoftwareSerial port

void loop() {
  // listen for new serial coming in:
  char someChar =;
  // print out the character:
  // toggle an LED just so you see the thing's alive.  
  // this LED will go on with every OTHER character received:


void toggle(int pinNum) {
  // set the LED pin using the pinState variable:
  digitalWrite(pinNum, pinState); 
  // if pinState = 0, set it to 1, and vice versa:
  pinState = !pinState;

some data arrives to the monitor, but caracters are “strange”!!
Where am I wrong?

Thanks in advance!


You need to post a link to your GPS. If the GPS serial output is TTL level that you are treating as RS232 level (using the MAX232 chip), that would account for the strange characters.

SoftwareSerial is obsolete. Use NewSoftSerial, instead. NewSoftSerial has an option to invert the incoming serial data. That seems to be required for some GPSs.

If SoftwareSerial is managing the specified tx and rx pins, you don't need to have pinMode statements for them.

SoftwareSerial does not have a method that tells you whether there is serial data to read, or not. NewSoftSerial does. Trying to read serial data, when none is available, will get a -1. Printing that will show y with 2 dots above it. Is that the "strange" data you are seeing?

More details about your specific problem, including sample output, would be helpful.

Hi and thanks for the reply The gps is this: When I connect it to a serial port on the pc I read data perfectly! Do I need Max232 or not? Tonight I'll try newsoftserial and keep you updated


The gps is this

Sorry but I doubt anyone is any wiser, all we see is a silver box and some wires.


True; the picture does not help much but the statement that it works fine with a PC serial port means that it is probably putting out RS232 levels. Therefore you will need the MAX232 level converter chip or something similar to get these signals into the Arduino.

The circuit you supplied for your MAX232 implementation is OK. I would look to the pin mode statements in your code, as pointed out elsewhere if you are using softserial this is already taken care of.


Peter B.

The GPS would not be TTL level... so you would want to use the level converter.

Make sure you are not trying to connect Transmit on the GPS to Transmit on the Arduino (same for Receive). You probably need to cross those signals over between the devices.

Thank you very much for answers. Tonight my whole evening will be dedicated to test everything again!

So, it's clear that if the gps works with the pc serial port it needs max232 to be connected to Arduino.

this is the result of a connection gps-pc: and it's what I expect from the connection with Arduino

When (with max232 in the middle) I've tried to read data and see them in the monitor the result (tonight I'll post it) was "similar" to the right one (I could recognise some carachter, the lenght of the lines seemed to be correct, ecc..). I hope that the new software layer (newsoftserial) will give me the good result. Then next step will be string manipulation"!

Especially as you said...

the lenght of the lines seemed to be correct

I wonder if your data is inverted?

In other words, what you think is binary 00001100 is 11110011.... quite easy to get this inversion from various sources.

Between reading each byte and displaying in, do a bitwise NOT.

You may also be encountering problems because you and your Arduino are not on the same page re- the "type" (in the narrow sense) of your data.

Post your code. (Sorry if you have done... doing this in haste.) People will soon be able to tell you if my ideas were relevant.

I've replaced the library with newsoftserial and it perfectly works! thanks to everyone for support!

just a curiosity: why the max232 works also without capacitors????

just a curiosity: why the max232 works* also without capacitors???

*for some certain value of ‘works.’

I suspect that the signals you are communicating with are not true RS-232 levels. C1 and C2 are external capacitors used for voltage doubling and inversion. I imagine the signal is +5V high 0V low instead of the standard +3V to +15V high and -3V to -15V low. But the reciever is tolerant enough to accept these, especially at such a slow baud rate. For example the MAX232A is typically <1.3V is low and >1.8 is high.

I wouldn’t expect it to work with all recievers nor would it be especially tolerant of noise.

Hook an oscope to the signals and let us know what you find.