Pages: [1]   Go Down
Author Topic: Arduino testing its own power source ?  (Read 404 times)
0 Members and 1 Guest are viewing this topic.
unprobable country named Belgium
Offline Offline
Full Member
***
Karma: 2
Posts: 241
Ga bu zo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I wave a 5V Arduino Pro Mini powered from 3 AA NiMH batteries. Is there a way to sense the power with the Arduino and switch a LED on when the voltage drops below a specific value ?

Thank you in advance.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31452
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
What you do is to switch the input of the A/D to the referance voltage and measure this with a referance voltage of the supply voltage ( the normal state).
Then you can work out the exact value of the 5V from what you measure the known 1.1V to be.
Logged

unprobable country named Belgium
Offline Offline
Full Member
***
Karma: 2
Posts: 241
Ga bu zo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I don't get the idea. Do you mean I should simply connect the power source to an analog input of the Arduino ?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8074
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can measure the internal 1.1V reference voltage relative the AVcc (which is normally connect to Vcc).  If the supply voltage is 5V you would get a reading of about 225 ((1.1/5.0)*1024) if the supply voltage drops to 4V you will get a reading of about 281 ((1.1/4.0)*1024).

Unfortunately you can't use "analogRead()" to read the internal voltage standard.  You will have to set the ADMUX register to 14 by direct port manipulation.  Here is a tutorial that covers the ADC: http://fivefive.wordpress.com/2008/01/23/avr-tutorials-adc/
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Edison Member
*
Karma: 4
Posts: 1726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://code.google.com/p/tinkerit/wiki/SecretVoltmeter
no external connections necessary,  it even works with the attiny series with a little modification
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this page also talk about it
http://www.ikalogic.com/avr-monitor-power-supply-voltage-for-free/
Logged

South England
Offline Offline
Full Member
***
Karma: 3
Posts: 205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/AnalogReference

Couldn't you also use this?
Logged

Offline Offline
Edison Member
*
Karma: 4
Posts: 1726
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you could with external components and change the reference but, the link I had has code for arduino to do it without any external components
Logged

unprobable country named Belgium
Offline Offline
Full Member
***
Karma: 2
Posts: 241
Ga bu zo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot everyone ! This is very interesting.
Logged

Pages: [1]   Go Up
Jump to: