How to Interface 108 Thermistors with Arduino - Page 1
Forum section: electronics / general

author: Krishh
author_rank: Newbie
timestamp: February 09, 2025, 01:08:06 pm
content: Hi everyone,I am working on a project where I need to interface 108 thermistors with an Arduino to monitor temperature across multiple points. Since Arduino boards have limited analog inputs, I'm looking for the best approach to handle this many sensors efficiently. Any other board other than an Arduino will also work fine as long as it is economical to purchase. Currently, I have an Arduino Uno, ESP32 Wroom, and a Raspberry Pi Pico H.How do I go about this? Thanks in advance

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 09, 2025, 01:19:28 pm
content: You can use analog multiplexers like theCD4051to expand the number of analog channels. You would need 14 of them to make it work. Use 7 of the UNO analog channels to hook up two CD4051's on each. Use 5 digital IO's of the UNO to make up the selects. (3 selects and 2 inhibit signals.)

author: tooki
author_rank: Super Contributor
timestamp: February 09, 2025, 01:33:25 pm
content: A classic solution is multiplexers/switches. There are 32-channel models available. (Maybe more, I haven’t checked all manufacturers.)I suppose that another approach in theory would be to use plain GPIOs to energize individual thermistors, with a common ADC pin to take the measurement.Avoid the ESP32’s ADC if possible; it’s not particularly good.

author: pqass
author_rank: Super Contributor
timestamp: February 09, 2025, 02:11:05 pm
content: How far away are the thermistors from the microcontroller? < 1m > 10m ?

author: Krishh
author_rank: Newbie
timestamp: February 09, 2025, 02:57:24 pm
content: Max would be 1.5 m; its in a battery pack, and we would just want this to be a temporary solution. The actual plan is to use CAN communication, but for now we would need to use an arduino.

