How to read high voltages on microcontroller?

A simple resistive voltage divider will achieve what you want.

Voltage Divider

The formula to calculate the output voltage is:

Formula

So if we assume your input voltage ranges from 0-50V, we need to divide it by 10 to achieve 0-5V. If we also assume we want to load the input voltage with 100kΩ, then the calculations would something like:

Vout / Vin = R2 / 100kΩ

0.1 = R2 / 100kΩ -> R2 = 10kΩ

R1 = 100kΩ - R2 = 90kΩ

So R1 = 90kΩ and R2 = 10kΩ

For an ADC requiring a maximum source impedance, you must make sure the voltage divider impedance is below this level. The impedance at the divider can be calculated as R1||R2.

For <2.5kΩ, the above won't meet this requirement as 10kΩ||90kΩ = 9kΩ
If we use 9kΩ and 1kΩ though, we get 1 / (1/1000 + 1/9000) = 900Ω

Bear in mind the lower the resistance the higher the wattage rating resistors you need. 50V / 1k = 50mA -> 50mA * 45V = 2.25W across the top resistor (0.25W across the bottom)
In these cases it's best to use an opamp buffer in between a high resistance divider and the ADC. Or use a 2kΩ and 18kΩ divider, which is not quite as power hungry as the 1k/9k version.


To add to Oli's answer:

enter image description here

The Schottky diode protects the opamp's input against overvoltage in case the input voltage would exceed the maximum specified 50 V. This is a better solution than the 5 V zener which is often placed in parallel with the 3 kΩ resistor. The 5 V zener voltage requires several mA, if the current is much lower the zener voltage will be lower as well, and the diode may clamp the input to for instance 4 V, or even lower.

The 27 kΩ resistor will allow 2 mA, isn't that enough for the zener? I might, but that's not what the zener will get; most of that 2 mA will pass through the 3 kΩ resistor, leaving only tens to hundreds of µA for the zener, which simply is too little.

Select a Schottky diode with a low reverse leakage current, so that the 5 V supply voltage doesn't influence the divider too much.


For an isolated measurement, you can use a voltage transducer, e.g. LEM's LV-25 or similar.

But a much easier way if you don't need isolation is to just use a voltage divider:

enter image description here