This is my code FYI:
#include <LiquidCrystal.h>
#include <DHT.h>
#define DHTPIN 5
#define DHTTYPE DHT22
const int rs = 12, en = 11, d4 = 10, d5 = 9, d6 = 8, d7 = 7;
const int RELAY1_ENABLE = 3;
const int RELAY2_ENABLE = 4;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
DHT dht(DHTPIN, DHTTYPE);
float hum;
float temp;
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(RELAY1_ENABLE,OUTPUT);
pinMode(RELAY2_ENABLE,OUTPUT);
digitalWrite (RELAY1_ENABLE, HIGH);
digitalWrite (RELAY2_ENABLE, HIGH);
Serial.begin(9600);
dht.begin();
}
void loop() {
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
if (hum < 88 ){
if (!Serial){
Serial.end();
delay(100);
Serial.begin(9600);
}
digitalWrite (RELAY2_ENABLE, LOW); // Relay 1 swtiches on when pin is set to low
digitalWrite (RELAY1_ENABLE, HIGH); // Relay 2 swtiches off when pin is set to high
lcd.begin(16, 2);
lcd.print("Bubbling");
lcd.setCursor(0,1);
lcd.print("T:");
lcd.print(temp);
lcd.print(" ");
lcd.print("RH:");
lcd.print(hum);
Serial.println(temp);
Serial.println(hum);
delay(15000);
}
else if (hum>88){
if (!Serial){
Serial.end();
delay(100);
Serial.begin(9600);
}
digitalWrite (RELAY1_ENABLE, LOW); // Relay 2 swtiches on when pin is set to low
digitalWrite (RELAY2_ENABLE, HIGH); // Relay 1 swtiches off when pin is set to high
lcd.begin(16, 2);
lcd.print("Drying");
lcd.setCursor(0,1);
lcd.print("T:");
lcd.print(temp);
lcd.print(" ");
lcd.print("RH:");
lcd.print(hum);
Serial.println(temp);
Serial.println(hum);
delay(15000);
}
}