Hi All
Firstly - Amazing forum - All of my programming questions have so far been answered by reading previous posts and trying the suggestions already given.
But I have built my code and tested my setup and unfortunately it isn't working....well it is but it frequently locks up. Basically this is a differential temperature controller - albeit a very basic one. It seems once it reaches its "switch on" temp the LCD stops displaying both tempreature readings, and 9 out of 10 times when turned on it also doesnt display the temp.
I have removed all delays as I suspected they were the issue but this hasnt helped.
Any guidance you can provide will be much appreciated.
Thanks Mike
#include "DHT.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define DHTPIN 26// what pin we're connected to
#define DHTPIN2 28// what pin we're connected to
#define DHTTYPE1 DHT22 // DHT 22 (AM2302)
#define DHTTYPE2 DHT22 // DHT 22 (AM2302)
const int diffON = 1;
const int diffOFF = 0.5;
const int RELAY1 = 42;
DHT dht1(DHTPIN, DHTTYPE1);
DHT dht2(DHTPIN2, DHTTYPE2);
void setup() {
Serial.begin(9600);
dht1.begin();
dht2.begin();
pinMode(RELAY1, OUTPUT);
digitalWrite(RELAY1, LOW);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Ret: ");
lcd.setCursor(0,1);
lcd.print("Sol: ");
}
void loop() {
float t0 = dht2.readTemperature(); //roof/solar temp
float t1 = dht1.readTemperature(); //pool return temp sensor
if(t0 > (t1 + diffON))
digitalWrite(RELAY1, HIGH);
do{
}while(t0 > (t1 + diffOFF));
digitalWrite(RELAY1, LOW);
lcd.setCursor(4,0);
lcd.print(t0);
lcd.setCursor(4,1);
lcd.print(t1);
}