# Voltage Measurement with ST Microcontroller

I want to measure DC voltages from 1mV to 10V.

I will be using STM32L053C8T6 Discovery board.

I want to use 3.3V reference voltage. I know that if you want to measure voltages bigger than reference voltage, you need to use voltage divider.

But what about if I want to measure voltages like 1mV? Do you have any suggestions how to do it?

That microcontroller has a 12 bit ADC, which means you get $$\\frac{V_\text{ref}}{2^{12}}\$$ as a quantization step; in your case, that's ca 0.8 mV.

In practice, you typically get noise and your Effective Number of Bits (ENOB) is lower.

So, in that case you've got two choices:

1. Use an external, higher-resolution ADC

I'll point out that being 1 mV-accurate over a 10 V span isn't trivial from an analog signal point of view, so: amplify!

You might do something like using a variable-gain amplifier (or a variable attenuation attenuator) to adjust the amplitude of your signal, if the amplified signal happens to exceed the 3.3V range (make sure to protect your IC from overvoltage).

I'm in the business of signal processing. Most people want to have 0.01 µV resolution without ever considering the quality of the signals they're digitizing – chances are, you won't be getting a meaningful signal at 1 mV resolution due to superimposed noise!

One solution to getting signals out of the noise floor (even out the lowest quantization bit, but only if you have enough noise!) is oversampling:

As you probably know, when sampling an analog signal, you need to make sure the highest frequency of the signal is less than half the sampling rate. Because of that (and you don't want all the stray higher-frequency signals to contribute noise energy), you always have an analog anti-aliasing filter, typically a low-pass filter (e.g. a simple RC) in front of your ADC.

If you now let your ADC run at a much higher rate than strictly necessary (for example: highest frequency in your signal 1 kHz, ADC sampling rate 100 kHz, hence, 50× oversampling), and then digitally low-pass filter, you get a finer quantization of the correlated signal in your observation, and an increase in SNR. Maybe that's the solution to your sampling problem!

But it's like with everything in engineering: What you should do depends on what you want to achieve, and what you have to work with; I can only encourage you to ask a question explaining your plans and the problems you've encountered when digitizing your signal – and what that signal actually is, and why you need to sample it! Such questions are always interesting.