Greetings,
I have been working on this little project and i need to have the readings from the DHT11 sensor switch relays on or off. I am still very new to coding and have been struggling to make sense of aspects of it. This code all compiles fine and the DHT 11 sensor is outputting values but none of my relays are cycling. assistance and guidance would be appreciated.
#include <dht11.h>
#define DHT11PIN 2 //temp sensor
#define Relay1_pin 4 //pin for heat loop
#define Relay2_pin 6 //pin for cool loop
#define Fan_pin 7 //pin for fan
dht11 DHT11;
void setup()
{
Serial.begin(9600);
pinMode(PIN4, OUTPUT);
pinMode(PIN7, OUTPUT);
pinMode(PIN6, OUTPUT);
}
void loop()
{
Serial.println();
int chk = DHT11.read(DHT11PIN);
Serial.print((float)DHT11.temperature,2);//prints temp in serial
Serial.print(",");//prints comma in serial
Serial.print((float)DHT11.humidity,2);//prints humidity in serial
//Serial.println();//carriage return
if (DHT11.temperature <33)
{
digitalWrite (PIN4,HIGH); //heat on
digitalWrite (PIN7,HIGH); //fan on
}else{
digitalWrite (PIN4,LOW); //heat off
digitalWrite (PIN7,LOW); //fan off
}
if (DHT11.temperature >36)
{
digitalWrite (PIN6,HIGH); //cool on
digitalWrite (PIN7,HIGH); //fan on
}else{
digitalWrite (PIN6,LOW); //cool off
digitalWrite (PIN7,LOW); //fan off
}
delay(5000);
}`Preformatted text`