Skip to main content

Class Max1704x

Base class for MAX1704x fuel gauge family, which monitors battery state of charge for lithium-ion batteries

Assembly: Max17043.dll​
View Source​
Declaration
public abstract class Max1704x : II2cPeripheral, IVoltageSensor, ISensor<Voltage>, IStateOfChargeSensor, ISensor<double>, ISensor

Derived:
Meadow.Foundation.Sensors.Battery.Max17043, Meadow.Foundation.Sensors.Battery.Max17044

Implements:
Meadow.Hardware.II2cPeripheral, Meadow.Peripherals.Sensors.IVoltageSensor, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>, Meadow.Peripherals.Sensors.IStateOfChargeSensor, Meadow.Peripherals.Sensors.ISensor<System.Double>, Meadow.Peripherals.Sensors.ISensor

Properties​

DefaultI2cAddress​

The default I2C address for the peripheral

View Source​
Declaration
public byte DefaultI2cAddress { get; }

Version​

Gets the version of the MAX1704x chip

View Source​
Declaration
public byte Version { get; }

Voltage​

Last value read from the Voltage sensor.

View Source​
Declaration
public Voltage? Voltage { get; }

Methods​

ReadVoltage()​

Reads the current battery voltage

View Source​
Declaration
public ValueTask<Voltage> ReadVoltage()
Returns​

System.Threading.Tasks.ValueTask<Meadow.Units.Voltage>: The battery voltage in volts

ReadStateOfCharge()​

Reads the current state of charge (battery percentage)

View Source​
Declaration
public ValueTask<double> ReadStateOfCharge()
Returns​

System.Threading.Tasks.ValueTask<System.Double>: Battery percentage from 0.0 to 100.0

SetAlertThreshold(int)​

Sets the alert threshold for low battery

View Source​
Declaration
public void SetAlertThreshold(int percent)
Parameters​
TypeNameDescription
System.Int32percentAlert threshold percentage (1-32)
Exceptions​

System.ArgumentOutOfRangeException
Thrown when percent is outside the valid range of 1-32

IsAlertSet()​

Checks if the alert flag is currently set

View Source​
Declaration
public bool IsAlertSet()
Returns​

System.Boolean: True if the alert flag is set, otherwise false

ClearAlert()​

Clears the alert flag

View Source​
Declaration
public void ClearAlert()

SetSleepMode(bool)​

Sets or clears the sleep mode of the fuel gauge

View Source​
Declaration
public void SetSleepMode(bool sleep)
Parameters​
TypeNameDescription
System.BooleansleepTrue to enter sleep mode, false to exit sleep mode

Events​

LowChargeAlert​

Event that fires when battery charge falls below alert threshold

View Source​
Declaration
public event EventHandler<double>? LowChargeAlert
Event Type​

System.EventHandler<System.Double>

Implements​

  • Meadow.Hardware.II2cPeripheral
  • Meadow.Peripherals.Sensors.IVoltageSensor
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>
  • Meadow.Peripherals.Sensors.IStateOfChargeSensor
  • Meadow.Peripherals.Sensors.ISensor<System.Double>
  • Meadow.Peripherals.Sensors.ISensor