mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 18:22:32 +00:00
Use INA for device battery level (#2536)
* WIP * Continued wip * We got em * Voltage sensor base class * INA voltage * Log it * Stacie's mom has got it going on * Move declaration up * Last one * Sneaky little bugger * Macro guard to avoid calling methods
This commit is contained in:
@@ -12,8 +12,12 @@ int32_t INA219Sensor::runOnce()
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
ina219 = Adafruit_INA219(nodeTelemetrySensorsMap[sensorType]);
|
||||
status = ina219.begin();
|
||||
if (!ina219.success()) {
|
||||
ina219 = Adafruit_INA219(nodeTelemetrySensorsMap[sensorType]);
|
||||
status = ina219.begin();
|
||||
} else {
|
||||
status = ina219.success();
|
||||
}
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
@@ -24,4 +28,9 @@ bool INA219Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
measurement->variant.environment_metrics.voltage = ina219.getBusVoltage_V();
|
||||
measurement->variant.environment_metrics.current = ina219.getCurrent_mA();
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t INA219Sensor::getBusVoltageMv()
|
||||
{
|
||||
return lround(ina219.getBusVoltage_V() * 1000);
|
||||
}
|
||||
Reference in New Issue
Block a user