Post topics, source code that relate to the Arduino Platform

User avatar
By Brian J. Murrell
#73051 I'm going to be trying to read a thermistor.

But before I go there, I just want to test my sketch with some fixed resistors. Building a simple voltage divider on A0 using two 5K resistors I don't get a reading on A0 of 512 as I would expect. I get ~561.

The two resistors I am using both read 5.08K on a DMM so they should be pretty equal.

I tried two 1M resistors also (1.055M and 1.025M on the DMM) and I get 222 on A0.

I understand there is a 220/100 voltage divider built onto these NodeMCU boards between their 3.3V A0 and the 1V A0 of the ESP2866. Is that voltage divider causing these readings? If so, how do I normalise an external voltage divider across the internal one so that I can actually calculate the resistance of what is going to be my variable resistor in the form of a 1M thermistor?

Cheers,
b.
User avatar
By btidey
#73074 The raw ADC input on the ESP8266 chip is 0-1V with a high input impedance (~20M). The Node MCU units that have a 0-3.3V range put a resistor divider in front. I think this is normally a 220K input and a 100K to ground. So the effective input impedance is now 320K.

The source impedance will therefore be a significant factor in what result you get.

One simple strategy for your thermistor would just be to couple it between the 3.3V line and the input.

V into ADC pin (0-1V) would then be

100000 / (320000 +RT) * 3.3 where RT is thermistor resistance in ohms

or RT = 330000/V - 320000

RT 10K gives 1V
RT 100K gives 0.78V
RT 1M gives 0.25V

If the thermistor goes down to low resistance values then it would be worth adding an extra resistor from the input to ground to move the range down. It is still just simple sums to calculate the input from the resistance values.
User avatar
By Brian J. Murrell
#73105 Ahhh. Cool. Those equation/conversions seem like they are working.

But still testing with a fixed 1.050M (as read by DMM) resistor (before I add another variable to the kit) standing in as RT, I still get anywhere from 261 to 270 on A0. I never once get (even near) the 247 that a 1.050M resistor should yield.

What effect am I still seeing? Not the fluctuation range -- that I can deal with -- just that even the lowest end of the range isn't at low as it should be. Even if I sample A0 10 times and take the average it's ~268 which is quite a ways away from the 247 that it should be. It's ~8% off. Even the very closest reading is still 5% off.

If the thermistor goes down to low resistance values then it would be worth adding an extra resistor from the input to ground to move the range down.


It seems like you are describing a voltage divider in that case, yes? Or am I misunderstanding where you mean to put the resistor?

It is still just simple sums to calculate the input from the resistance values.


I must be dense. Maybe it's too late at night, :lol: but I'm still not seeing where in:

RT = 330000/V - 320000

I account for the additional resistance.

I probably need to go as low as 1K (and as high as at least 1M, maybe 2M to 3M to get a really good range -- but 1M at least) on my thermistor. But I can figure out what size resistor I will need in there once I know where to add it into the equation.