nanoFramework.Iot.Device.Axp192
1.2.222
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Axp192 --version 1.2.222
NuGet\Install-Package nanoFramework.Iot.Device.Axp192 -Version 1.2.222
<PackageReference Include="nanoFramework.Iot.Device.Axp192" Version="1.2.222" />
paket add nanoFramework.Iot.Device.Axp192 --version 1.2.222
#r "nuget: nanoFramework.Iot.Device.Axp192, 1.2.222"
// Install nanoFramework.Iot.Device.Axp192 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Axp192&version=1.2.222 // Install nanoFramework.Iot.Device.Axp192 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Axp192&version=1.2.222
AXP192 - Enhanced single Cell Li-Battery and Power System Management IC
Documentation
-Product documentation can be found here. -Registers can be found here (Chineese only, note: bing translator make miracle).
Usage
// Make sure you configure properly the I2C pins, here example for ESP32
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
I2cDevice i2cAxp192 = new(new I2cConnectionSettings(1, Axp192.I2cDefaultAddress));
Axp192 power = new Axp192(i2cAxp192);
Important: make sure you read th documentation of your battery and setup the proper charging values, stop current. Overcharging your battery may damage it.
Using the button
One button is available and can be setup to track short and long press:
// This part of the code will handle the button behavior
power.EnableButtonPressed(ButtonPressed.LongPressed | ButtonPressed.ShortPressed);
power.SetButtonBehavior(LongPressTiming.S2, ShortPressTiming.Ms128, true, SignalDelayAfterPowerUp.Ms32, ShutdownTiming.S10);
The status is kept in the registers up to the next status read. You can then have both a short and a long press, you can get the status like this:
var status = power.GetButtonStatus();
if ((status & ButtonPressed.ShortPressed) == ButtonPressed.ShortPressed)
{
Debug.WriteLine("Short press");
}
else if ((status & ButtonPressed.LongPressed) == ButtonPressed.LongPressed)
{
Debug.WriteLine("Long press");
}
Battery status
You can get various elements regarding the battery status:
Debug.WriteLine($"Battery:");
Debug.WriteLine($" Charge curr : {power.GetBatteryChargeCurrent().Milliamperes} mA");
Debug.WriteLine($" Status : {power.GetBatteryChargingStatus()}");
Debug.WriteLine($" Dicharge curr: {power.GetBatteryDischargeCurrent().Milliamperes} mA");
Debug.WriteLine($" Inst Power : {power.GetBatteryInstantaneousPower().Milliwatts} mW");
Debug.WriteLine($" Voltage : {power.GetBatteryVoltage().Volts} V");
Debug.WriteLine($" Is battery : {power.IsBatteryConnected()} ");
Advanced features
The AXP192 can charge the battery, get and set charging current, cut off voltage, has protection for temperature. Most feature can be access or setup. You can check out the sample to get more details on how to set those advance features.
Note: this binding uses UnitsNet for the units like Voltage, Amperes.
Here is an example reading the current, voltage:
Debug.WriteLine($"Temperature : {power.GetInternalTemperature().DegreesCelsius} °C");
Debug.WriteLine($"Input:");
// Note: the current and voltage will show 0 when plugged into USB.
// To see something else than 0, you should output those data on a serial port for example
// Or display on the screen.
Debug.WriteLine($" Current : {power.GetInputCurrent().Milliamperes} mA");
Debug.WriteLine($" Voltage : {power.GetInputVoltage().Volts} V");
Debug.WriteLine($" Status : {power.GetInputPowerStatus()}");
Debug.WriteLine($" USB volt : {power.GetUsbVoltageInput().Volts} V");
Debug.WriteLine($" USB Curr : {power.GetUsbCurrentInput().Milliamperes} mA");
Coulomb counter
The AXP192 has a Coulomb counter where the value is in mili Amperes per hour (this one is not yet using UnitsNet). You first have to enable the Counter and then you can read the value. It is recommended to let some time between the moment you enable and read the data. Features to reset, stop the count are available as well
power.EnableCoulombCounter();
// Do something here
// You can then read periodically the Coulomb counter:
Debug.WriteLine($"Coulomb: {power.GetCoulomb()} mA/h");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.14.2)
- nanoFramework.Runtime.Events (>= 1.11.6)
- nanoFramework.System.Device.Gpio (>= 1.1.28)
- nanoFramework.System.Device.I2c (>= 1.1.9)
- UnitsNet.nanoFramework.ElectricCurrent (>= 4.150.0)
- UnitsNet.nanoFramework.ElectricPotential (>= 4.150.0)
- UnitsNet.nanoFramework.Power (>= 4.150.0)
- UnitsNet.nanoFramework.Temperature (>= 4.150.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on nanoFramework.Iot.Device.Axp192:
Package | Downloads |
---|---|
nanoFramework.M5Core2
This package includes the nanoFramework.M5Core2 assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickC
This package includes the nanoFramework.M5StickC assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickCPlus
This package includes the nanoFramework.M5StickCPlus assembly for .NET nanoFramework C# projects. |
|
nanoFramework.Tough
This package includes the nanoFramework.Tough assembly for .NET nanoFramework C# projects. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on nanoFramework.Iot.Device.Axp192:
Repository | Stars |
---|---|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
Version | Downloads | Last updated |
---|---|---|
1.2.673 | 168 | 10/23/2024 |
1.2.656 | 776 | 10/3/2024 |
1.2.639 | 645 | 9/6/2024 |
1.2.631 | 296 | 8/28/2024 |
1.2.613 | 515 | 8/9/2024 |
1.2.601 | 252 | 7/26/2024 |
1.2.590 | 390 | 7/17/2024 |
1.2.573 | 657 | 6/19/2024 |
1.2.570 | 112 | 6/14/2024 |
1.2.560 | 363 | 5/29/2024 |
1.2.548 | 374 | 5/15/2024 |
1.2.536 | 579 | 4/15/2024 |
1.2.514 | 690 | 3/22/2024 |
1.2.494 | 467 | 2/28/2024 |
1.2.474 | 696 | 1/24/2024 |
1.2.462 | 240 | 1/5/2024 |
1.2.458 | 235 | 12/20/2023 |
1.2.436 | 694 | 11/10/2023 |
1.2.403 | 918 | 10/6/2023 |
1.2.396 | 403 | 9/27/2023 |
1.2.384 | 457 | 9/6/2023 |
1.2.378 | 638 | 8/16/2023 |
1.2.369 | 644 | 8/2/2023 |
1.2.363 | 339 | 7/28/2023 |
1.2.357 | 417 | 7/19/2023 |
1.2.354 | 410 | 7/14/2023 |
1.2.345 | 702 | 6/21/2023 |
1.2.341 | 467 | 6/14/2023 |
1.2.337 | 431 | 6/7/2023 |
1.2.335 | 202 | 6/2/2023 |
1.2.329 | 647 | 5/26/2023 |
1.2.313 | 727 | 5/12/2023 |
1.2.302 | 512 | 5/10/2023 |
1.2.297 | 514 | 5/3/2023 |
1.2.273 | 2,080 | 3/17/2023 |
1.2.267 | 1,181 | 3/10/2023 |
1.2.263 | 980 | 3/8/2023 |
1.2.259 | 1,073 | 2/27/2023 |
1.2.256 | 845 | 2/24/2023 |
1.2.253 | 810 | 2/22/2023 |
1.2.222 | 2,123 | 1/9/2023 |
1.2.219 | 353 | 1/9/2023 |
1.2.208 | 2,804 | 1/3/2023 |
1.2.203 | 1,287 | 12/28/2022 |
1.2.153 | 4,031 | 11/5/2022 |
1.2.141 | 3,983 | 10/25/2022 |
1.2.122 | 1,621 | 10/12/2022 |
1.2.114 | 1,544 | 10/8/2022 |
1.2.95 | 5,078 | 9/22/2022 |
1.2.87 | 4,804 | 9/15/2022 |
1.2.73 | 1,599 | 9/8/2022 |
1.2.63 | 2,591 | 9/3/2022 |
1.2.47 | 1,697 | 8/15/2022 |
1.2.40 | 1,931 | 8/6/2022 |
1.2.38 | 1,606 | 8/5/2022 |
1.2.28 | 4,786 | 8/1/2022 |
1.2.13 | 3,874 | 7/24/2022 |
1.2.10 | 1,625 | 7/23/2022 |
1.1.145.58726 | 3,003 | 7/7/2022 |
1.1.133.52556 | 5,779 | 6/30/2022 |
1.1.127.28388 | 2,740 | 6/28/2022 |
1.1.121.35854 | 1,939 | 6/26/2022 |
1.1.113.2032 | 2,739 | 6/23/2022 |
1.1.102.51394 | 2,520 | 6/15/2022 |
1.1.99.36719 | 1,627 | 6/14/2022 |
1.1.74.7591 | 8,403 | 5/31/2022 |
1.1.72.29765 | 1,041 | 5/31/2022 |
1.1.67.25390 | 1,736 | 5/27/2022 |
1.1.66.33470 | 1,384 | 5/26/2022 |
1.1.64.21380 | 1,421 | 5/26/2022 |
1.1.54.28879 | 2,820 | 5/23/2022 |
1.1.40 | 4,117 | 5/5/2022 |
1.1.1 | 13,181 | 4/14/2022 |
1.0.308 | 1,452 | 4/12/2022 |
1.0.302 | 4,619 | 3/31/2022 |
1.0.300 | 502 | 3/31/2022 |
1.0.288-preview.113 | 152 | 3/25/2022 |
1.0.288-preview.103 | 161 | 3/21/2022 |
1.0.288-preview.99 | 158 | 3/18/2022 |
1.0.288-preview.98 | 134 | 3/18/2022 |
1.0.288-preview.93 | 168 | 3/15/2022 |
1.0.288-preview.86 | 184 | 3/8/2022 |
1.0.288-preview.77 | 161 | 2/27/2022 |
1.0.288-preview.75 | 136 | 2/26/2022 |
1.0.288-preview.65 | 156 | 2/18/2022 |
1.0.288-preview.63 | 148 | 2/16/2022 |
1.0.288-preview.61 | 147 | 2/12/2022 |
1.0.288-preview.58 | 138 | 2/10/2022 |
1.0.288-preview.53 | 135 | 2/9/2022 |
1.0.288-preview.41 | 184 | 1/31/2022 |
1.0.288-preview.29 | 212 | 1/28/2022 |
1.0.288-preview.20 | 213 | 1/27/2022 |
1.0.288-preview.19 | 146 | 1/27/2022 |
1.0.288-preview.18 | 168 | 1/27/2022 |
1.0.288-preview.5 | 179 | 1/24/2022 |
1.0.288-preview.1 | 173 | 1/21/2022 |
1.0.272 | 249 | 1/10/2022 |
1.0.259 | 1,040 | 12/9/2021 |
1.0.258 | 346 | 12/7/2021 |
1.0.235 | 275 | 11/1/2021 |
1.0.234 | 192 | 11/1/2021 |
1.0.218 | 632 | 10/18/2021 |
1.0.191 | 388 | 9/29/2021 |
1.0.167 | 384 | 9/15/2021 |