Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By hundsmiachn
#60911 Hi

Thanks for your tips. Is 3.3V enough voltage at the gate for the 2N7002 ? I thought mosfets aren't very suitable for voltages around the 3V. As I remember I dont need any additional resistors to switch the mosfet, neither on the gate or the drain, is that correct ? I will try the 2n7002 with the 10k in parallel to the thermistors, just have to wait for the order I just placed at ali... (-:
I will also look the adc descriptions to get more infos about the adc input, thanks for that.

But how do I correct for the parallel 10k resistor in the software to get the correct reading ?
Before, the code to get the temp would look like this:

Code: Select allRs = 64000; //64k resistor
Vcc = 3.3;

V_NTC = adc_val/1024;
R_NTC = (Rs * V_NTC) / (Vcc - V_NTC);
R_NTC = log(R_NTC);
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * R_NTC * R_NTC ))* R_NTC );


Rs would have to be 27000 (next value of E12) now, but how do I correct for the parallel 10k ??

thanks for your help
regards
Erich
User avatar
By hundsmiachn
#60947 Hi

Just another idea I just had. What about swapping the thermistor with the resistor ? The ADC would then be in parallel to the resistor. If I make it 560R, the range for the thermistor would be at 1280R for lowest restistance (90C). And if the transistors are all off, the ADC would be pulled down to ground.
Do I miss something here? The only thing I would have to take care, that the temperature must not be over 90C, only then the voltage at the ADC pin would be higher than 1V.

thanks
regards
Erich
User avatar
By warwick
#60955 Erich,

There are a couple of advantages to having the NTCs switched to GND in parallel with say a 10k resistor as proposed:

- if the NTC is open circuit or short circuit for any reason (I assume you may perhaps be planning on the three NTCs being plugged in and measuring somewhere off the board), the voltage to the A/D remains within range.

- if you turn on a GPIO (switching on another NTC) by mistake before turning off the previous one, voltage to the A/D remains within range.

- you have essentially infinite temperature measurement range (NTC resistance can vary between 0 to infinity) - however resolution (A/D counts per degree) will reduce towards the extremities.

- you can select the parallel resistor to give you maximum measurement resolution around a point of interest within the range (assuming there is one). For example, if you are normally measuring room temperature (25C) and your NTC is 10k at 25C, you can choose the parallel resistor to also be 10k - and the pull-up resistor from 3.3V to be 23k (could be 22k + 1k if you want to use E12). Or, if you wanted to maximise resolution across your range of 0-90C, you could choose the parallel resistor to match your NTC resistance at 45C (midpoint of your range of interest) - and select the pullup resistor appropriately to give you 1V to the a/d converter when the NTC is open circuit.

If you decide to go with this configuration, you can calculate the NTC resistance based on the resistance calculation you previously showed - where the resistance you calculated is that of the fixed resistor and NTC resistor in parallel.

For parallel resistance, Rtotal = (R1 x R2) / (R1 + R2)

Assuming R1 is the NTC and R2 is fixed resistor and solving for R1:

Rntc = R1 = (R2 x Rtotal) / (R2 - Rtotal)

Depending on what accuracy you need for your temperature measurements, you may wish to chose a reference voltage - such as 2.5V from a TL431 - for the high side of your resistor divider, rather than the 3.3V supply to the ESP8266, which I am guessing may typically have a tolerance of +/-5%.
User avatar
By hundsmiachn
#60964 Hi

Thanks for your reply. You have some good points here. I think I will try your solution with a 4k7 in parallel, so I dont have to care for any short curcuits or anything like that. I only have to figure out how I can recalculate to the right value in the software.
My approach would be: (4k7 @ ~46C)
Code: Select allVcc ---- 12k(V1) ------ ADC ----- Temp(V2)  ----- GND
                              | --- 4k7 --- |


example: (3939R should be about 51C)
ADC value = 512 --> V2 = 0.5V --> V1 = 2.8V
--> Rges = 12000 * 0,5 / 2.8 = 2143R
--> Rntc = 2143 * 4700 / (4700 - 2143) = 3939R
--> Rt = ln(Rntc) = 8,28
--> T = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Rt * Rt ))* Rt ) - 273,15= 47,6C
Where could I find better coefficients (thermistor would be a MF52AT with 1%), because now the value would be 3C off ?


thanks for your help
regards
Erich