2023-01-18 08:56:47 -06:00
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
2022-10-15 09:11:05 -05:00
|
|
|
#include "configuration.h"
|
|
|
|
|
#include "TelemetrySensor.h"
|
|
|
|
|
#include "SHTC3Sensor.h"
|
|
|
|
|
#include <Adafruit_SHTC3.h>
|
|
|
|
|
|
|
|
|
|
SHTC3Sensor::SHTC3Sensor() :
|
|
|
|
|
TelemetrySensor(TelemetrySensorType_SHTC3, "SHTC3")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2022-11-13 14:56:52 +01:00
|
|
|
status = shtc3.begin();
|
2022-10-15 09:11:05 -05:00
|
|
|
return initI2CSensor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHTC3Sensor::setup()
|
|
|
|
|
{
|
|
|
|
|
// Set up oversampling and filter initialization
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SHTC3Sensor::getMetrics(Telemetry *measurement) {
|
|
|
|
|
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;
|
|
|
|
|
}
|