mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-15 06:17:47 +00:00
* Add variant_shutdown() as a week function in main-nrf52.cpp * Add Status LED module * Add Thinknode M3 support * Catch case of BLE disabled * Update src/modules/StatusLEDModule.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/StatusLEDModule.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update variants/nrf52840/ELECROW-ThinkNode-M3/rfswitch.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unused pin * M3 pairing LED only active for 30 seconds after state change * Thinknode M3 shutdown work --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/*
|
|
* Worth noting that both the AHT10 and AHT20 are supported without alteration.
|
|
*/
|
|
|
|
#include "configuration.h"
|
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<Adafruit_AHTX0.h>)
|
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
|
#include "AHT10.h"
|
|
#include "TelemetrySensor.h"
|
|
|
|
#include <Adafruit_AHTX0.h>
|
|
#include <typeinfo>
|
|
|
|
AHT10Sensor::AHT10Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_AHT10, "AHT10") {}
|
|
|
|
bool AHT10Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
|
{
|
|
LOG_INFO("Init sensor: %s", sensorName);
|
|
aht10 = Adafruit_AHTX0();
|
|
status = aht10.begin(bus, 0, dev->address.address);
|
|
|
|
initI2CSensor();
|
|
return status;
|
|
}
|
|
|
|
bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
|
{
|
|
LOG_DEBUG("AHT10 getMetrics");
|
|
|
|
sensors_event_t humidity, temp;
|
|
aht10.getEvent(&humidity, &temp);
|
|
|
|
// prefer other sensors like bmp280, bmp3xx
|
|
if (!measurement->variant.environment_metrics.has_temperature) {
|
|
measurement->variant.environment_metrics.has_temperature = true;
|
|
measurement->variant.environment_metrics.temperature = temp.temperature + AHT10_TEMP_OFFSET;
|
|
}
|
|
|
|
if (!measurement->variant.environment_metrics.has_relative_humidity) {
|
|
measurement->variant.environment_metrics.has_relative_humidity = true;
|
|
measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endif
|