nanoFramework.Iot.Device.Ip5306
1.2.696
Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Ip5306 --version 1.2.696
NuGet\Install-Package nanoFramework.Iot.Device.Ip5306 -Version 1.2.696
<PackageReference Include="nanoFramework.Iot.Device.Ip5306" Version="1.2.696" />
paket add nanoFramework.Iot.Device.Ip5306 --version 1.2.696
#r "nuget: nanoFramework.Iot.Device.Ip5306, 1.2.696"
// Install nanoFramework.Iot.Device.Ip5306 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Ip5306&version=1.2.696 // Install nanoFramework.Iot.Device.Ip5306 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Ip5306&version=1.2.696
IP5306 - Power management
This chip is used mainly in power bank and embedded devices as a power management device. It is connected using I2C and allows to adjust the charging current,voltage, cutoff voltage. It has the capacity to light up 4 leds displaying the charge of the battery. This device is used in the M5Stack.
Documentation
The datasheet in Chinese can be found here.
Usage
As always when using I2C, you need to make sure you're using the right pins. En ESP32, you need the register the pins if not using the default one.
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
I2cDevice i2c = new(new I2cConnectionSettings(1, Ip5306.SecondaryI2cAddress));
Ip5306 power = new(i2c);
Note the default address of the IP5306 is 0xEA, the address used in M5Stack is 0x75 (here setup as SecondaryI2cAddress
).
Getting access to the properties
All properties can be adjusted and changed. He is an example how to display all of them:
Debug.WriteLine($" AutoPowerOnEnabled: {power.AutoPowerOnEnabled}");
Debug.WriteLine($" BoostOutputEnabled: {power.BoostOutputEnabled}");
Debug.WriteLine($" BoostWhenVinUnpluggedEnabled: {power.BoostWhenVinUnpluggedEnabled}");
Debug.WriteLine($" BostEnabled: {power.BoostEnabled}");
Debug.WriteLine($" ButtonOffEnabled: {power.ButtonOffEnabled}");
Debug.WriteLine($" ChargerEnabled: {power.ChargerEnabled}");
Debug.WriteLine($" ChargingBatteryVoltage: {power.ChargingBatteryVoltage}");
Debug.WriteLine($" ChargingCurrent: {power.ChargingCurrent}");
Debug.WriteLine($" ChargingCutOffCurrent: {power.ChargingCutOffCurrent}");
Debug.WriteLine($" ChargingCuttOffVoltage{power.ChargingCuttOffVoltage}");
Debug.WriteLine($" ChargingLoopSelection: {power.ChargingLoopSelection}");
Debug.WriteLine($" ChargingUnderVoltage: {power.ChargingUnderVoltage}");
Debug.WriteLine($" ConstantChargingVoltage: {power.ConstantChargingVoltage}");
Debug.WriteLine($" FlashLightBehavior {power.FlashLightBehavior}");
Debug.WriteLine($" IsBatteryFull: {power.IsBatteryFull}");
Debug.WriteLine($" IsCharging: {power.IsCharging}");
Debug.WriteLine($" IsOutputLoadHigh: {power.IsOutputLoadHigh}");
Debug.WriteLine($" LightDutyShutdownTime: {power.LightDutyShutdownTime}");
Debug.WriteLine($" LowPowerOffEnabled: {power.LowPowerOffEnabled}");
Debug.WriteLine($" ShortPressToSwitchBosst: {power.ShortPressToSwitchBosst}");
Debug.WriteLine($" SwitchOffBoostBehavior: {power.SwitchOffBoostBehavior}");
Debug.WriteLine($" GetButtonStatus: {power.GetButtonStatus()}");
Button status
You can get the button status:
var button = power.GetButtonStatus();
switch (button)
{
case ButtonPressed.DoubleClicked:
Debug.WriteLine("double clicked");
break;
case ButtonPressed.LongPressed:
Debug.WriteLine("Long pressed");
break;
case ButtonPressed.ShortPressed:
Debug.WriteLine("Short pressed");
break;
case ButtonPressed.NotPressed:
default:
break;
}
Important: depending on the behavior you setup for the button, the device may switch off what's connected to it. So be careful on what you setup. Once the I2C connection is broken, you can't adjust the behavior bck.
configuration for M5Stack
The configuration for M5Stack is the following:
// Configuration for M5Stack
power.ButtonOffEnabled = true;
power.BoostOutputEnabled = false;
power.AutoPowerOnEnabled = true;
power.ChargerEnabled = true;
power.BoostEnabled = true;
power.LowPowerOffEnabled = true;
power.FlashLightBehavior = ButtonPress.Doubleclick;
power.SwitchOffBoostBehavior = ButtonPress.LongPress;
power.BoostWhenVinUnpluggedEnabled = true;
power.ChargingUnderVoltage = ChargingUnderVoltage.V4_55;
power.ChargingLoopSelection = ChargingLoopSelection.Vin;
power.ChargingCurrent = ElectricCurrent.FromMilliamperes(2250);
power.ConstantChargingVoltage = ConstantChargingVoltage.Vm28;
power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_17;
power.LightDutyShutdownTime = LightDutyShutdownTime.S32;
power.ChargingCutOffCurrent = ChargingCutOffCurrent.C500mA;
power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_2;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Device.I2c (>= 1.1.16)
- UnitsNet.nanoFramework.ElectricCurrent (>= 5.61.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on nanoFramework.Iot.Device.Ip5306:
Package | Downloads |
---|---|
nanoFramework.M5Core
This package includes the nanoFramework.M5Core assembly for .NET nanoFramework C# projects. |
|
nanoFramework.Fire
This package includes the nanoFramework.Fire assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5Stack
This package includes the nanoFramework.M5Stack assembly for .NET nanoFramework C# projects. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on nanoFramework.Iot.Device.Ip5306:
Repository | Stars |
---|---|
nanoframework/nanoFramework.M5Stack
:package: Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
Version | Downloads | Last updated |
---|---|---|
1.2.696 | 185 | 12/16/2024 |
1.2.673 | 351 | 10/23/2024 |
1.2.656 | 378 | 10/3/2024 |
1.2.639 | 323 | 9/6/2024 |
1.2.631 | 197 | 8/28/2024 |
1.2.613 | 301 | 8/9/2024 |
1.2.601 | 173 | 7/26/2024 |
1.2.590 | 259 | 7/17/2024 |
1.2.573 | 359 | 6/19/2024 |
1.2.570 | 110 | 6/14/2024 |
1.2.536 | 493 | 4/15/2024 |
1.2.514 | 388 | 3/22/2024 |
1.2.494 | 228 | 2/28/2024 |
1.2.474 | 358 | 1/24/2024 |
1.2.462 | 186 | 1/5/2024 |
1.2.458 | 155 | 12/20/2023 |
1.2.436 | 327 | 11/10/2023 |
1.2.403 | 418 | 10/6/2023 |
1.2.396 | 261 | 9/27/2023 |
1.2.384 | 244 | 9/6/2023 |
1.2.378 | 317 | 8/16/2023 |
1.2.369 | 286 | 8/2/2023 |
1.2.363 | 245 | 7/28/2023 |
1.2.357 | 276 | 7/19/2023 |
1.2.354 | 247 | 7/14/2023 |
1.2.345 | 262 | 6/21/2023 |
1.2.341 | 220 | 6/14/2023 |
1.2.337 | 268 | 6/7/2023 |
1.2.335 | 143 | 6/2/2023 |
1.2.329 | 246 | 5/26/2023 |
1.2.313 | 363 | 5/12/2023 |
1.2.302 | 318 | 5/10/2023 |
1.2.297 | 333 | 5/3/2023 |
1.2.273 | 1,068 | 3/17/2023 |
1.2.267 | 663 | 3/10/2023 |
1.2.263 | 515 | 3/8/2023 |
1.2.259 | 521 | 2/27/2023 |
1.2.256 | 535 | 2/24/2023 |
1.2.253 | 521 | 2/22/2023 |
1.2.222 | 1,142 | 1/9/2023 |
1.2.208 | 1,531 | 1/3/2023 |
1.2.203 | 660 | 12/28/2022 |
1.2.153 | 2,054 | 11/5/2022 |
1.2.141 | 2,218 | 10/25/2022 |
1.2.63 | 7,155 | 9/3/2022 |
1.2.47 | 1,061 | 8/15/2022 |
1.2.40 | 1,014 | 8/6/2022 |
1.2.38 | 972 | 8/5/2022 |
1.2.28 | 2,528 | 8/1/2022 |
1.2.13 | 2,013 | 7/24/2022 |
1.2.10 | 991 | 7/23/2022 |
1.1.142.3202 | 1,891 | 7/7/2022 |
1.1.133.52556 | 2,763 | 6/30/2022 |
1.1.121.35854 | 2,422 | 6/26/2022 |
1.1.102.51394 | 2,461 | 6/15/2022 |
1.1.99.36719 | 994 | 6/14/2022 |
1.1.72.29765 | 4,908 | 5/31/2022 |
1.1.64.21380 | 2,383 | 5/26/2022 |
1.1.54.28879 | 1,819 | 5/23/2022 |
1.1.40 | 2,624 | 5/5/2022 |
1.1.1 | 8,368 | 4/14/2022 |
1.0.302 | 3,569 | 3/31/2022 |
1.0.300 | 441 | 3/31/2022 |
1.0.288-preview.113 | 142 | 3/25/2022 |
1.0.288-preview.103 | 148 | 3/21/2022 |
1.0.288-preview.98 | 138 | 3/18/2022 |
1.0.288-preview.93 | 160 | 3/15/2022 |
1.0.288-preview.86 | 185 | 3/8/2022 |
1.0.288-preview.77 | 163 | 2/27/2022 |
1.0.288-preview.75 | 128 | 2/26/2022 |
1.0.288-preview.65 | 149 | 2/18/2022 |
1.0.288-preview.63 | 132 | 2/16/2022 |
1.0.288-preview.61 | 141 | 2/12/2022 |
1.0.288-preview.58 | 125 | 2/10/2022 |
1.0.288-preview.53 | 127 | 2/9/2022 |
1.0.288-preview.41 | 176 | 1/31/2022 |
1.0.288-preview.29 | 148 | 1/28/2022 |
1.0.288-preview.20 | 174 | 1/27/2022 |
1.0.288-preview.18 | 142 | 1/27/2022 |
1.0.288-preview.5 | 154 | 1/24/2022 |
1.0.288-preview.1 | 148 | 1/21/2022 |
1.0.267 | 356 | 1/4/2022 |
1.0.259 | 563 | 12/9/2021 |
1.0.258 | 288 | 12/7/2021 |
1.0.218 | 500 | 10/18/2021 |
1.0.203 | 344 | 10/11/2021 |
1.0.191 | 331 | 9/29/2021 |
1.0.177 | 346 | 9/22/2021 |