Domotique/WifiControlSensor/sensor_DHT.ino

30 lines
525 B
Arduino
Raw Normal View History

#ifdef CONFIG_ENABLE_DHT
#include "sensor_DHT.h"
int DHTSetup(int pin){
dht = new DHT(pin, DHTTYPE);
dht->begin();
return 0;
}
int DHTGetTempAndHumidity(float &t, float &h){
int ret = 0;
t = dht->readTemperature();
h = dht->readHumidity();
if(isnan(t)){
t = 0;
ret = -1;
}
if(isnan(h)){
h = 0;
ret = -1;
}
return ret;
}
bool DHTIsConnected(){
//No way to know if connected
//Check at least if initialized
return dht != NULL;
}
#endif