Go Down

Topic: simple serial issue (Read 10916 times) previous topic - next topic


Finally got some pictures up:

Any questions? Just ask. It all makes sense :)
The white cable is the USB from the PC to the Arduino. The black is the USB to Serial converter that came with the GPS. Its plugged into the PC as well.
The little black box with round edges on the laptop is the GPS. In between the GPS and the USB to Serial converter is a little homemade breakout device. Two wires goes to get some power from the USB to Serial converter, while the third (TX) is plugged into pin3 on the DB9-jack on the RS232 to TTL converter (sorry, the pin had fallen out on some of the pictures). This breakout-setup has been tested with the PC as the recipient, and it worked 100% - I received loads of NMEA-data.
From the TTL-side of the RS232 to Serial converter goes 4 pins: two to get power from the breadboard (measured at the pins: 5.00volt). The two other ("T" and "R") goes to pin 0 and 1 on the Arduino. My testing involved switching these pins, and trying to insert the TX-pin from the GPS in different holes in the female DB9-jack.
All I got was alot of "-1".. :/


Haven't looked them over real hard, but one thing I don't see is a common ground between the Arduino and the GPS. I see that you are powering the Arduino from the USB port of the PC, but does everything share a ground?

Easy thing to try is connect a wire from the Arduino ground to the all the oter grounds. 2 devices being powered from seperate supplies need to share a ground for data. I have done that to my self a few times.

It don't look like your problem is that simple, but you never know.



Two main problems.

1. Already mentioned, there is no common ground. RS232 requires a common ground between all devices. That explains why you got nothing when using SoftwareSerial, and why you wouldn't have gotten anything with hardware serial, if you had been aware of the next point:

2. Look over to the other side of the Arduino board. See those two other pins labeled 0 and 1, and also RX and TX? I think you know where I'm going with this.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store


I see someone already caught it, was just looking over the pics again. You aren't connected to the TX and RX pins on the Arduino.


Jan 26, 2009, 10:19 am Last Edit: Jan 26, 2009, 10:20 am by loldrup Reason: 1
This is slightly embarrasing..
Now it apparently works. At least I see loads of digits - all of which is something else than "-1". Only issue now is that the Arduino IDE has started freezing 100% when I try to upload new code to my board. It just writes "Uploading to I/O board..." and then its dead. Afte 5 mins I kill it from Windows task manager. That means I cant change:

[font=Courier]Serial.print(hardSerialChar, DEC);[/font]


[font=Courier]Serial.print(hardSerialChar, BYTE);[/font]

So I can have a final confirmation that what I see is the NMEA-data (but what could it else be).

But anyway, thank you all for your help. It really was a simple serial issue ;)


Just add the common ground and go back to the software serial code, you can't upload because pins 0 and 1 are also used for the bootloader. If you attach something to them, it can easily interfere with the upload, that's why we were all skeptical of that method at the beginning. Plus, you would see all the data twice, once when it was sent to the Arduino and PC from the GPS, and then again when the Arduino sent it to the PC.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store


to macegr:
I guess your comment apply generally to all projects that use the hardware serial port of the arduino? Or is there something in my setup that makes it extra delicate/complicated/unfortunate/risky?
I can't see how use of the hardware serial on the arduino can awoid having the effects you mention.


Most successful hardware serial projects are connecting to only one device at a time. That means disconnecting other devices while downloading code to the Arduino.

It's why the software serial library exists.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store


I've now added common ground.

I guess one can actually brick a Arduino by writing a program that constantly sends some trivial data (like "A") to the PC

void setup()  {

void loop() {

That would make it impossible to ever write programs to it again, as it will hang, just as mine is doing now, when I upload while my GPS is connected.


WAUW, now it works perfectly :D

I'm using this code:

[font=Courier]void setup()  {

void loop() {
if (Serial.available()) {
char hardSerialChar = Serial.read();
Serial.print(hardSerialChar, BYTE);

The code without the if Serial.available inserted alot of "-1" in the NMEA-sentenses (hmm, one could actually figure out the cycle-speed of the 'void loop' function by looking at how many "-1" are for each NMEA-letter, and knowing that the baud rate of the GPS is 4800)

I had some issues right up till now. Using the power supply from the breadboard to support my GPS made it not turn on (which I didn't notice). Using the ground from the breadboard and the power line from the original GPS-cable also didn't work - the GPS turned on but couldn't communicate anything. Finally I added a wire from the ground on the breadboard to the ground-jack on the original GPS cable going to the computer. THEN it worked. PHEW!! I was getting really frustrated.

And yes: DON'T let data go into RX when uploading new code to the Arduino.


Good to hear you have it going and nice to see that Serial.available() has finally made it into your code.  ;)

Have fun!


i am not sure if this is where i ask anyway i am new to using arduino.
i am building a miniture dynamometer and i want to send four types of information(voltage,speed,load pressure) to my program (vb) over a serial link. please if anyone can help i would be gratefull


I guess one can actually brick a Arduino by writing a program that constantly sends some trivial data (like "A") to the PC

Hmmm.... that didn't brick my Arduino.


Jan 27, 2009, 09:39 am Last Edit: Jan 27, 2009, 09:41 am by loldrup Reason: 1
to mikalhart:
no I figured that myself too. The problem only occurs with stuff going into the RX pin on the Arduino. And that you can aways mitigate by removing the source of that stuff. So no bricking option here :)

Go Up