Another illustration that demonstrate the uses of Analog to measure the voltage of an external battery and integrate the area under the curve to arrive at the useful capacity of a battery mAH.
If you’re going to calculate the desired voltage range, you need to use the following voltage divider. The voltage divider has a following formula see below the example.
Voltage Out will be 5v ADC and Voltage In will be max voltage value to be measured.
Voltage Out = (Resistance 1* Voltage In) / Resistance 1 + Resistance 2)
VOut = (R2 * VIn) / R1 +R2)
Connect your components as shown of the diagram below and choose your resistance value base on the desired voltage range. To measure 0 ~ 10v you need to choose R1 as 100k and the R2 will be 100k, and if your choose 0 ~ 15v you need to connect R1 as 100k and the R2 will be 50k and to measure 0 ~ 25v you’re going to use the R1 as 100k and the R2 will be 25k and the last one range to measure is 0 ~ 55v you need to connect R1 as 100k and the R2 will be 10k. Test your resistors before going to hook it up to test before changing your code to gain the accurate measurement.
Here is the list resistant to calculate the range of voltage.
- Measuring 0 to 10v: R1 = 100k | R2 = 100k
- Measuring 0 to 15v: R1 = 100k | R2 = 50k
- Measuring 0 to 25v: R1 = 100k | R2 = 25k
- Measuring 0 to 55v: R1 = 100k | R2 = 10k
Required Components
- Arduino Board.
- 1x 10k Resistor
- 1x 100k Resistor
- 1x OLED Screen (Optional)
- Jumper Wires / DuPont Wires
- Solder less Bread Board
Code for Serial Communication
[crayon-6741a0fd6b733780176313/]
Code with OLED Screen on U8glib
[crayon-6741a0fd6b73c464270232/]
Download Required Libraries
Download the U8glib here | Zip