mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-10 13:13:27 +00:00

minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging
26 lines
612 B
C++
26 lines
612 B
C++
#include "configuration.h"
|
|
|
|
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
|
#include "TelemetrySensor.h"
|
|
#include "VoltageSensor.h"
|
|
#include <Adafruit_INA219.h>
|
|
|
|
class INA219Sensor : public TelemetrySensor, VoltageSensor
|
|
{
|
|
private:
|
|
Adafruit_INA219 ina219;
|
|
|
|
protected:
|
|
virtual void setup() override;
|
|
|
|
public:
|
|
INA219Sensor();
|
|
virtual int32_t runOnce() override;
|
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
|
virtual uint16_t getBusVoltageMv() override;
|
|
int16_t getCurrentMa();
|
|
};
|
|
|
|
#endif |