2024-04-29 22:10:49 +12:00
|
|
|
#include "configuration.h"
|
|
|
|
|
|
2024-04-27 18:05:39 +12:00
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
|
|
|
|
|
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
|
|
|
|
2023-01-18 14:51:48 -06:00
|
|
|
int32_t SHTC3Sensor::runOnce()
|
|
|
|
|
{
|
2022-12-30 10:27:07 -06:00
|
|
|
LOG_INFO("Init sensor: %s\n", sensorName);
|
2022-10-15 09:11:05 -05:00
|
|
|
if (!hasSensor()) {
|
|
|
|
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
|
|
|
|
}
|
2023-01-18 14:51:48 -06:00
|
|
|
status = shtc3.begin();
|
2022-10-15 09:11:05 -05:00
|
|
|
return initI2CSensor();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-18 14:51:48 -06:00
|
|
|
void SHTC3Sensor::setup()
|
2022-10-15 09:11:05 -05:00
|
|
|
{
|
|
|
|
|
// Set up oversampling and filter initialization
|
|
|
|
|
}
|
|
|
|
|
|
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
|