Issues having a proper digital input with an externally powered circuit

Hello arduino users.
I have a question which I am sure is dumb, but I am very new to electronics.

Basically I have a very simple circuit for test (resistor+leds) and I want to read with arduino wether it is being powered or not.
I use the sketch Basics>Digital read serial , and when my circuit is powered by the 5V output viltage of the arduino, it works perfectly.

Now when I do the exact same thing but with an external power supply for my circuit , here a tranformator of 220V alt (france) to 5V continuous ( 1 full line and one dotted line is continuous right?) , I cant read anything, I have the same erratic signal than if my pin wasnt connected to anything.

my question is why? and how to remedy?

For info the all thing is made to read with a arduino the state of a domestic motion sensor, which I will use to power or not the transformator.
If there is any better way to do this I will be happy to hear about it.
Thanks a lot for your input :slight_smile:

Simon

Ya got the grounds on both devices connected?

Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V

SO your power supply is "too weak"

@robtillaart: Since this subject came up, and I have yet to try it, can you put 5v power into the 5v pin on the Arduino rather than the power jack?

sorry if I wasnt clear enough,
my arduino is correccty powered, it is the circuit i am tring to read that is externally powered.

when <i power my circuit with the 5V output of the arduino, digital read works but when I power it with a 5V transformator it doesnt.
the thing is I cant see the difference between the voltage provided by the arduino and the one provided by my transformator, ans then why I can read the first and not the second.

For SurferTim: I have both wires out of my transformator connected at each end of my circuit, the led lights up fine in both case... maybe something happens inside the transfo which makes the (-) wire not being the ground???

help!! :slight_smile:

No, unless it is a clean continuous 5V I would not do that.

1 full line and one dotted line is continuous right?

AFAIK - Wrong, the voltage from your "dotted one" looks like - http://www.circuitsonline.net/img/000382.png - So the effective voltage is less than 5 Volt
That is why the recommended voltage must be 7V, so that even a "dotted one" will give "5 real Volts"

The grounds need to be connected. If the transformer is a standard wall wart, it isolates the ground.

Try connecting the grounds only (no power) between the two devices.

@robtillart: I mean regulated 5v with a switching regulator to the 5v pin. The USB powers it that way I think.

thank you SurferTim:
when I connect the (-) wire of my transformator to the GND pin of the arduino it works better. I do have clear 1 or 0 input in my digital read.
Now the problem I have is that when I turn off (or even unplug) my tranformator, there seems to be still residual current, and my led take like 10 seconds to slowly fade, and then my digital read is 10 sec late to turn 1 into 0 when the power supply is disconnected.

how come?

thank you

The transformer has a relatively large capacitor on the output. That is why I recommend using a transformer close to the current rating on the device. If the current rating on the transformer is a lot larger than the current requirement, it takes a while for the cap to bleed off the stored electrons.

ok, so basically I could overcome that by adding a big resistor in my circuit, to "boost" its current requirement?

for info I did an other cicuit that works for my purpose:
using the transformator to power a relay, that I directly plug into the arduino ( 5V, GND and pin 2 for read).

What do you think of it? will there still be the bleeding electons issue?

thanks a lot

I don't think the parallel resistor is a good idea. When I have equipment that relies on each other to function, I make it my goal to power them with the same primary power supply. If the power supply fails, all devices quit.

I plan on using a regulated 5v supply to the 5v pin on the Arduino, and connect that 5v to my other child devices also.

the thing to have an external power supply is the point of the circuit:
I want to be able to read with the arduino wheter the external power supply of the circuit is plugged or not, without ever turning off the arduino.

This is meant to read wether a motion sensor (interruptor) is seeing something or not. basicallly the transormator is plugged to the sensor, and I want a read on my arduino of the state of the sensor.

what do you think of my solution with a relay?

Or how would you do that? the only requirement I have is having a digital read on the arduino of the state of a domestic motion sensor.
thanks

If you need to determine if the power is up on the external device, I think I might add another wire besides the comm and ground from the device to the Arduino. Connect that wire to the power supply of the external device and a digital pin on the Arduino, but only if the external device is 5v power. Check the status of that pin in your program loop. When it goes low, you have a power outage.