author: Krishh
author_rank: Newbie
timestamp: February 09, 2025, 02:59:50 pm
content: Was thinking about the same; just wanted to know if there is a better solution Looks like I'll end up going for analog multiplexers.I found this on TI's website: [https://www.ti.com/lit/ds/symlink/cd74hc4067.pdf], will this do the job?

author: Krishh
author_rank: Newbie
timestamp: February 09, 2025, 03:07:15 pm
content: Gotcha will stick to an Uno or Nano.How about this? Analog Multiplexer: CD74HCx4067https://www.ti.com/lit/ds/symlink/cd74hc4067.pdf

author: kaevee
author_rank: Regular Contributor
timestamp: February 09, 2025, 03:32:15 pm
content: Quote from: Krishh on February 09, 2025, 03:07:15 pmIf budget is not a constraint, checkout the low leakage analog MUX from TI:https://www.ti.com/product/MUX36S16

author: edavid
author_rank: Super Contributor
timestamp: February 09, 2025, 04:00:31 pm
content: Quote from: tooki on February 09, 2025, 01:33:25 pmThis is a much better approach, especially if you used a string of 74HC595s or other shift registers to drive the thermistors. That could greatly simplify the wiring, and allow for a modular design where you could easily add or subtract thermistors.What is the sample rate requirement?

author: pqass
author_rank: Super Contributor
timestamp: February 09, 2025, 04:31:46 pm
content: Quote from: edavid on February 09, 2025, 04:00:31 pmI'm failing to understand how this would work with a common ADC pin. The power to the thermistor would have to be cutoff entirely like a PNP open collector driver which the '595 is not (will sink when low).If you use a TQFP version of the ATmega328 you'll have 8 ADC pins + 8x 4067s and Bob's yer auntie, you're done.

author: mino-fm
author_rank: Regular Contributor
timestamp: February 09, 2025, 04:42:49 pm
content: What kind of thermistors? NTC, PTC, PT1000, KTY?Quote from: pqass on February 09, 2025, 04:31:46 pmI would use 14 x ATmega328 and collect data via USART using 'Multi-processer Communication Mode'.

author: edavid
author_rank: Super Contributor
timestamp: February 09, 2025, 04:43:11 pm
content: Quote from: pqass on February 09, 2025, 04:31:46 pmJust add series diodes.

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 09, 2025, 07:14:43 pm
content: Quote from: Krishh on February 09, 2025, 03:07:15 pmYeah that one will work too.

author: NorthGuy
author_rank: Super Contributor
timestamp: February 10, 2025, 06:02:55 pm
content: Make a matrix. On high side, 11 resistors and 11 ADC channels. On low side, 10 groups of thermistors. Each group consists of 11 thermistors, each of these 11 thermistors connected to its own ADC channel. Each group gets pulled to the ground by an MCU pin (one group at a time). 10 x 11 = 110 - more than you need. This way you only need 11 analog pins and 10 digital pins, and no extra parts aside of 11 resistors. It is not hard to find an MCU that would have the needed pins.

author: Kleinstein
author_rank: Super Contributor
timestamp: February 10, 2025, 06:15:37 pm
content: The matrix idea may works, but it would reduce the accuracy. The unused channels would still have a small effect.Usually one also needs more circuit than just the ADC input pins at the µC to measure a resistance.A matrix could be feasible with diodes as sensor.So what type of thermistor and what accuracy level and speed is wanted ?Depending on the accuracy needed, one may need 2 MUX channels per sensor to eliminate the switch resistance.108 channels are a lot and chances are one would divide the problem and have something like 4 completely separate units (PCBs) and join the results digitally.Already 27 sensors is quite a bit for one µC to handle, but more managable. Simply repeat 4 x is relatively easy.

author: mariush
author_rank: Super Contributor
timestamp: February 10, 2025, 06:42:52 pm
content: There's TMUX1208 or TMUX1308 (cheaper than tmux1208 but higher channel resistance) which are cheap and have very little variation between channels and low channel resistance.TMUX1208 :https://www.digikey.com/short/z9c9qqffTMUX1308 :https://www.digikey.com/short/37p29d0hYou could wire up to 128 sensors to 16 8:1 analogue muxers and you could connect these 16 analogue muxers to 2 8:1 analogue muxers so 5-6 data pins would be enough .. use a couple ADCs to read theThere's also reasonably cheap ADCs, like TLA2024 for example, which has 4 inputs and 12bit , 3.3 ksamples per second and it's small ... so with 4 of these you could skip the 2nd level of muxing and just connect the 14-16 analogue muxers to the inputs of the ADCs. ADC1283 has 8 channels and it's not much more expensive.Links to ADCs with 4 or more input channels :https://www.digikey.com/short/nmwh2905

author: mikerj
author_rank: Super Contributor
timestamp: February 11, 2025, 11:46:22 am
content: Quote from: edavid on February 09, 2025, 04:43:11 pmThe voltage output from the 595 is likely to have some temperature dependent behaviour, and the diodes certainly will. Driving the thermistors from MOSFETs switched by e.g. a 595 would mostly eliminate this, at the cost/complexity of a MOSFET per thermistor. A advantage of this scheme is that the same reference resistor is used for all thermistors, eliminating either this error contribution or tedious amounts of calibration to remove it.

author: edavid
author_rank: Super Contributor
timestamp: February 11, 2025, 03:42:26 pm
content: Quote from: mikerj on February 11, 2025, 11:46:22 amIt would have been nice if OP had told us something about his precision requirements, but since he is considering thermistor sensors and an Arduino ADC, they can't be very stringent.Since the output resistance of the 595 outputs is much lower than the thermistor resistance, there would be little temperature dependence, especially if the 595s weren't inside the battery pack. I don't think external MOSFETs would be much better than the ones inside the 595. I also don't think the diode forward voltage change would be significant, but that depends on the details that OP hasn't told us

author: coromonadalix
author_rank: Super Contributor
timestamp: February 11, 2025, 05:10:20 pm
content: all matrix and muxers are a good idea, but polling intervals, scanning speeds, time to fully read theses sensors accurately ?even some micro arduino for a few $$$ are powerful enough, you could communicate with say rs485 ?? you would only need one rs485 interface1x duino for each sensors if you want a full time, always ''on'' measurement ? use other db9 pins to supply them ?? daisy chain them ??even rj45 connectors would be fine, something like poe / power them up thru theses unused pinsfor software :https://freeserialanalyzer.com/or many free utilities ??rs232 485 loggers ?

author: prosper
author_rank: Regular Contributor
timestamp: February 12, 2025, 04:07:54 am
content: IMHO, this is exactly what those cheap 10c mcus are for. Read a few thermistors with the cheap mcu, and put the results out on an i2c or uart bus. Copy and paste as many times as you need to handle all the thermistors.

author: mino-fm
author_rank: Regular Contributor
timestamp: February 13, 2025, 11:12:26 am
content: Quote from: prosper on February 12, 2025, 04:07:54 amI don't know, which kind of sensor should be used. I don't know nothing about temperature/resolution/accuracy and I don't know nothing about speed.Please show me your 10 ct mpu that can answer my questions.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 13, 2025, 11:32:16 am
content: Quote from: prosper on February 12, 2025, 04:07:54 amDistributed multi-processing could make sense if there is some other distributed function as well. If it isjustreading temperature, then analog multiplexing of NTCs, multiplexing NTC power supplies (need open-drain drivers as explained by others!), or maybe multiplexing I2C or one-wire or whatever temperature sensors directly would be easier, mostly because then you don't need to develop, maintain and program a separate firmware for those "satellite" MCUs. It's not an impossible task of course, but in this case unnecessary complication, IMO.Related to the OP's case, I did use this hundred-MCU solution for a EV battery pack BMS design, but those MCUs were easily powered directly off the li-ion cells, and would use their internal temperature sensors to sense temperature, sense their own supply voltage as monitored cell voltage, plus offer a balancing ("consume current") feature. Since the microcontrollers all shared galvanic connection through the battery pack (going up by one cell voltage each), digital Manhester-encoded communication chain through IO pins with simple series resistor was easy to get working.If Ionlyhad to measure temperature, I wouldn't do it this way.

author: tooki
author_rank: Super Contributor
timestamp: February 13, 2025, 05:44:56 pm
content: Do they have to be thermistors? Or could you just use a bunch of DS18B20-style temperature sensors on a single 1-Wire bus?

author: Siwastaja
author_rank: Super Contributor
timestamp: February 13, 2025, 05:59:39 pm
content: Quote from: tooki on February 13, 2025, 05:44:56 pmThis, but divide them into a few buses. 1-Wire bus depends on high speed (microsecond timing), and capacitance of long wires / many tens of devices is simply too much. (For some reason I never understood, it is marketed as if it was fine with hundreds of devices and tens of meters of wire, but at least I can't make it work reliably in such extreme setups)But e.g. 14 sensors per bus * 8 buses should work, and you can just use any 1-Wire library on Arduino and re-init it to use different IO pins (and you easily can have 8 IO pins for this).I recommend providing the third wire for external power for 1-Wire sensors.

author: Kleinstein
author_rank: Super Contributor
timestamp: February 13, 2025, 08:01:45 pm
content: If one could choose the sensors, I would consider diodes. They can be used in a matirx and this way easy to get many channels with little hardware. As a downside one may need individual calibration or selecting the diodes (still feasible with a moderate price per diode).

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 13, 2025, 08:17:52 pm
content: For 1 wire I can advice to make use of the DS2482 to make the 8 busses Siwastaja mentioned.It uses I2C for communication with the MCU.I have used it in my central heating system with 88 DS18B20 sensors. The software I used wasowfson a Linux bases Raspberry PI 2B. No idea if this is also available to run on an Arduino based device.Quote from: Siwastaja on February 13, 2025, 05:59:39 pmI have managed to make it work without problems with up to 20 devices on a single bus and line lengths of more than 10 meters. I made optocoupler and DC-DC converter based galvanic separations between the Raspberry PI connected DS2482 and the actual sensors. Took a lot of tweaking on the circuit to make it work, but was able to have it still work reliable with at least 90 meters of cat 5 utp cable, where I used three wires. 5V, ground and signal. The ground and signal using a twisted pair.Quote from: Siwastaja on February 13, 2025, 05:59:39 pmThis also speeds up the scanning process when multiple sensors are on the bus and makes it work more reliable.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: February 13, 2025, 10:16:46 pm
content: Quote from: Krishh on February 09, 2025, 02:57:24 pmThe LIN bus may be easier than CAN?Quote from: Krishh on February 09, 2025, 02:59:50 pmYes, sure, a couple of those will do a 16x16 matrix, using 8 MCU pins to select and an ADC to read. Fine for a temporary solution.

author: tooki
author_rank: Super Contributor
timestamp: February 14, 2025, 01:07:14 pm
content: Quote from: Siwastaja on February 13, 2025, 05:59:39 pmOP said maximum 1.5m, so splitting into multiple buses might not even be necessary.

author: ledtester
author_rank: Super Contributor
timestamp: February 14, 2025, 04:18:05 pm
content: Based on the datasheet:https://www.analog.com/media/en/technical-documentation/data-sheets/DS18B20.pdfit seems it takes about 20 bytes of communication just to read the temperature from one sensor.The transmission speed of 1-wire is 16.6K bits/second (each bit takes 60us) so if all 108 sensors were on a single bus it would take about 1 second to get all the readings:108*20*8 = 17280 bitsIn any case, the conversion time is 90ms on the lowest resolution (see Table 2 in the datasheet) which limits the sample rate to about 10 samples per second at most.

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 14, 2025, 05:04:25 pm
content: Temperatures normally do not vary that fast. Not sure about what it is like within a battery pack, but I suspect that within normal use it will not matter that much if a reading is only once a second.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 14, 2025, 07:42:04 pm
content: Quote from: tooki on February 14, 2025, 01:07:14 pmIn this case not because of wire length, but because of the number of sensors.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 14, 2025, 07:43:14 pm
content: Quote from: pcprogrammer on February 14, 2025, 05:04:25 pmOne reading every 30 seconds is definitely more than enough for a battery pack. Even the sensors themselves have enough thermal mass that nothing happens at <15 second level.

author: mino-fm
author_rank: Regular Contributor
timestamp: February 15, 2025, 10:39:25 am
content: Ten years ago I used Arduino UNO R3 to sample up to 6 x KTY81 as shown below.PB.0 is activated with 0.1 s period for <= 1 ms until all channels are read. A duty ratio of 1:100 will avoid internal heating of sensors. Ratiometric measurements don't care about absolute value of Vref.Today I would use a STM32G0xy for >= 8 input channels with 12 bits of resolution and about 11 ENOB. Because of stable HSI clock no external resonator or crystal is required.

author: pqass
author_rank: Super Contributor
timestamp: February 15, 2025, 03:13:52 pm
content: I don't think anyone has mentioned it so far but input conditioning should be used to position the signal such that the entire ADC range is used.For example, between -10°C to +50°C, theKTY81/110returns 747R to 1209R and 1000R at 25°C if the sensor is provided with 1mA. Assuming a 1000R bias resistor and 2Vref, then the mid-point of the divider only moves between 860mV and 1090mV or between 438 and 560 in (10 bit) ADC values without any range maximization. Unfortunately, the ATmega328 only provides a 1.1Vref which is 0.55mA to the sensor thus the resistances in Table 7 of the PDF will be different.Whether a diode (-2.2mV/°C) or diode-connected-transistor (-???mV/°C) is used instead, ADC range maximization should still be needed.See "Using a 2n2222 as Temp. Sensor"here. A summing amplifier is used to sum the raw signal with a counter voltage (via offset pot) to position the 0°C point and gain (via feed-back pot) to maximize the output range. Although, you probably can remove the need for a negative offset adjustment voltage if you position 0°C to be up at a 1/6th of the Vref.Also, the sensor may not be linear so you'll have to compensate via lookup table or more complex formula.

author: Kleinstein
author_rank: Super Contributor
timestamp: February 15, 2025, 04:14:29 pm
content: There quite different thermistors. The KTY81 and similar are relatively linear. AFAIR they get about linear in in the voltage when combined with some 2.7 K.So one could use 2.7 K to 5 V supply and than a divider to some 2 to 2.5 V for V ref. This way one gets a little more resolution, though still quite a bit of the ADC range not used.The PTC with more exponential response give much more change in the resistance (e.g. 4.5% per K compared to some 0.6 % for the KTY81). This can be enough to get reasonable resolution (though a limited range) with only a resistor. The response is however nonlinear.For a Diode as sensor one could use the 1.1 V reference and this way get some 0.5 K resolution from the usuaul 2.2 -mV/K and a 10 bit ADC. This is not great, but could still be good enough.

author: NorthGuy
author_rank: Super Contributor
timestamp: February 15, 2025, 04:33:52 pm
content: Quote from: pqass on February 15, 2025, 03:13:52 pmNot really. A few years back I used NCU18XH103F60RB. I had no problems getting 0.5 degree resolution with simple voltage divider between the thermistor and a 10k resistor. My chip had a 12-bit ADC, so there wouldn't be a problem to get 0.1 degree resolution. For batteries, 1 degree is probably enough, which you can get even with an 8-bit ADC.For batteries it is more important to ensure good thermistor placement, so that it measures the temperature of the battery, not the surroundings. Otherwise, you can easily get several degree error.

author: mino-fm
author_rank: Regular Contributor
timestamp: February 15, 2025, 05:12:42 pm
content: Quote from: pqass on February 15, 2025, 03:13:52 pmPB.0 is used as output to supply the sensor dividers. Vref is input and supplied by PB.0 output too, maybe 4.5 V.As told before, today I would use a controller with 12 bit ADC still not knowing what is really needed.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 15, 2025, 06:11:20 pm
content: Quote from: NorthGuy on February 15, 2025, 04:33:52 pmI agree. Nowadays 12-, even 14-bit ADCs integrated into MCUs are cheap and very linear. By careful analog design you could extract maybe 1-2 more bits of dynamic range. But because it is rarely a limiting factor anyway, this effort is wasted. Scaling values in software is trivial, and you need to do it anyway.If you try to do as qpass says and use the "entire range" of ADC, that would imply amplification, i.e., an opamp, which can then add new sources of inaccuracy, and unnecessary clipping if you later understand that you wanted 10degC more range.Of course, one should paysomeattention to how they e.g. choose a reference (pull-up or pull-down) resistor for an NTC. For example, for a 10kOhm NTC a 5kOhm fixed resistor works better than e.g. a 20 kOhm resistor when temperatures to be measured most accurately are in range of, say, 30 - 100 degC. Choosing a 100kOhm resistor would be then a bad idea. But all this does not take too many minutes to figure out in Excel; NTC manufacturers helpfully publish spreadsheets of resistances at different temperatures.

author: pqass
author_rank: Super Contributor
timestamp: February 15, 2025, 06:16:05 pm
content: Quote from: mino-fm on February 15, 2025, 05:12:42 pmI think using PB0 as an output and AREF (the Vref in/out) pin as input (ie. "analogReference(EXTERNAL)") to track its voltage is not much better than just connecting AREF to Vcc. Using the AREF pin as an output (ie. "analogReference(INTERNAL)") would be quieter and independent of Vcc level without using the extra PB0 pin. Although, it would be better to drive the thermistors via 2x opamp buffer that way the 1090mV to 860mV (+50°C to -10°C) divider mid-point fits nicely in the top quarter of the ADC range. This still gives 0.26°C resolution without the offset+gain, per channel, that I proposed previously.

author: Kleinstein
author_rank: Super Contributor
timestamp: February 15, 2025, 07:31:27 pm
content: Quote from: Siwastaja on February 15, 2025, 06:11:20 pmTo get good signal swing from a resistive sensor it is usually better to have the series resistor larger than the sensor, not smaller. So 10 K sensor and 20 K of fixed resistor absolutely makes sense. This is especially the case when the ADC can use a reference that is smaller than the voltage driving the half bridge. Things can be different with highly nonlonear NTCs, that can change a lot from nominal resistance.

author: NorthGuy
author_rank: Super Contributor
timestamp: February 15, 2025, 10:10:06 pm
content: Quote from: Kleinstein on February 15, 2025, 07:31:27 pmThe voltage on the ADC isVt = V*Rt/(Rt+Rh)whereV is VDDRt is the resistance of the thermistorRh is the resistance of the high side resistorWe want to make Vt as much sensitive to Rt as we can. Thus, we calculate the sensitivityS = dVt/dRt = VRh/(Rt + Rh)^2We need to select Rh which maximizes S. The S function has one maximum which is obtained when the differential dS/dRh is zero.dS/dRh = (V(Rt+Rh)^2 - VRh*2(Rt+Rh))/(Rt+Rh)^4 = V(Rt-Rh)/(Rt+Rh)^3This is equal to zero when Rt = Rh. Hence, the best Rh is equal to the expected resistance of the thermistor Rt at prevalent temperatures.

author: mikerj
author_rank: Super Contributor
timestamp: February 17, 2025, 10:51:20 am
content: Quote from: Kleinstein on February 15, 2025, 07:31:27 pmAll NTC thermistors are highly non-linear AFAIK, thus the challenge with getting a good curve fit over the full temperature range without a ridiculous number of terms, though linear PTC thermistors are available. If the fixed resistor is reasonably close to the NTC resistance in the middle of the required temperature range this provides both a useful amount of linearisation and improves resolution (assuming it will be quantised by an ADC).