D1 Mini analog input voltage

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

D1 Mini analog input voltage

Post by kwiley » Mon Mar 28, 2022 5:31 pm

The ESP8266 has an analog input pin, but it operates in the voltage range 0V-1V, not 0V-3.3V, and clearly not 0V-5V. The D1 Mini is a wrapper around the ESP-12E/F (although later versions of the D1 Mini completely deconstructed the ESP8266 and spread its individual components out on the D1 Mini's board directly). There appears to be a fairly good consensus that the D1 Mini incorporates the necessary 3.3V->1V voltage divider to enable the ESP8266 to receive 3.3V-range analog sensor inputs.

I was testing the corresponding voltages and found that when I put 1V into the D1 Mini's analog pin, I measure .30V on the corresponding ESP-12F's analog pin, and when I put 3.3V into the D1's analog pin I measure .46V at the ESP-12's analog pin. Obviously, I don't want to test putting 5V into the D1's analog pin, but I'm surprised that providing its apparent max (3.3V) produces less than half of the anticipated voltage range at the ESP (.46V instead of 1V).

The docs (https://www.wemos.cc/en/latest/d1/d1_mini.html) clearly indicate that the D1's pin ought to be operating in the 3.3V range (in fact, somewhat concerningly, that document says the max is 3.2V; does that imply that 3.3V would damage either the D1 o the ESP-12?), so why don't I get 1V at the ESP in these experiments?

I'll admit, the ADC appears to be pre-calibrated to this .46V range. When I read the digital value from the A0 pin, I get 349 for 1V and 1024 for 3.3V (curiously, getting 1024 suggests that the minimum value must be 1, not 0). So, on one hand, it could be argued that I'm still getting the full 10-bit range available from the sensor. But I'm curious if its more like getting 9-bits (since the voltage maxes out at about half its purported range, .46V, in fact .04V less than half). It might be internally calibrated to stretch the real .46V range up to 1024 digital values just before or after the ADC, but that still implies that in terms of analog sensitivity relative to some presumed noise floor, I'm only reading .46V of signal spread, not 1V. Merely doubling the value to get .46 up to 1V doesn't give me 1V of true sensor sensitivity since it multiplies the noise along with the signal.

So, what do you think? Does the D1 Mini really only provide .46V of analog sensor range, not 1V, even if that range is internally spread out to make use of the 10-bit ADC? Or alternatively, is it actually making use of the full 1V range despite my readings of .46V and I'm just misunderstanding how to interpret reading .46V on the ESP's pin?

Thoughts?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: D1 Mini analog input voltage

Post by Roberthh » Mon Mar 28, 2022 6:33 pm

Looking at the D1 Mini schematics, it has as 220k/100k resistor voltage divider between the board's analog pin and the ESP8266 analog input, resulting in a division factor of 3.3. That matches the voltage you have seen at 1 V. I do not know how you did the measurement at 3.3 V, but it has to be done when the chip is powered. If the chip is not powered, the ESD protection diodes at the input will limit the voltage. And for that state, .46 V is reasonable (3.3 over 220k at a Si Diode). Edit: Or to be precise: 1 V over 68,75k at a Si Diode.
An ADC reading of 1024 indicates overflow.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: D1 Mini analog input voltage

Post by kwiley » Mon Mar 28, 2022 6:53 pm

I used a YwRobot power supply, which offers 5V and 3.3V. Obviously, I connected the D1's ground to the ground associated with the power supply to establish a common ground across the entire system. Then, like I said, the 3.3V input seemed to produce .46V instead of 1V.

I'll try it again with power to the D1 and see if it makes any difference.

I wonder by 3.3V overflowed the ADC. I suppose, as I admitted above, the spec actually stipulates an operating voltage of 3.2V, so perhaps the analog input really can't process 3.3V properly.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: D1 Mini analog input voltage

Post by Roberthh » Mon Mar 28, 2022 6:58 pm

The data sheet for the ESP8266 says for Vcc: Min 2.5V, Max. 3.6V, Typ 3.3V

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: D1 Mini analog input voltage

Post by kwiley » Mon Mar 28, 2022 6:59 pm

Okay. That fixed it. If I provide power to the D1, then 3.3V into the analog pin produces 1V when I measure the ESP-12's direct analog pin. I only get the .46V reading when the D1 isn't powered (even if I connect the D1's ground obviously). I didn't realize the need to power it just to get a proper voltage reading spanning the distance from the D1 analog pin to the ESP analog pin.

I'm still worried about that overflow issue. If a 3.3V signal overflows the ADC, then 3.3V sensors aren't quite operating in the D1 and ESP's intended sensor range. Could I solve that problem with an line resistor or diode to drop the voltage a little bit? It seems to me that such a compensation shouldn't be necessary. Shouldn't I be able to use a sensor directly in designs of this sort?

Thank you.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: D1 Mini analog input voltage

Post by kwiley » Mon Mar 28, 2022 7:00 pm

I wasn't talking about VCC. My questions were about the analog input pin.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: D1 Mini analog input voltage

Post by Roberthh » Mon Mar 28, 2022 7:03 pm

The ADC of the ESP8266 is not overly precise. So the 0-1 range is just typical. You can insert a series resistor into the boards ADC input, which changes the division factor. Just try some values, like 100k or less.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: D1 Mini analog input voltage

Post by kwiley » Mon Mar 28, 2022 7:07 pm

Thank you again. Appreciate the input on the matter.

Cheers!

Post Reply