DHT11 controlling Relay

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

DHT11.txt (3.51 KB)

Does this:

digitalWrite (PIN3,HIGH);

Make the humidifier come ON or go OFF?

  if (DHT.humidity >40){
    digitalWrite (PIN3,HIGH);
    digitalWrite, (PIN3,LOW);

  if (DHT.temperature >30){

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

That’s one way to do this; using millis() you can get the delay while the processor can do other things in the meantime.

thank you i will try this weekend i know it need some kind of reset;

goes on, and when reach the desired humidity goes off and as the humidity goes down the relay never goes on again