Hi Everyone, I'm quite new to Arduino and all the programming that goes with it, a little help would be greatly appreciated.
Ok so I am trying to control the humidity in a room with the DHT11 sensor and everything seems to be working fine my relays are activating on the correct values however I have is set to between 40 and 55% but as soon as the humidity drops below 55 it starts the humidifier, its probably working as it is supposed to, however, this happens every minute or so. How can I delay the relay to only start when the humidity reaches 40 again and not 54%
Please excuse my English not my first language
Here is my code
#include <DHT.h>
#include <DHT_U.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 8
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
const int relayPin1=6;
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
dht.begin();
pinMode(relayPin1, OUTPUT);
}
void loop() {
int h = dht.readHumidity();
int t = dht.readTemperature();
int f = (t * 9.0)/ 5.0 + 32.0;
lcd.setCursor(0, 0);
lcd.print("Baby Room");
lcd.setCursor(0,1);
lcd.print("Weather Monitor");
delay(5000);
lcd.clear();
lcd.print("Temp: ");
lcd.print(f);
lcd.print("F ");
lcd.print(t);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(h);
lcd.print("%");
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
if (h >= 40 && h <= 55 ) {
digitalWrite(relayPin1,LOW);
lcd.print("Humidifier");
lcd.setCursor(0,5);
lcd.print("On...");
} else {
digitalWrite(relayPin1,HIGH);
lcd.print("Humidifier!");
lcd.setCursor(0,5);
lcd.print("OF...");
digitalWrite(relayPin1,HIGH);
}
delay(2000);
lcd.clear();
}