2024-04-29 22:10:49 +12:00
|
|
|
#include "configuration.h"
|
|
|
|
|
|
2025-04-28 18:35:13 -05:00
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<Adafruit_SHTC3.h>)
|
2024-04-27 18:05:39 +12:00
|
|
|
|
2023-01-18 08:56:47 -06:00
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
2024-05-03 14:26:57 +02:00
|
|
|
#include "SHTC3Sensor.h"
|
2022-10-15 09:11:05 -05:00
|
|
|
#include "TelemetrySensor.h"
|
|
|
|
|
#include <Adafruit_SHTC3.h>
|
|
|
|
|
|
2023-01-21 18:22:19 +01:00
|
|
|
SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC3, "SHTC3") {}
|
2022-10-15 09:11:05 -05:00
|
|
|
|
2025-10-13 18:09:33 +02:00
|
|
|
bool SHTC3Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
2023-01-18 14:51:48 -06:00
|
|
|
{
|
2024-10-14 06:11:43 +02:00
|
|
|
LOG_INFO("Init sensor: %s", sensorName);
|
2025-10-13 18:09:33 +02:00
|
|
|
status = shtc3.begin(bus);
|
2022-10-15 09:11:05 -05:00
|
|
|
|
2025-10-13 18:09:33 +02:00
|
|
|
initI2CSensor();
|
|
|
|
|
return status;
|
2022-10-15 09:11:05 -05:00
|
|
|
}
|
|
|
|
|
|
2023-01-21 18:22:19 +01:00
|
|
|
bool SHTC3Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
2023-01-18 14:51:48 -06:00
|
|
|
{
|
2024-08-16 17:15:51 -05:00
|
|
|
measurement->variant.environment_metrics.has_temperature = true;
|
|
|
|
|
measurement->variant.environment_metrics.has_relative_humidity = true;
|
|
|
|
|
|
2022-10-15 09:11:05 -05:00
|
|
|
sensors_event_t humidity, temp;
|
|
|
|
|
shtc3.getEvent(&humidity, &temp);
|
|
|
|
|
|
|
|
|
|
measurement->variant.environment_metrics.temperature = temp.temperature;
|
|
|
|
|
measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity;
|
|
|
|
|
|
|
|
|
|
return true;
|
2024-04-27 18:05:39 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|