Go Down

Topic: Arduino reading 5v signal (Read 470 times) previous topic - next topic

zejdkoco1

Jul 17, 2017, 09:31 pm Last Edit: Jul 17, 2017, 10:04 pm by zejdkoco1
Hello, I have a question about wiring the arduino for a project i have, I just want to be sure before potentially destroying my board (Im new to this).
I have an Arduino Nano and it will be powered by the mini USB (from PC). I want it to read the voltage of another device's USB port (to see if it is powered or not), so basically I want to know if it receives 5v or not.

First question is about the wiring, I presume i would wire the positive to a pin and the negative of the signal wire to the GND of the arduino. Is this correct?Is this even safe?

Second, I'm not sure whether to use an analog pin or digital pin as input since I only care about it having voltage or not (the measurement is not required).

Third, would I need to connect a resistor in series with the 5v signal wire to limit current?

Thanks in advance for your help, and sorry If I'm asking banal questions but I just want to make sure.

DVDdoug

#1
Jul 17, 2017, 09:44 pm Last Edit: Jul 17, 2017, 09:45 pm by DVDdoug
Quote
First question is about the wiring, I presume i would wire the positive to a pin and the negative of the signal wire to the GND of the arduino. Is this correct?Is this even safe?
USB has two data wires, +5V, and ground.    Connect the grounds together and connect the switched USB's 5V to an Arduino input pin.

Quote
Second, I'm not sure whether to use an analog pin or digital pin as input since I only care about it having voltage or not (the measurement is not required).]
Digital.  5v (nominal) is a digital '1' or 'high' and 0V or ground (nominal) is digital '0' or 'low'.

Quote
Third, would I need to connect a resistor in series with the 5v signal wire to limit current?
No.  The Arduino's inputs are very high impedance.     (There are protection diodes, and if you exceed +5V,  actually if you exceed Vcc, or if you apply a negative voltage you can get "excessive current".)

zejdkoco1

Ok, thank you very much for the quick answer.

icegodd

#3
Dec 05, 2017, 07:33 pm Last Edit: Dec 05, 2017, 07:49 pm by icegodd
hi

do it need a pulldown resistor??

i have make drawing, can you guys plz check if its safe!! (usb vcc > interrupt arduino)

xl97

If you are checking for 'hi'.. then yes.

You would pull the line 'low' so it has a known state and is not 'floating'.

larryd

If the monitoring Arduino is powered off and the monitored USB is turned on, there will be back-feed current through the input protection diode on the powered off Arduino.

Not a good thing!


No technical PMs.
The last thing you did is where you should start looking.

ondsinet

If you are worried about frying your board, that might happen if you apply more than 5 volts to your digital or analog pin. That shouldn't be a problem when measuring from USB, unless it's something DIY.
If Greater voltages are a possibility, try making a voltage divider.

Wawa

You say in post#0 that you have a Nano running on USB power, but post at a Fritzing picture of a Micro.
So what is it.

A Nano powered from USB runs on ~4.6volt, because of a backflow protection diode in series with it's USB supply. One of the reasons you can't just connect a solid 5volt signal to a digital pin.
There is also the risk of the Nano being off. Then pin voltage limit is 0.5volt (VCC+0.5).
That could partially or fully phantom-power the Nano, and that could be bad for the pin.

An acceptable way to stop connected devices phantom-powering each other is a (10k) current limiting resistor between 5volt signal and pin.
A better way is an opto coupler.
Connect the opto transistor between pin and ground with internal pull up enabled in pinMode.
And power the opto LED with <=1k CL resistor from that external voltage.

Can't use pin0 on a Nano (as drawn on the Fritzing). Pin0,1 are the pins that talk to the USB<>Serial chip.
Leo..

icegodd

My question is the same as first post#0 but its not the same project.

Thx all for inputs.
I will use a opto transistor (there is alot ex-sample on @)

My project is:

Arduino control rgb led. If arduino is on standby/sleep and pc goes on then it will turn the lights on. And pc is powering down then the light goes off.
That is why i need usb vcc interrupt function (D2 input pin).

Go Up