diff --git a/include/mgos_prometheus_sensors.h b/include/mgos_prometheus_sensors.h index 18596f4..03f4445 100644 --- a/include/mgos_prometheus_sensors.h +++ b/include/mgos_prometheus_sensors.h @@ -4,4 +4,7 @@ #include "mgos.h" #include "mgos_gpio.h" +float mgos_prometheus_sensors_dht_get_temp(uint8_t idx); +float mgos_prometheus_sensors_dht_get_humidity(uint8_t idx); + #endif // __MGOS_PROMETHEUS_SENSORS_H diff --git a/src/dht.c b/src/dht.c index 5cd5913..14ad437 100644 --- a/src/dht.c +++ b/src/dht.c @@ -91,6 +91,22 @@ static bool dht_sensor_create(int pin, enum dht_type type) { return true; } +float mgos_prometheus_sensors_dht_get_temp(uint8_t idx) { + if (idx>=s_num_dht) + return NAN; + if (!s_dht_sensor[idx]) + return NAN; + return s_dht_sensor[idx]->temp; +} + +float mgos_prometheus_sensors_dht_get_humidity(uint8_t idx) { + if (idx>=s_num_dht) + return NAN; + if (!s_dht_sensor[idx]) + return NAN; + return s_dht_sensor[idx]->humidity; +} + void dht_init() { char *tok;