Go Down

Topic: Detecting powering method. (Read 1 time) previous topic - next topic

struthio

hello,

I am an owner of Arduino Nano 3.0.

This board can be powered by USB / external unregulated power / external +5V.

Is there a way to detect if board is powered by USB power or external unregulated one ?

johnwasser

You could connect one of the analog inputs to the external power through a 470K resistor and to ground with a 100K resistor.  This will divide the voltage by 4.7 which should make even the maximum allowed external voltage (20v) safe for the 5v input.  If the analog input reads 0 (or near 0) you are using USB or regulated 5V power.  Otherwise you can determine the supply voltage:

(analogRead() / 1023.0) * (5.0 * 4.7)

392 -> 9v
522 -> 12v
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

struthio

I thought that maybe here is some 'internal way' of detecting power source, since in Arduino Nano:

Quote
The FTDI FT232RL chip on the Nano is only powered if the board is being powered over USB. As a result, when running on external (non-USB) power, the 3.3V output (which is supplied by the FTDI chip) is not available and the RX and TX LEDs will flicker if digital pins 0 or 1 are high.


I guess I will use one of Analog inputs for measuring 3.3v if it is available then we have USB power.

I require this because I want 'battery backup power' to keep my app running, but to extend lifetime on battery I want to disable / skip some operations performed.

Thanks for help.

johnwasser


Quote
The FTDI FT232RL chip on the Nano is only powered if the board is being powered over USB. As a result, when running on external (non-USB) power, the 3.3V output (which is supplied by the FTDI chip) is not available and the RX and TX LEDs will flicker if digital pins 0 or 1 are high.


I guess I will use one of Analog inputs for measuring 3.3v if it is available then we have USB power.


I looked at the Arduino Nano 3.0 schematic and it looks like the FTDI chip runs off the same +5V rail as everything else.  You should have 3.3v any time you have 5v.  The only difference between USB and External power is the voltage on the input side of the 5V regulator.

I guess that won't actually tell you if you are USING external power, just that it's available.

If you are using USB for a data connection perhaps you can detect the loss of communication as an indication that the USB cable has gone dead.

If not, perhaps one os the FTDI pins will indicate the state of the USB data lines.

Another choice might be to put a diode between the USB power and the 5v rail and a supercapacitor across 5v and ground.  Then use an interrupt  input to sense a fall of the USB power.  The supercapacitor should give enough back-up power to allow the software to turn on the battery and go into low-power mode.  I'm not sure how the "auto power switching" device works but that might act as the necessary diode.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

struthio

One more question. On Arduino Nano 3.0 page is written:

Quote
The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically selected to the highest voltage source.


If I connect arduino to USB (so it will be powered by USB +5V) and also connect battery to arduino Vin (Inregulated power input).

Which one will be used (most) ? Will battery be only used if USB power is not sufficient or ortherwise, arduino will work on battery and USB power will be as additional source ?

( I plan to use 9V battery)

jraskell

Quote
but to extend lifetime on battery I want to disable / skip some operations performed.



Exactly what kind of 'operations' are you thinking of skipping/disabling?  Are you referring to peripheral devices (internal or external) being disabled, or actual operations on the micro not being performed?  The former could help battery life.  The latter won't make any difference at all.

struthio

Both :)

First of all I will disable LCD and it's backlight (because this will consume most of power), also loop will be delayed from 1s to about 10s or even 60s.

This delay will result in longer 'sleep time' of external devices and less power consumption, and as I believe Atmega also can be put in sleep mode.

Also no data will be transferred by USB(UART) to PC.


But I would also like to know if I connect both battery and USB power at the same time, will this use battery or usb power ?

(I ask this because I would like to know if I should build some kind of battery disconnecting circuit).


struthio

Battery is 9V and USB gives 5V, but battery power goes through ua78m05 so at the end at both sides will be +5V. And that is why I am confused :/

jraskell


also loop will be delayed from 1s to about 10s or even 60s.

This, in itself, will have zero affect on power consumption.  delay(60000) consumes just as much power as computing FFTs.


This delay will result in longer 'sleep time' of external devices and less power consumption,

Whether or not this conserves power is dependant on the external devices.  If they are somehow triggered by the Arduino, this may (or may not) be the case.  Something like say, one of the Sharp IR distance sensors though, are freerunning and will consume power regardless what the Arduino is doing.


struthio



Thanks for tips.
Most of devices used have 'automatic sleep mode' or can be put in sleep mode with specific command sent to them.


As for powering.

Since I didn't want to modify my arduino and didn't want to embed plain Atmega chip I decided to go with little 'workaround'.
Device will always start from battery in 'low-power consumption mode' then UART communication is detected it will switch to USB powering.
After disconnecting form USB device will reset itself and start from battery.

This solution allows me even to keep power circuit on separate board :)

Go Up