Pages: [1] 2   Go Down
Author Topic: Getting an Arduino to Monitor Its Own Voltage: How?  (Read 1586 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I get an Arduino to monitor its own voltage levels? I'm getting occasional dips / spikes in the voltage output of a humidity sensor and would like to know whether the noise observed in the output voltage is due to variations in the source voltage.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8940
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I get an Arduino to monitor its own voltage levels?

Use a voltage divider to bring the VCC voltage below 1V, connect it to an analog input, and use the internal 1.1V reference of the ATmega328P:

Code:
analogReference(INTERNAL);
Logged

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

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

 Alternative, you can measure the internal reference voltage which should be 1.1V, then work out what value the Vref is from the value you read the 1.1V from.

See the processor data sheet for how to switch the analogue input to read the internal 1.1V.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use a voltage divider to bring the VCC voltage below 1V, connect it to an analog input, and use the internal 1.1V reference of the ATmega328P:

The sensor I'm using is powered by the Arduino's 5V supply. What's the reason for dropping the voltage and using a 1.1V reference instead of the 5V default?


Alternative, you can measure the internal reference voltage which should be 1.1V, then work out what value the Vref is from the value you read the 1.1V from.

I understand the part about measuring the internal reference voltage, but I don't understand what you mean when you say to "work out what value the Vref is from the value you read the 1.1V from."
Logged

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

Quote
The sensor I'm using is powered by the Arduino's 5V supply. What's the reason for dropping the voltage and using a 1.1V reference instead of the 5V default?
The point is that once you change to the internal referance only voltages below that will be measured, so you have to use a potential divider to do that. Say you have a five to one divider, then exactly five volts on the power will give you one volt you can measure. As the five volt supply changes then so will your reading, because the referance is fixed.

Quote
but I don't understand what you mean when you say to "work out what value the Vref is from the value you read the 1.1V from."
If you use the supply voltage as a referance voltage it will always read the same value if you try and measure it. However the 1.1V is fixed, so if you measure it with a changing referance it's value will appere to change even though it is a fixed voltage. By looking how the value you read changes you can work out what is happening to the referance voltage, that is your supply voltage. Simple high school maths.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The point is that once you change to the internal referance only voltages below that will be measured, so you have to use a potential divider to do that. Say you have a five to one divider, then exactly five volts on the power will give you one volt you can measure. As the five volt supply changes then so will your reading, because the referance is fixed.

Does this mean I can count on the internal reference voltage not to change even if my Arduino's 5V rail were indeed unstable?

I've measured the 5V rail with a multimeter and the voltage appears to be stable at 4.9V, but I don't know whether the dips and spikes I'm getting are too brief to register on the multimeter.
« Last Edit: May 08, 2012, 01:44:31 pm by AdrianLopez » Logged

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

Quote
Does this mean I can count on the internal reference voltage not to change even if my Arduino's 5V rail were indeed unstable?
Yes.

Quote
but I don't know whether the dips and spikes I'm getting are too brief to register on the multimeter.
They normally are. However, I am not sure you will see it with the analogue read either, you have to look often to catch brief excursions.
Logged

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sensor I'm using is powered by the Arduino's 5V supply. What's the reason for dropping the voltage and using a 1.1V reference instead of the 5V default?

Because if your reference is the 5V rail, and if the problem is that the 5V rail is not reliable, then a reading relative to the 5V rail will just follow along with the variations, showing "no relative change."

The 1.1V internal reference is fixed at 1.1V, no matter what the supply voltage is.

Also, just to trouble-shoot your sensor: Try adding a 100 uF or 470 uF electrolytic capacitor between 5V and GND to stabilize the supply, if that's indeed what the problem is.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Driving down the voltage to 0.86 volts using a voltage divider and scaling back up to 4.9 in software shows none of the dips and peaks I'm getting with the sensor attached. This rules out the Arduino's 5V rail as being the problem, so either the behavior I'm seeing is normal for the sensor I'm using or else I have a bad sensor. I'll start a new thread in the sensors forum for feedback on the particular sensor I'm using.

Thank you all for your help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like I may have ruled out electrical noise a bit too early: The ADC Noise of Netduino.
« Last Edit: May 11, 2012, 03:24:04 pm by AdrianLopez » Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing in common between an Arduino and Netduino are the letters "duino".  So I'm not sure how much of the article is relevant.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing in common between an Arduino and Netduino are the letters "duino". So I'm not sure how much of the article is relevant.
They are certainly more different than they are similar, but why would the Arduino's ADCs not be susceptible to electrical noise the way the Netduino's are?
Logged

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sources of the noise as discussed in that article are almost entirely due to the specifics of the hardware on the Netduino. The hardware on the Arduino is very different. The same kinds of problems may still exist, but you'd have to do a similar level of diagnostics to figure out what the actual cause is. If you have an oscilloscope, now's the time to break it out!
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm getting occasional dips / spikes in the voltage output of a humidity sensor...

What is the Arduino driving? If it is switching anything that takes more than a small amount of current, then you need to be very careful about your ground wiring, otherwise the switched current will induce a voltage on the ground line, which may feed back to the analog inputs.

To avoid or at least reduce this problem, dedicate one of the Arduino ground pins as "analog ground". Connect the ground side of your analog sensors to this ground, along with the ground sides of any capacitors you are using to smooth the analog inputs. Use the other Arduino ground pins for everything else, such as power to the Arduino and the ground sides of any output devices.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing connected to the Arduino at the moment is an analog humidity sensor. Connections are 5V, GND and A0.
Logged

Pages: [1] 2   Go Up
Jump to: