Nodemcu analog input very inaccurate - sometimes

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
first post, bear with me...

I have a Nodemcu and I try to get a thermistor sensor to work using Esphome.

A fixed resistor (1kΩ) and a ntc thermistor (4.7kΩ at 25degC) as a voltage divider circuit. voltage is measured, resistance of the thermistor is calculated and converted to temperature. All seems to work, except the voltage measured is wrong. 2.7V on a trusty multimeter vs 2.9V on the analog input pin.

The pin apparently has a voltage divider, as the raw voltage is 0-1V but that is multiplied by 3.3 to get the real voltage.
Connecting a 3.3V output pin to analog in gives me a perfect 3.3V reading. But not when my resistors are connected.

What am I doing wrong? I have tried two different Nodemcu's with the same result.
 

nsaspook

Joined Aug 27, 2009
13,272
Likely high source impedance causing the sample and hold capacitor not to be fully charged during the sample time. You can add a buffer capacitor between the analog pin and voltage common of a small uf value to lower the impedance during the short sample time or increase the sample period so it has more time to top-off to the actual value.
 

nsaspook

Joined Aug 27, 2009
13,272

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
I tried it with wifi disabled, and also with the suggested capacitor, but no luck. Still very inaccurate.
The same circuit on an Arduino works like a charm.
 

Papabravo

Joined Feb 24, 2006
21,225
As you are all aware, ADC performance depends on a fairly large set of variables in a way that digital circuits do not. Many people who design digital and uP circuits fall flat on their collective faces when it comes to analog circuits. Although to implementations may appear to be superficially the same, I assure that they are not. Nature is by extensive observation entirely mechanistic. Two things do NOT behave differently for no reason. We could ultimately determine the reasons for this, but at what cost? Use the one that works -- bin the one that doesn't.
 

Thread Starter

Salmoneus

Joined Mar 18, 2020
9
As you are all aware, ADC performance depends on a fairly large set of variables in a way that digital circuits do not. Many people who design digital and uP circuits fall flat on their collective faces when it comes to analog circuits. Although to implementations may appear to be superficially the same, I assure that they are not. Nature is by extensive observation entirely mechanistic. Two things do NOT behave differently for no reason. We could ultimately determine the reasons for this, but at what cost? Use the one that works -- bin the one that doesn't.
Two microcontrollers that are good at one thing each in my case. Arduino measures analog perfectly, but no communication. Nodemcu measures analog way too badly but have communication.
 

Papabravo

Joined Feb 24, 2006
21,225
Two microcontrollers that are good at one thing each in my case. Arduino measures analog perfectly, but no communication. Nodemcu measures analog way too badly but have communication.
There is a solution to your problem, but it might cost you some $$$'s to find it.
 
Top