How high am I? Knowing me I'm missing something really stupid and easy, because that's usually what gets me...
So, I'm trying to create a 2 minute timer routine that triggers off of a temp sensor so I can use my Arduino as a smart & connected thermostat for my furnace. Sadly, it doesn't seem to be working. I think I've exhausted my troubleshooting. Would someone be so kind as to review the code and see if I'm missing anything?
Thanks for your time! Cheers
#include <SoftwareSerial.h>
// Create RX/TX Serial Connection Ports to Display
SoftwareSerial comDisplay(10, 11);// ***** GLOBAL VARIABLES
unsigned long TimerFurnace = 0; //global Millis tracker
int TempSP = 70; //default temp// ***** PIN Variables
int TempSensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int WaterSensorPin = 1; // 10mV per inch, tank 40" tall (inches = read / 2), 6" is full
int LPGSensorPin = 2; // 2.1% is explosive level
int CO2SensorPin = 3; //void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitorcomDisplay.begin(9600); // set up serial port for 9600 baud
pinMode(13, OUTPUT); //Furnace relay
digitalWrite(13, HIGH); //Make sure the relay is off (inverse relay logic)}
void loop() // run over and over again
{// Turn Furnance on if below setpoint
if (insideTempReadingF < TempSP)
{
digitalWrite(13, LOW); // Furnace ON!
TimerFurnace = millis(); // start Furnace On timer, to keep it from flickering on/off//troubleshooting feedback
Serial.print("ON - Time Left: ");
Serial.print((long(millis()) - TimerFurnace) / 1000L);
Serial.print(" - Temp: ");
Serial.println(insideTempReadingF());
}else if ((millis() - TimerFurnace) >= 120000UL) //make sure the furnance has been on for at least 2 min
{
digitalWrite(13, HIGH); // Furnace off//troubleshooting feedback
Serial.print("OFF - Time Left: ");
Serial.print((long(millis()) - TimerFurnace) / 1000);
Serial.print(" - Temp: ");
Serial.println(insideTempReadingF());
}
Serial.println(insideTempReadingF() - TempSP);}
int insideTempReadingF() //Get the temperature Sensor reading, do stuff with it, and puke it out in degrees F
{
int TempReading = analogRead(TempSensorPin);// converting that reading to voltage
float voltage = TempReading * 5.0;
voltage /= 1024.0;// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree with 500 mV offset
//to degrees ((voltage - 500mV) times 100)// now convert to Fahrenheit
float temperatureF = ((temperatureC * 9.0 / 5.0) + 32.0) - 1; // "-1" is calibration offsetreturn temperatureF; // return results
}