I am trying to construct a temperature monito using a 10 K thermistor. The thermistor I am using is a Tecmar 082 .I have tried several different scenarios but my results are less than positive.
Currently using Windows 10 home , ide 2.3.2 and Arduino Uno. Pretty straight forward, voltage divider 10k resistor,10 K Thermistor Ao to uno at junction aref to one side of divider and gnd to the other .This was a suggestion in the program to get a better reading because of the noise generated from the Uno.
Nuf said there, as the temperature goes up my temperature in C does down, that is back wards as to what I should be getting, example room temp is 71 deg reads 23.3 C .Decided to use a water bath at 118.7 deg and the reading went to 12-13 C , that should have been closer to 49 C.
decided to read resistance of sensor in open air and got 9.9k ohms.I ajusted the divider to accomidate that as a divider and it didn't help .Seems to be working in reverse.
//
// SPDX-License-Identifier: MIT
// Thermistor Example #3 from the Adafruit Learning System guide on Thermistors
// Overview | Thermistor | Adafruit Learning System by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and consider buying parts from Adafruit
// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}
void loop(void) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert absolute temp to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
delay(1000);
}
Larryfos
I am trying to construct a temperature monito using a 10 K thermistor. The thermistor I am using is a Tecmar 082 .I have tried several different scenarios but my results are less than positive.
Currently using Windows 10 home , ide 2.3.2 and Arduino Uno. Pretty straight forward, voltage divider 10k resistor,10 K Thermistor Ao to uno at junction aref to one side of divider and gnd to the other .This was a suggestion in the program to get a better reading because of the noise generated from the Uno.
Nuf said there, as the temperature goes up my temperature in C does down, that is back wards as to what I should be getting, example room temp is 71 deg reads 23.3 C .Decided to use a water bath at 118.7 deg and the reading went to 12-13 C , that should have been closer to 49 C.
I didn't study your code, but if it's operating "backwards" then your voltage divider is "backwards".
That's not correct. Aref is not an output... You can optionally use it as an input and supply an external reference. Most of the time, nothing is connected to Aref.
And the default Aref is Vcc so any if you connect the voltage divider to Vcc, any noise from the power supply (which is also the reference) gets canceled out (the voltage ratio remains correct so the ADC reading remains correct.)
If you have noise issues (which can happen with 10K and long unshielded connections) a capacitor between AO and ground (0.1uF or higher) should help, and/or you can smooth or average the readings.
Thanks all , didn’t even think of that, I’ll revers the resistance connection as cyou suggest and will just use the 5va demo I watched it suggested to use the aref to help reducusing-a-thermistore noise so I did that. Thanks DVDoug and JCA34F .
So I did reverse my connection to the divider and it is doing what it should, now I will adjust resistance to correct the error. Unless I misunderstood , here is the example I was using to power it with the 3.3 and aref.
I've found "steinhart" to be a PIA with little benefit. Make a table and use the map() function to interpolate.
Also when testing forget the average and temp conversion and print out the raw counts. When you have that working the way you want, then add in the conversion. hint, make the conversion a function (aka subroutine). Then you can easily change it without touching your main code.
Using/calibrating a thermistor can be a PITA. Why not use a factory calibrated digital temp sensor, like the DS18B20, and leave thermistors for single temp points like thermostats.
Leo..
I plan on inserting this probe into the fireplace , on the interior wall by the existing snap disc switch which is not very accurate. It keeps blowing cold air. Then the next step would be to try to figure out how to control the fan operation. Currently it has a rehostat for speed control. I doubt I can do anything with that but I could use a current sensor in series wit the AC voltage to shut it off . At least that’s my plan.
Things are starting to work , just having some lcd.print errors. I can Serial.print (steinhart):
but when i try to use the lcd statement it tells me that steinhart was not declared . I will have to try to figure this out.
The smoothThermistor library works well for me, library is in the IDE library manager.
/*
* This file is part of SmoothThermistor.
*
* Copyright (c) 2016 Gianni Van Hoecke <gianni.vh@gmail.com>
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* User: Gianni Van Hoecke <gianni.vh@gmail.com>
* Date: 23/05/16
* Time: 20:19
*
* SmoothThermistor (https://github.com/giannivh/SmoothThermistor)
* A flexible thermistor reading library.
*
* The components:
* - Thermistor (here a 10K thermistor is used)
* - Resistor (here a 10K resistor is used)
* - Some wires
*
* The easy circuit:
*
* Analog pin 0
* |
* 5V |-----/\/\/\-----+-----/\/\/\-----| GND
*
* ^ ^
* 10K thermistor 10K resistor
*
* The advanced circuit:
*
* AREF Analog pin 0
* | |
* 3.3V |-+---/\/\/\-----+-----/\/\/\-----| GND
*
* ^ ^
* 10K thermistor 10K resistor
*/
// include the SmoothThermistor library
#include <SmoothThermistor.h>
// create a SmoothThermistor instance, reading from analog pin 0
// using a common 10K thermistor.
//SmoothThermistor smoothThermistor(A0);
// if you have a different type of thermistor, you can override the default values
// example:
SmoothThermistor smoothThermistor(A0, // the analog pin to read from
ADC_SIZE_10_BIT, // the ADC size
10000, // the nominal resistance
10000, // the series resistance
3950, // the beta coefficient of the thermistor
25, // the temperature for nominal resistance
10); // the number of samples to take for each measurement
void setup() {
// set up UART
Serial.begin(9600);
// use the AREF pin, so we can measure on 3.3v, which has less noise on an Arduino
// make sure your thermistor is fed using 3.3v, along with the AREF pin
// so the 3.3v output pin goes to the AREF pin and the thermistor
// see "the advanced circuit" on top of this sketch
// smoothThermistor.useAREF(true);
}
void loop() {
// print the temperature
Serial.print("Temperature = ");
Serial.println(smoothThermistor.temperature();
// pause for 2 seconds
delay(2000);
}