axp2101¶
Circuitpython driver for AXP2101 power management IC
Author(s): Dario Cammi
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class axp2101.AXP2101(i2c: I2C, device_address: int = 0x34)¶
Circuitpython driver for AXP2101 power management IC
This driver class is designed not to be directly instanciated but to be extended. The subclass should not directly expose LDOs but specific properties and methos to interact with connected hardware. For example on M5Stack Core3 the DLDO1 is the output power the LCD backlight. The subclass instead of expose the DLDO1 voltage control should expose a property to control the DLDO1 brightness
- Parameters:
Quickstart: Importing and using the device
Here is an example of using the
AXP2101class. First you will need to import the libraries to use the sensorimport board from axp201 import AXP201
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA pmic = AXP2101(i2c)
Now you can get the AXP2101 battery status
is_battery_connected = pmic.is_battery_connected battery_voltage = pmic.battery_voltage
- property battery_level: int¶
Battery level in percentage (0% - 100%)
Returns 0 if no battery is connected to AXP2101
- property battery_status: BatteryStatus¶
Battery charging status
Returns if the battery is charging, discharging or in standby Returns
Noneif no battery is connectedStatuse
- class axp2101.BatteryStatus(value)¶
Enum-like class from AXP2101 battery charging status
- DISCHARGING: BatteryStatus¶
The battery is discharging, battery is powering the devices
- STANDBY: BatteryStatus¶
The battery is neither charging neither discharging
- CHARGING: BatteryStatus¶
The battery is charging