Building a dual thermometer display for BBQ. Temperature probes good for up to 500degF but mostly need accuracy between 100degF and 300degF. I'm using a simple divider with 9900ohm reference resistor connected to gnd and thermistor connected to +5V while tapping sense voltage between them. I'm having major problems calibrating. I've taken thermistor resistance readings at:
74degF - 10683ohm,
183degF - 9833ohm,
344degF - 922ohm.
I've tried different Steinhart-Hart calculators but I can't get this code to work. I get numbers that are way off. Does anyone see what I'm doing wrong. I've checked my wiring a number of times and can't find anything wrong. I'm using Arduino Nano.
BTW, this device will transmit temperature to a receiver.
#include <LiquidCrystal.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
LiquidCrystal lcd(11, 10, 9, 8, 7, 6); //RS, EN, DB4, DB5, DB6, DB7
int ThermPin1 = 0; // Arduino analog read pin numbers
int ThermPin2 = 1;
float Vs = 4.79; //source voltage
float Vt1, Vt2; // raw voltage from analog inputs
float V1, V2; // real volts converted from analog readings
float R1 = 9930; //value of resistor chosen for divider
float R2 = 9930; //value of resistor chosen for divider
float Rp1, Rp2; // calculated R values of thermistors ;
float logRp1, logRp2;
float T1, T2; //calculated temperatures
// coefficients from Steinhart-Hart Equation calculator
float c1 = 108.7752882e-3, c2 = -206.1903352e-4, c3 = 1075.708164e-7;
int col, row; //row and column of lcd display
int iT1, iT2;
RH_ASK rf_driver;
void setup() {
// Initialize ASK Object
if (!rf_driver.init())
{
Serial.println("Unable to initialize rf_driver.");
}
// Setup Serial Monitor
Serial.begin(9600);
lcd.begin(8, 2);
}
void loop() {
Vt1 = analogRead(ThermPin1);
Vt2 = analogRead(ThermPin2);
V1 = Vt1 * .00488; // .0048 = 5V/1023 convert ADC reading to real volts
V2 = Vt2 * .00488;
Rp1 = (Vs - V1) / (V1 / R1); // calculate probe resistance based on values of Vs, V1 and R1
Rp2 = (Vs - V2) / (V2 / R2); // Vthermistor = Vs-V2, Current = V2/R2, Rthermistor = Vthermistor/Current
// calculate temperature in Kelvin
logRp1 = log(Rp1);
T1 = 1.0 / (c1 + c2 * logRp1 + c3 * logRp1 * logRp1 * logRp1);
logRp2 = log(Rp2);
T2 = 1.0 / (c1 + c2 * logRp2 + c3 * logRp2 * logRp2 * logRp2);
//convert K to C
T1 = T1 - 273.15;
T2 = T2 - 273.15;
// convert C to F
T1 = (T1 * 9.0)/ 5.0 + 32.0;
T2 = (T2 * 9.0)/ 5.0 + 32.0;
//lcd.clear();
iT1 = T1; //convert float to int
lcd.setCursor(0, 0); //col,row
lcd.print("T1=");
lcd.print(iT1);
lcd.print("F ");
iT2 = T2; //convert float to int
lcd.setCursor(0, 1); //col,row
lcd.print("T2=");
lcd.print(iT2);
lcd.print("F ");
//for temperature coefficients see https://rusefi.com/Steinhart-Hart.html
}