temperature controlled relay coding (i think im almost there, just need a hand)

Hi everyone,

So to cut a long story short, I have a fully operational DHT22 and dual relay, my problem is that I just CAN'T figure out how to set it so that when the humidity and temperature reach certain points, the relays are activated and then deactivated at the higher threshold. I'm not sure how to tell the arduino: 'read the humidity, if its lower than 80RH, turn relay 1 on, then turn it off at 100RH. would it be something like

if(dht.humidity<80){
digitalWrite(relay1,LOW)

BUT THEN WHAT? D;

Underneath this is my VERY basic coding; please bare in mind that I first heard of an arduino about a week ago, so I'm about as beginner as it gets. Any help is massively appreciated but please try to communicate with me as if i've got a very basic grasp of all of this... I'm just a man.

Thanks in advance - Sam

#include <cactus_io_DHT22.h>
#define DHT22_PIN 2
int Humidifier = 7;
int Heater = 8;
DHT22 dht(DHT22_PIN);

void setup() {

pinMode(Humidifier, OUTPUT);
pinMode(Heater, OUTPUT);
digitalWrite(Humidifier,HIGH);
digitalWrite(Heater,HIGH);
Serial.begin(9600);
Serial.println("PROTO");
Serial.println("RH\tTemp (C)\tTemp (F)");
dht.begin();
}

void loop(){

dht.readHumidity();
dht.readTemperature();

if (isnan(dht.humidity) || isnan(dht.temperature_C)) {
Serial.println("DHT sensor read failure!");
return;
}
Serial.print(dht.humidity); Serial.print("%\t\t");
Serial.print (dht.temperature_C); Serial.print("*C\t");
Serial.print (dht.temperature_F); Serial.println("*F\t");
delay (2500);
}

It's best that you think how you would manually do it.

if (dht.humidity < 80)
{
  digitalWrite(relay1,LOW); //ON 
}

else if (dht.humidity >= 100)
{
digitalWrite(relay1,HIGH); //OFF
}

I'm just a man

Get your lady friend to help. :wink:

THANKS!

This has been driving me crazy. took me far too long summon the effort to post in this forum.

Much obliged!