Wind & Wet

Arduino data logger - Voltage measurement

Most of the time the voltage will be held to around 12V by the battery, however, if the battery is disconnected the voltage in the circuit can rise much higher. I wanted a means of isolating the Arduino from any voltage over 5V.

Initially, I experimented with a simple voltage divider with a 4.8 volt zenner diode across the Arduino input to control any over voltage. This worked to a point, but the zenner diode did not have a clean cut off point and voltage went off the linear well before 4.8 volts.

In the end I simply used a voltage divider to drop the input voltage to a low value (approx 1/28 of the input) and then the same MPC6283 rail-to-rail op amp used in the current measurement to amplify the signal back to the required value. When the input voltage goes out of range the op amp is saturated but the voltage into the ADC does not exceed 5V.

The circuit used is:

Voltage measurement circuit
  • The voltage divider R1 and R2 reduces the input voltage bt 1/28. If the typical range was 0-20V the voltage divider would be less than 1 volt. It would take a voltage of 5 * 28 = 140V to exceed the 5V limit on the op amp and this should be protected by the zener diode anyway.
  • The op amp is used in non-inverting mode. The gain is calculated from 1+(R2/(R1+P1). This gives a gain of 1+(39000/2200) = 18.7 to 1+(39000/22200) = 2.7 with a potential input voltage range of 7.5V to 51.8V


It is quite easy to apply a voltage near to the maximum across the sensor using some batteries and then adjust the gain so the ADC value is around the maximum value of 1023. (I used several 9V cells clipped together with a potentiometer as a voltage divider as a source). I plotted a graph of voltage against ADC value and deliberately went over scale to check the linear range. The trend line is calculated from just the linear portion of graph.

Graph of voltage against ADC reading
  • As I mentioned in the current measurement section the voltage is not smooth but rectified AC (single phase in this case). The peak voltage will be √2 = 1.4 times the average voltage.
  • The voltage being measured is rectified AC, not smooth DC. The Arduino software needs to sample the voltage a number of times over each cycle to correctly calculate the average.
I do not warrant the correctness of this content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted the terms of use. Copyright © 2024. All Rights Reserved. Privacy policy