DHT22 Sensor With Relay is not working
board : arduino mega 2560
my code
when humidity > 90 why relay not working???
sorry language english not primary language
#include <simpledht.h>
int pindht22 = 22;
simpledht22 dht22;
int fanrelay = 13;
void setup() {
serial.begin(9600);
}
void loop() {
// start working...
serial.println("=================================");
serial.println("sample dht22...");
float temperature = 0;
float humidity = 0;
int err = simpledhterrsuccess;
if ((err = dht22.read2(pindht22, &temperature, &humidity, null)) != simpledhterrsuccess) {
serial.print("read dht22 failed, err="); serial.println(err);delay(2000);
return;
}
serial.print("status: ok");
serial.print((float)temperature); serial.print(" *c, ");
serial.print((float)humidity); serial.println(" rh%");
delay(1000);
if ((float)humidity > 75){
digitalwrite(fanrelay, high);
} else{
digitalwrite(fanrelay, low);
}
}
my code
when humidity > 90 why relay not working???
sorry language english not primary language
#include <simpledht.h>
int pindht22 = 22;
simpledht22 dht22;
int fanrelay = 13;
void setup() {
serial.begin(9600);
}
void loop() {
// start working...
serial.println("=================================");
serial.println("sample dht22...");
float temperature = 0;
float humidity = 0;
int err = simpledhterrsuccess;
if ((err = dht22.read2(pindht22, &temperature, &humidity, null)) != simpledhterrsuccess) {
serial.print("read dht22 failed, err="); serial.println(err);delay(2000);
return;
}
serial.print("status: ok");
serial.print((float)temperature); serial.print(" *c, ");
serial.print((float)humidity); serial.println(" rh%");
delay(1000);
if ((float)humidity > 75){
digitalwrite(fanrelay, high);
} else{
digitalwrite(fanrelay, low);
}
}
you didn't use code tags when posted. didn't call pinmode() on fanrelay.
Arduino Forum > Using Arduino > Programming Questions > DHT22 Sensor With Relay is not working
arduino
Comments
Post a Comment