I got a NodeMCU/ESP8266 development board and am trying to utilise the A0 (10-bit ADC) input to read the voltage from a voltage divider on the 3.3V pin. So I have the following:
schematic
simulate this circuit – Schematic created using CircuitLab
However when I read A0, it's not the ~512 value that I'd expect for the 1.65V (as measured with a multimeter) that is on A0. It's rather somewhere around 450.
If I swap out the 100K resistors for 1M resistors (which is my target because I have a 1M thermister), the reading is even more off, around 200 where the voltage on A0 reads about 1.55V with a multimeter.
Even with 3.3V on A0, it's only reading 1016-1017 and with nothing on A0 it reads 9 which isn't hugely out, but it's still not hugely accurate either.
Is there something I am not understanding and not taking into account? I'd be interested in any insight.
-
1\$\begingroup\$ Mind using the built-in schematic editor to put the schematic up? \$\endgroup\$ThreePhaseEel– ThreePhaseEel2017年12月20日 12:44:59 +00:00Commented Dec 20, 2017 at 12:44
-
\$\begingroup\$ "... and with nothing on A0 ..." - Nothing as in floating pin? \$\endgroup\$marcelm– marcelm2017年12月20日 12:56:13 +00:00Commented Dec 20, 2017 at 12:56
-
\$\begingroup\$ @marcelm Yes. But really, a/the floating pin reading is the least of the issues. \$\endgroup\$Brian– Brian2017年12月20日 16:29:50 +00:00Commented Dec 20, 2017 at 16:29
-
\$\begingroup\$ Have you measured the resistors? Is the voltage exactly 3.3V when you are measuring it? What does the datasheet for the module say the analog input tolerance is? \$\endgroup\$Passerby– Passerby2017年12月20日 19:41:43 +00:00Commented Dec 20, 2017 at 19:41
-
\$\begingroup\$ Yes. The resistors seem within allowance. 101.55K and 101.2K. Yes, the voltage is exactly 3.3V with a multimeter and it's exactly 1.65V at the voltage divider Vout. I don't have the datasheet for the module. \$\endgroup\$Brian– Brian2017年12月21日 11:22:01 +00:00Commented Dec 21, 2017 at 11:22
1 Answer 1
There's a thing that you might be missing: the input resitence of the analog ports.
schematic
simulate this circuit – Schematic created using CircuitLab
When you use such 100k resistors you may have to consider the effect that it will cause to your measurement. I didn't find the correct input value but most microcontrollers with analog inputs has a input resistence about 1M. Let's assume that.
You'll have a parallel resistor circuit of a aprox 90.9k with 100kΩ and 1MΩ in parallel, causing the lower part of your voltage divider to be less than half. So the voltage in the measure point will be 1.57V. And 1.57*1023/3.3 = 484 bits.
And your 1M thermister will make things worse.
I would advise you to use something like an op amp with buffer configuration to measure what you want. You'll rise your input resistence. Or you could use a lower thermister. Resistors with>1M insert white noise in your circuit.
schematic
If you still suspecting of something else, use 10k resistors and see it working.