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.
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.
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'.
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".)
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.
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.
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..
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).