Post topics, source code that relate to the Arduino Platform

User avatar
By btidey
#73113 The absolute ADC accuracy is not good so you will want to have a calibration factor in there. That can just be a fudge factor that converts the ADC reading 0-1023 into a voltage.

When using a parallel resistor from the input to ground then the equations are a little more complicated but not too much. The easiest way is to first calculate the overall parallel resistance of the RP and the 320000 input resistance of the module.

With say a resistance of 33K this would be 320K || 33K = 29915Ohms

The ADC input is still 100000/320000 = 0.3125 of the module input voltage

So RT 1M gives 3.3 * 29915 / 1029915 module voltage or 0.03V ADC
100K gives 3.3 * 29915 / 129915 module voltage or 0.237V ADC
10K gives 3.3 * 29915 / 39915 module voltage or 0.772V ADC
1K gives 3.3 * 29915 / 30915 module voltage or 1.037V ADC

As you can see this almost fits into the ADC range but the precision is going to be poor at the extremes of the range. This is sort of what you would expect as the ADC is only 10 bit and you are trying to measure a range of 1000 times. The other challenge is that I don't think the ADC is very good at near 0V input.

If you wanted better precison over the range then you would need to think about using some sort of linearising circuit for the thermistor.
User avatar
By btidey
#73114 Another technique you could use and have spare outputs is to use these to switch in different parallel resistors in an autoranging fashion, E.g one could use 1K, 10K, 100K and none to give good coverage over a wide range.

Of course this is starting to get complicated so it might be worth reviewing what sensor you are using. What temperature range are you trying to cover, and which part needs most accuracy? For example, thermistors are often used to measure / control the temperature of a 3D print head. Although one wants an indication from room temperature up to say 250C, it is at the working temperature of 180 - 250 where one wants the most accuracy so one would choose to use a low value parallel resistor to give good accuracy there at the expense of accuracy at room temperature.
User avatar
By Brian J. Murrell
#73119
schufti wrote:since you have a DMM, why not just measure the actual voltage at the A0 pin on the ESP-12 module (not at the A0 on the nodemcu) and recalculate this reading (V*1023) to compare with your adc reading?

This actually makes my NodeMCU A0 readings look even worse. The ESP-12's A0 reads 0.2385 which should be yielding a NodeMCU A0 value of 244 (0.238*1024). At the same time, the voltage on the NodeMCU's A0 is 0.735.

So the ADC readings are definitely "off". Can I count on that "off"ness as being linear across any resistance though and just simply add a calibration (i.e. fudge) factor in there as @btidey suggests?

@btidey, apologies for not being able to follow along here, but I must be misunderstanding what you are trying to express with:
btidey wrote:So RT 1M gives 3.3 * 29915 / 1029915 module voltage or 0.03V ADC

since I get a different value:
3.3 * 29915 / 1029915 = .09585208488079113324

and I'm not quite sure what 1029915 represents or where it comes from.

Many thanks for being patient with somebody who is very new to all of this.
User avatar
By Brian J. Murrell
#73120
btidey wrote:The absolute ADC accuracy is not good so you will want to have a calibration factor in there. That can just be a fudge factor that converts the ADC reading 0-1023 into a voltage.
...
As you can see this almost fits into the ADC range but the precision is going to be poor at the extremes of the range. This is sort of what you would expect as the ADC is only 10 bit and you are trying to measure a range of 1000 times. The other challenge is that I don't think the ADC is very good at near 0V input.

If you wanted better precison over the range then you would need to think about using some sort of linearising circuit for the thermistor.


Or just a better ADC.

Since in the end I will want to read multiple thermistors, perhaps ditching the ESP-12's ADC and adding a multiple input ADC with better precision is the way to go in the long term. I'd still like to be able to read the ESP-12's A0 fairly accurately in the 4-300K range though in the short term to continue to make progress with the rest of the project and add the better ADC later.

So as an aside, any suggestions for an ADC with more inputs (up to 4 perhaps) and better precision that would interface to the NodeMCU/ESP-12 nicely? Would an SPI interface be the best choice?