Hello,
I want to measure the Voltage that my Arduino MEGA operates, by using its ADC and a voltage divider.
What values+discrete elements should I use for this measurement?
Thank you...
Hello,
I want to measure the Voltage that my Arduino MEGA operates, by using its ADC and a voltage divider.
What values+discrete elements should I use for this measurement?
Thank you...
You can use a 1k2 and a 3k9; that will give an 1:5 divider; 12k and 39k will also work. See e.g. Voltage Divider Calculator how to calculate.
You can set the reference voltage to 1.1 volt (I think).
See analogReference().
PS
I just realise you don't mention how you power the Arduino. I assumed that you want to monitor the 5V pin.
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
From the reference for Vref.
Yup, available but with a different function than other processors. 2.56V, too.
Vref will not be exactly the value set. If set to 1V1 the actual Vref can be 1.0 to 1.2 volts. Measure Vref (with DMM) and use the measured value in calculations.
Is this a homework assignment?
What do you need help with? Do you know how a [u]voltage divider[/u] works?
The default ADC reference is Vcc (the voltage powering the Arduino) so if you use that (and if you assume Vcc is 5V) you'll always read "5V", so that won't work.
But, there is also an optional-internal 1.1V (nominal) reference and that will stay constant when Vcc changes. With the 1.1V reference you can't read over 1.1V But, if you drop Vcc down to about 1V with a voltage divider on the analog input, using the 1.1V reference you can read the voltage divider output and calculate Vcc. (i.e. The ADC reading is proportional to Vcc and you simply need to apply the correct factor to calculate voltage.)
The 1.1V reference is stable but it has a tolerance (I believe it can vary between 1V and 1.2V). The resistors in your voltage divider also have a tolerance. So if you want accurate measurements you'll have to measure the actual voltage with a DMM and make a calibration adjustment (in software).
There is also a "trick" that can be used to measure Vcc. There is a way to read the internal "1.1V" voltage (with Vcc as the ADC reference). So for example, if Vcc is low the internal reference will read high and if Vcc is high the internal voltage will read low. If you know the true internal reference you can calculate Vcc from the error (the difference between the true internal voltage and what you measure/calculate).
alex5678:
I want to measure the Voltage that my Arduino MEGA operates,
Approximately what voltage will you be measuring?
Your question is confusing. A Mega operates on 5v.
...R
Here is some information on the "trick" DVDdoug mentioned:
https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/