Simple Serial Pins 0/1 Problem

I'm trying to very simply use pin 0 for serial input from some other serial device and echo the received data back to the PC through the USB interface. Everything is working fine except I'm having what I believe to be a Byte/ASCII issue so I'm not getting the expected data. I can't figure out the right combination of data types to simply echo the serial data that comes in on that pin...

Here's my code:

int incomingByte = 0;

void setup()

void loop()
  if (Serial.available() > 0)
    incomingByte =;

    //Echo serial data on PIN 0 back to PC over USB  
    Serial.print(incomingByte, DEC);
    Serial.println(incomingByte, BYTE);

...and for the input of '111234aaabcd' here's my output:

103     g
103     g
103     g
51      3
102     f
79      O
79      O
79      O
39      '
78      N

Just to clarify, for the input of '111234aaabcd' I'm expecting the output to be identical, '111234aaabcd'. This seemed easy but something simple really has me stumped....


The code look right.
Have you disconnected pin 0 from the USB chip? If not then you will have your other device and the USB chip both trying to drive the serial input to the Arduino and you will get rubbish.

Mike, I'm not sure what you mean by disconnecting Pin 0 from the USB chip (FT232 I assume). I also just noticed, my data isn't as consistent as I thought. ASCII input '123' used to always come out as 'g3f' and now it's consistently coming out as 'f2e' (exactly 1 bit lower). To describe my physical connections, my circuit is very simple:

Serial Device TX --> Arduino Pin 0 (RX)
Serial Device GND --> Arduino GND
Arduino USB --> Laptop

I want to monitor the TX from USB to the Laptop which should simply repeat the data coming in on Pin 0 from the external device. I'm essentially just building a one-way serial to USB device at the moment. Is that even possible with the built-in FTDI chip?

That connection is OK as long as the PC doesn't send anything back on it's serial line. If it does then because the USB chip AND your serial device will be driving the port at the same time, you will get rubbish, which is what it looks like you are getting. So by disconnect I mean unsolder the link resistors. I assume you haven't done this as it makes downloading a sketch tricky (you have to put a switch in).

What application are you using at the PC end, make sure it is not echoing back any data.
Alternatively I would recommend you went to the playground and look up the software serial and use another line for the input. The down side of that is that while you are recieving a serial byte you can't do anything else.


Are you saying that if you have power to the board, not via USB, and you want to use a serial cable to pins 0 and 1, you can't unless you disconnect the Atmega from the FTDI?

It looks like you can't just connect a serial cable to a PC and to pins 0 and 1 to do a "generic" serial connection. Would this type of connection require something like a max232?


Would this type of connection require something like a max232?

Yes that is what I mean.
You can carry on powering the board through the USB providing the COM ports are not open back to the Arduino Monitor or Processing or other stuff that expects serial communications. But once you do then the RX into the Arduino gets to become active. It is wired up to USB bridge through a resistor so you might be able to get away with stuff coming in serially from somewhere else (through a RS232 to TTL voltage converter like a Max chip) and going out through the USB's serial connector, but you have to make sure that the USB coms doesn't send anything, like acknowledgements otherwise that will upset what is going in.

Not to hijack this thread, but I am having a similar problem and I'm not using pins 0 or 1.

I have an external serial device that, when directly connected to my PC via serial port and watching in HyperTerminal I receive the following data (This is exactly what I want to see)...


Now, for my actual project, my final goal is to receive the data from the serial device in and record it to an SD card. I had put the SD recording to the side until I can get the Arduino to properly receive and recognize the received data.

When printing the received data to the Arduino serial monitor it is all gibberish like in the original post.

This is what I get...


I am using NewSoftSerial with pins 6 and 7 for connection to the serial device.

The serial device is configured as such...

9600 Baud
No Parity
8 Bits
1 Stop Bit
No Hand Shaking
Echo Off

My original post is here...

I think that I'm having the same trouble as CraigKC.

Thank you,

Ohh... Here is my sketch...

Serial to SD card DATA logger

#include <ctype.h>

#include <NewSoftSerial.h>

NewSoftSerial GPS(6, 7); //pin 6 RX from device pin 7 TX to device
byte writing = 2;  //LED writing indicator
byte recordenable = 5; //record enable pin

#include "FileLogger.h"

void setup() {

  pinMode(recordenable, INPUT);
  pinMode(writing, OUTPUT);

  // set the data rate for the NewSoftSerial port


void loop()
  byte val = 0;
  while(digitalRead(recordenable) == HIGH) { //check for record enable signal
    digitalWrite(writing,HIGH); //indicate that recording is active
  if (GPS.available()) {
    val = (char);
    int long length = sizeof(val) - 1;
     //FileLogger::append("GPS.txt", &val, 1);
     //FileLogger::append("GPS.txt", val);

  while(digitalRead(recordenable) == LOW) { //check for record enable signal
   digitalWrite(writing,LOW); //indicate that recording is inactive