Microcontrollers like the ATMEGA’s found on Arduino’s have an ADC on board that can measure voltages from 0V up to 5V and return that as a number ranging from 0-1023. But what to do when we want to measure outside of this range?

## Extending the range

If you want to measure higher voltages than 5V, the go-to solution is using a resistor-divider network. If you use two 2k resistors in series for example, one end connects to ground, the other end to 10V, then the midway point between both resistors should measure 5V. Then in your code you can scale any reading up by two to get your actual voltage reading.

## Negative readings

If we need to read negative voltages, we have to flip the resistor-devider network up side down.

In the image below, I connected the first resistor to our maximum voltage we can read. After the first resistor, comes our readout point at ground. Over the next voltage gaps I place identical resistors to keep it visually correct and make the voltage drop identical over each resistor in the network. The last resistor connects to the lowest possible voltage we can encounter.

Now suppose we measure -5V which is not our lower limit, voltage drop over all resistors still is the same and the top is still connected to the maximum of 5V. In the image below I compressed the network together to show you what happens.

The total voltage drop is 5 minus -5 is 10V. Per resistor this is a drop ofÂ 10 divided by 3 is 3.3V. This 3.3V is subtracted from the maximum of 5V because the negative voltage pulls down over the network. This leaves a 1.6V reading for the controller.

Converting your reading back to the original voltage is not that difficult either. Subtract 1.6V from our maximum of 5V the get the voltage drop. This is 3.3V. The 3.3 is only after the first of three resistors so 3.3 times 3 is 10V. So in reality the reading is 10V lower than our maximum of 5V, 5V minus 10V is minus 5V.

After finishing the design of the network, you can simplify it. Because we only measure after the first resistor, the rest can be grouped together like in the picture below.