ESP32 measuring ADC with high precision and wide range

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

ESP32 measuring ADC with high precision and wide range

Postby zazas321 » Thu Sep 08, 2022 12:21 pm

Hello. I am working on a project where we need to measure very small currents (<100uA)

The Hardware design is based on uCurrent Gold (https://www.eevblog.com/projects/ucurrent/).

I would also like to mention that my hardware are not great.

Please see the idea here:
https://imgur.com/1X86Q5v


My questions:

1.
In current design, there are 3 switches to select current/voltage output ratio:
1mV/mA
1mV/µA
1mV/nA


For example, in the 2nd mode (1mV/µA). If the device is drawing 100uA, the voltage output will be 100mV, but if device starts to draw 50mA , according to the current/voltage ratio, in theory, the output voltage would be 50V (but I assume the voltage output will be limited by the Supply voltage of MAX4239)

Lets assume the input voltage is 12V and I am trying to measure 50mA in 1mV/uA mode. The voltage output will be limited to 12V hence I will only be able to measure up to 12mA. In order to measure above 12mA, I would need to switch to 1mV/1mA mode. Then the output will be 50mV.

Is there a possibility to modify current design to ensure the device automatically switches to different modes when the voltage output goes beyond limit to still be able to measure the output?

2.
Is ESP32 ADC accurate and good enough to be able to accurately measure small currents? I am concerned about the accuracy of the ADC.

For example, assume I want to measure 100uA and the voltage output is 100mV (1mV/1uA mode). Is it better to measure 100mV as it is or is it better to implement some circuitry that would up the voltage level to some higher voltage so it is easier to measure it on the ESP32?
For example use a voltage divider that would increase the voltage output by 10. So if the output is 100mV, after the voltage divider I would see 1V and when I perform calculations on the ESP32 I would just simply measure the ADC and divide by 10? However, what if the voltage goes above 3.3V (Trying to measure higher than 3300uA (3.3mA). The voltage output would already be 3.3V so obviously I no longer want to use voltage divider to increase the voltage output by 10..)

Maybe its best to select some external ADC IC that is capable of measure wide range voltage. This way, I could avoid the complexity of automatically switching between modes?

User avatar
mbratch
Posts: 302
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 measuring ADC with high precision and wide range

Postby mbratch » Sat Sep 10, 2022 2:18 am

I certainly wouldn't use the onboard ADC of the ESP32 for inputs in the 100mV range. I believe the ADC is non-linear that low in the voltage range of the ADC. Also, I'm not sure I understand what you intend by, "use a voltage divider that would increase the voltage output by 10". A voltage divider reduces voltage.

In your overall design, you'll want to have a firm understanding of what the actual output voltage range is. You could then scale that voltage down to a range acceptable by the ADC. If you need precision, I would definitely go with an external ADC. They're easy to use and can connect with, for example I2C, and you can get a higher precision ADC as well. But you'll probably need to do some calculations, looking at the specs, to determine if, after scaling, you have the precision you need for your application. There are probably good alternative approaches, but I'm not sure how your "modes" work or what the specs of each are. Are they set by configuration in software, or determined some other way?

Who is online

Users browsing this forum: No registered users and 76 guests