19 lines
589 B
C++
19 lines
589 B
C++
#include <endpoints/DHTEndpoint.h>
|
|
|
|
void DHTEndpoint::bind(String _name, SpejsNode* _parent) {
|
|
Endpoint::bind(_name, _parent);
|
|
|
|
sensor.setup(pin, sensor_type);
|
|
samplingTimer.initializeMs(samplingRate, TimerDelegate(&DHTEndpoint::sample, this)).start();
|
|
}
|
|
|
|
void DHTEndpoint::sample() {
|
|
TempAndHumidity th = sensor.getTempAndHumidity();
|
|
if(sensor.getStatus() == DHTesp::ERROR_NONE) {
|
|
notify("degree", String(th.temperature));
|
|
notify("humidity", String(th.humidity));
|
|
} else {
|
|
debugf("Failed to read from DHT: %d", sensor.getStatus());
|
|
}
|
|
}
|