Serial communication doesn't work when only external power is used

Hi everyone,

I'm working on a project that uses the hardware serial interface of the arduino uno.
The problem that I'm having is that everything works when I power the arduino via the usb port, but when I only use an external power supply the serial communication stops working.

I googled about this issue and found out that it has to do with the bootloader that on startup looks for data on the serial port, but on startup the device I'm trying to talk to is already sending date so the bootloader gets confused and fails to load the sketch stored in its memory.

A solution that I found is to overwrite the bootloader by using the .hex file of my sketch and an external AVR programmer. I tried this first with the simple blinking sketch and everything worked fine even with the external power.

When I upload the .hex file of my sketch using the serial communication, it does not work. It even seams like the RX and TX pins are connected, Wich seems verry unlikely.

Has anyone encountered this problem and is there a solution?

Many thanks
Freespirit2907

I googled about this issue and found out that it has to do with the bootloader that on startup looks for data on the serial port, but on startup the device I'm trying to talk to is already sending date so the bootloader gets confused and fails to load the sketch stored in its memory.

Wrong, on startup the bootloader wait looking for a magic sequence of chars, if it gets that sequence it loads a new program if not then your existing sketch is simply run. It is not loaded from the bootloaders memory.

Not running with only external power normally means a flat battery or not enough external power.

With out the bootloader you cannot load a sketch over serial that's what the bootloader does.

Mark

When you plug the arduino into your computer, your computer is providing the power but it is also the the HOST for the usb.

For two things to communicate on the USB port, one of the items has to be the HOST. With the arduino, your computer is. The arduino is the slave.

If the item you're connecting to your arduino through the USB port is not going to act as a HOST then communicaton is never going to start.

freespirit2907:
but on startup the device I'm trying to talk to is already sending date

Haven't you both described the problem and the solution?

The device sending the data should wait until the Arduino is ready (and that is true for communication over the USB connection as well as direct connection to the Rx and Tx pins).

Look at how that is done in this Python demo by waiting for the Arduino to send a "ready" message.

If you absolutely cannot prevent the device from sending data when the Arduino is not ready you can disable the autoreset feature (Google will find the answer for you).

...R

Thank you for the quick replies.

holmes4:
Wrong, on startup the bootloader wait looking for a magic sequence of chars, if it gets that sequence it loads a new program if not then your existing sketch is simply run. It is not loaded from the bootloaders memory.

Okey seams like my information wasn't correct. So the bootloader still on the chip shouldn't be a problem then?

holmes4:
Not running with only external power normally means a flat battery or not enough external power.

My external power is a 12V supply capable of sourcing 3Amps. Should be enough :wink:

holmes4:
With out the bootloader you cannot load a sketch over serial that's what the bootloader does.

I know, I used a AVR dragon and atmel studio, just to try if the bootloader was the issue.

@KenF Does that also aplie when I'm only using the uart interface? the other device isn't connected through the usb port.

@Robin2 the device is already sending data and I don't control the device I'm just trying to interact with what it is sending.

Freespirit2907

freespirit2907:
@KenF Does that also aplie when I'm only using the uart interface? the other device isn't connected through the usb port.

No it doesn't. So you're using pins 0 and 1 for your serial even when powered from the USB port?

KenF:
No it doesn't. So you're using pins 0 and 1 for your serial even when powered from the USB port?

Yes I am.

freespirit2907:
Yes I am.

I think it must be a timing issue. Do you have a display available to start debugging it?

I could hook up a display, but problem is not if my code works, I know it does because it works while powered with the usb...

Or could there be that big of a difference between usb power and external?

How do you know your arduino is even powering up? Maybe you've just got a blown voltage regulator.

Could you use SoftwareSerial to receive the data on different pins and leave pins 0 and 1 free?

...R

I know it's powering up, I tried an easy program that isn't using serial (like blink) and it worked fine.

I could use Software serial of I didn't need serial interrupts and parity. But unfortunatly I do :\

Maybe it helps when I give some more info on my project:

My laptop communicates over serial using an usb to uart(ttl) converter, with a device, the tx of my pc is connected to directly to the device but the tx of the device gose to the rx of the arduino, I change some bits in the data and use the arduino's tx to send to the rx of my pc.

I hope that helps a little xo

Many thanks for the ideas you already sujested guys :slight_smile:

freespirit2907:
I could use Software serial of I didn't need serial interrupts and parity. But unfortunatly I do :\

You could probably add parity checking to the simple code in this demo yet another software serial It already uses an interrupt to detect incoming bits.

...R