Hello just wander if somebody can help me? i just start using the arduino, pretty much copy and paste the code, i try to build a controlled humidifier with Arduino NANO, DHT11, OLED I2C, Relay Module and a ultrasonic Mist, everything seem to work well except for the relay, when reach the desired humidity the relay stops(Low) but as its going back the relay never turn on(high) again
if (DHT.humidity >40){
digitalWrite (PIN3,HIGH);
}else{
digitalWrite, (PIN3,LOW);
}
if (DHT.temperature >30){
digitalWrite(PIN4,HIGH);
}else{
digitalWrite(PIN4,LOW);
}
This will cause lots of on/off switches when the humidity or temperature are close to the trigger level. Build in some hysteresis (e.g. switch on if <40, switch off if >50).
// delay needed between sensor reads
delay(2000);
That's one way to do this; using millis() you can get the delay while the processor can do other things in the meantime.