Hi all. I am trying to get the average room temperature of a 'larger' space using four to five NTC 20k 3950B Thermistors. I looked at some examples on how to wire and program it up to an Arduino Uno, interpreting some code and examples online. Once I had one thermistor hooked up and accurately reading temps, I cleaned up the code a little bit and moved onward to hooking up multiple in a series.
I figured that if I soldered together four thermistors in a series, the total nominal resistance could just be multiplied by the quantity of probes (in this case 4). So in my example, if I am using four 20k thermistors, then I should be able to change my values to 20,000 * 4 == 80,000. The B value (3950) should stay the same, since the probes are all of the same type and have identical curves in proportion to temperature. The only other thing I thought could potentially change would be the nominal temperature, which is typically the resistance at a given room temperature (typically 25C).
Anyway, I tried multiplying these resistance values by a factor of 4 and my temperature values were pretty far off. I had my values being reported over the Serial port for debugging. When I take the probes out of the voltage divider circuit and measure them in a series at around room temperature using a multi-meter, I was getting about 90k which sounds in the right ballpark. This what also showed up on the Serial monitor when printing as well, so it sounds like the calculation and math from the original voltage divider circuit translates OK.
I am using a single 20k ohm resistor as the 'static' resistor on the voltage divider circuit in order to calculate the unknown thermistor resistance by measuring the analog voltage on the ADC of the Arduino. This calculated ADC value also checks out on the multimeter, so I believe that eliminates that as a potential issue too.
The only thing I could not easily understand through some of the online examples/tutorials were the steinhart equations. These were what translate the resistance values into a identifiable temperature. I found the online explanation to be lackluster and the code a bit sloppily presented, so I just copy/pasted that part and integrated it into my code.
Although I had it working perfectly before with a single Thermistor, I am fairly certain that there is something that needs to be tweaked in these calculations to get four to work in a series together. I also thought perhaps there may be some other hardware based thing I might be overlooking, since I am still mostly a novice with electrical components.
Any help would be appreciated. I'll leave my chicken scratch code here for you to look over.
// thermistor-1.ino Simple test program for a thermistor for Adafruit Learning System
// https://learn.adafruit.com/thermistor/using-a-thermistor by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and consider buying parts from Adafruit
bool debugging = true;
/*
* ____________HARDWARE ENVIROMENT PERAMETERS______________
*
*/
const int numAnalogPins = 5; // Number of physical connections to enable.
int pinLogicTable[5] = {A0, A1, A2, A3, A4}; // Array to index logic pins.
float pinSupplyVoltage[numAnalogPins];
float ViTable[numAnalogPins]; // Array to store the calculated input voltages for each channel.
float VoTable[numAnalogPins]; // Array to store the calculated output voltages for each channel.
float R1Table[numAnalogPins]; // Array to store the calculated resistance of each channel.
float tempTable[numAnalogPins]; // Array to store the calculated resistance of each probe (C).
/* _____________THERMISTOR PERAMETERS______________
*
*/
// Pin I/O for reading temperatures. (Deprecated).
int THERMISTOR_PIN_1 = A0;
int THERMISTOR_PIN_2 = A1;
int THERMISTOR_PIN_3 = A2;
int THERMISTOR_PIN_4 = A3;
int THERMISTOR_PIN_5 = A4;
// Thermistor Resistance Rating (at 25C).
int THERMISTOR_NOMINAL = 20000 * 4;
// The beta Coefficient of the thermistor (usually 3000-4000)
int B_COEFFICIENT = 3950;
// Secondary resistor value (in ohms). Used as a voltage divider to calculate the change in the Thermistors resistance.
int SERIES_RESISTOR = 20000;
// The value of the power supply voltage
float SUPPLY_VCC = 5.0;
// Temperatures for nominal resistance (This is almost always 25 C)
int TEMPERATURE_NOMINAL = 25;
// Number of times to resample. More samples means better accuracy at the cost of latency.
int NUM_SAMPLES = 16;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
// Read all voltages on the ADC.
for (int i = 0; i < numAnalogPins; ++i){
// SAMPLE SMOOTHING:
float sampleAverage = 0; // Store average resistance value.
// Resample analog port 'x' times for better accuracy.
for (int j = 0; j < NUM_SAMPLES; ++j) {
sampleAverage += analogRead(pinLogicTable[i]);
}
// Find average from 'x' amount of samples.
sampleAverage /= NUM_SAMPLES;
// If resampling is > 1, it will save the AVERAGE from all samples.
ViTable[i] = sampleAverage;
}
// Find the output Voltage (from the voltage divider circuit).
for (int i = 0; i < numAnalogPins; ++i){
VoTable[i] = (SUPPLY_VCC / 1023) * ViTable[i];
}
// Find the unknown resistance value of the Thermistor, using a Series resistor of known value.
for (int i = 0; i < numAnalogPins; ++i){
R1Table[i] = ( (SUPPLY_VCC * SERIES_RESISTOR) - (SERIES_RESISTOR * VoTable[i]) ) / VoTable[i];
}
// Convert the resistance to Temperature (C).
for (int i = 0; i < numAnalogPins; ++i) {
float steinhart;
steinhart = R1Table[i] / THERMISTOR_NOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= B_COEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURE_NOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
tempTable[i] = steinhart;
}
// Report debugging information over serial.
if(debugging){
for (int i = 0; i < numAnalogPins; ++i){
Serial.print("Pin Logical Address: ");
Serial.print(pinLogicTable[i]);
Serial.print(" Supply Voltage = ");
Serial.print(SUPPLY_VCC);
Serial.print(" PWM In: ");
Serial.print(ViTable[i]);
Serial.print(" Voltage Out: ");
Serial.print(VoTable[i]);
Serial.print(" Thermister Resistance: ");
Serial.print(R1Table[i]);
Serial.print(" Probe Temperature (C): ");
Serial.print(tempTable[i]);
Serial.println();
}
Serial.println();
}
delay(2000);
}
Serial monitor:
Pin Logical Address: 14 Supply Voltage = 5.00 PWM In: 171.88 Voltage Out: 0.84 Thermister Resistance: 99040.00 Probe Temperature (C): -12.81