Go Down

Topic: Getting an Arduino to Monitor Its Own Voltage: How? (Read 1 time) previous topic - next topic

AdrianLopez

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.

johnwasser


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: [Select]

analogReference(INTERNAL);
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Grumpy_Mike

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.

AdrianLopez


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

Grumpy_Mike

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.

AdrianLopez

#5
May 08, 2012, 08:39 pm Last Edit: May 08, 2012, 08:44 pm by AdrianLopez Reason: 1

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.

Grumpy_Mike

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.

jwatte


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.

AdrianLopez

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.

AdrianLopez

#9
May 11, 2012, 10:02 pm Last Edit: May 11, 2012, 10:24 pm by AdrianLopez Reason: 1
It looks like I may have ruled out electrical noise a bit too early: The ADC Noise of Netduino.

James C4S

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.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

AdrianLopez


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?

jwatte

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!

dc42


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.
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.

AdrianLopez

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

Go Up