sensing ambient (room) temperatures using cheap thermistors

Thread Starter

ag-123

Joined Apr 28, 2017
294
There are quite a few 'cheap' NTC thermistors in the 'online flea markets' e.g.
https://www.aliexpress.com/w/wholesale-thermistor.html
just about all of them claims NTC 3950 25degC with no datasheets in the tag
so I go about searching for datasheets and stumbled into one e.g.
https://www.tme.eu/Document/803044d5da776ac3c31dc4c407347b50/NTCM-HP-100K-1.pdf
I 'got lucky' and it seemed what I casually measured of a 'cheap flea market' 100k NTC thermistor conforms to the specs quite well.
(I've had once got a 3d printer in which a claimed 100k NTC thermistor measures 50k at 25 deg C ! and they 'casually' shipped that in the kit with the 3d printer, try to imagine just how wildly off plastic temperatures e.g. 200 deg C there are in the wild which accounts for the *millions* of 3d printing problems out there)

then I started with this 'naive' circuit:
thermdivider.png
well that looks quite straightforward. However, a problem is that I'm measuring ambient (room) temperatures, and that based on the tables
https://www.tme.eu/Document/803044d5da776ac3c31dc4c407347b50/NTCM-HP-100K-1.pdf
(I worked that using Steinhart–Hart equation, and the values fall quite well within range)
https://en.wikipedia.org/wiki/Thermistor
the resistance change for every degree change at room temperatures is around 2k-5k ohms.
That translates to about 2-5% change in voltages for every degree change at the divider output.
20 deg C ~ 124k
25 deg C ~ 100k
30 deg C ~ 80k
so taking VCC = 3.3v, divider output
20 deg C ~ 0.24 v
25 deg C ~ 0.3 v
30 deg C ~ 0.36 v

well what a tiny change (0.12v) for a 'whopping' 10 deg C range. and at 0.3v add a long wire to the sensor it becomes an antenna, the radio waves alone picked up adds enough signals (noise) to exceed 0.3 v !

Then I went back to the 'flea markets' and got a bunch of transistors
https://www.aliexpress.com/w/wholesale-2n2222.html
(lots of fakes, I got lucky again and got working ones, I got 1 bag which is practically just plastic with 3 leads made to look like transistors, thrown away !)
the circuit becomes this
thermbjt.png
well, this works finally, components are 'cheap', but that it is a lot of effort *calibrating* that transistor, i.e. determine the Hfe / beta )
it is a bit of surprise that an accurately measured beta / Hfe of a 'flea market' BJT runs to around 336
I'd guess this beta / Hfe value would vary between transistors.
The circuit is highly determinant on beta / Hfe the current amplification of the BJT, the load resistance R1 100 ohm is determined based on the Beta of 336 such that around ambient 100k ohms Vce (at J1) runs around 2.5v. The high amplification beta 336 is the reason a low R1 of 100 ohms is used.
(another bad news is that beta is after all not a constant fig 3
https://www.onsemi.com/pdf/datasheet/p2n2222a-d.pdf )

the workings are like
ib = (Vcc - Vbe) / R(th1)
ic = beta x ib = beta * (Vcc - Vbe) / R(th1) = 336 * (3.3 - 0.7) / R(th1)
vout = vce = vcc - V(r1) = vcc - ic * r1 = vcc - beta * (Vcc - Vbe) * r1 / R(th1) = 3.3 - 336 * (3.3 - 0.7) * 100 / R(th1) = 3.3 - 87360 / R(th1)

so that works out like
20 deg C ~ 124k ~ 3.3 - 87.36 / 124 = 2.59 v
25 deg C ~ 100k ~ 2.42v
30 deg C ~ 80k ~ 2.2v
that gives a range of about 0.4 v for that 10 deg range
 
Last edited:

Thread Starter

ag-123

Joined Apr 28, 2017
294
I'm thinking, this method is after all 'old'. With microcontrollers, it'd be after all possible to measure the thermistor resistance by charging / discharging a fixed capacitor across the thermistor.
 
Last edited:

BobTPH

Joined Jun 5, 2013
11,463
The variability of beta and slow turn on of transistors is why we do not use them as is to detect a threshold. The circuit of a comparator overcomes those shortcomings.
 

Thread Starter

ag-123

Joined Apr 28, 2017
294
well, not quite detecting a threshold, but that literally using it as an amplifier
my guess is an OpAmp would give a much better linearity (it is designed for that), but that I happened to have a bunch of transistors, and that this transistor circuit literally has a smaller component count, vs say using an Op Amp.
Actually, not quite, it'd seem like using an OpAmp may be like using one more resistor, and best of all it can be non inverting
https://www.allaboutcircuits.com/vi...ifier-configurations-non-inverting-amplifier/
 
Last edited:

Thread Starter

ag-123

Joined Apr 28, 2017
294
call it recreational research if you'd like :p
I've got a "blue pill" stm32f103 mcu board on which the mcu is literally *fake* (clone)
https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html
https://hackaday.com/2020/10/22/stm32-clones-the-good-the-bad-and-the-ugly/
and that clone mcu provides an internal temperature sensor that gives a bunch of *fake* incorrect readings.
I could have ordered a semiconductor sensor e.g. DS18B20
https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf

but that as I've a bunch of 100k thermistors and transistors on hand, decided to just go ahead and used them.
for the curious
temp.png
not too bad for a kitchen sink thermistor sensor setup
 
Last edited:

MrChips

Joined Oct 2, 2009
34,626
If you are using an MCU, simply connect the thermistor between a GPIO and GND, with a capacitor in parallel with the thermistor.
 

Thread Starter

ag-123

Joined Apr 28, 2017
294
yup @MrChips
I think using the thermistor and a capacitor in an RC circuit is probably an 'easier/better' setup to determine the resistance of the thermistor
https://en.wikipedia.org/wiki/RC_circuit
should have thought about that earlier, the thing about that little BJT amplifier is the calibration to get that transistor beta / Hfe value is 'labor intensive' with which it directly measures volts.
while an RC circuit, one'd need to work the impulse response and the time it takes to decay along that exponential curve.
\[ h_c(t) = \frac{1}{R C}e^{-t/RC} \]
 
Last edited:

MrChips

Joined Oct 2, 2009
34,626
Thermistor to MCU interface

Thermistor to MCU.jpg

Charge the capacitor to Vcc. Then switch the GPIO to input and detect the discharge time via a GPIO interrupt.
Repeat this for a fixed time period and determine frequency. For NTC thermistor, the frequency increases with temperature.
Use a lookup table to convert to temperature.
 
Top