#include "Arduino.h"
#include <Wire.h> // library to handle I2C
#include <Arduino_PMIC.h>. // library to handle BQ24195
#define PMIC_ADDRESS 0x6B // indirizzo I2C del caricabatterie
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Initialise serial port
Serial.begin(9600);
// while (!Serial);
// Initialise battery charger
InizializzaPMIC();
}
void loop()
{
int i;
for(i=0; i<3; i++)
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
delay(1000);
}
void InizializzaPMIC(){
if (!PMIC.begin()) {
Serial.println("Failed to initialize PMIC!");
while (1);
}
// Set the input current limit to 2 A and the overload input voltage to 3.88 V
if (!PMIC.setInputCurrentLimit(2.0)) {
Serial.println("Error in set input current limit");
}
float tensione = 3.88;
if (!PMIC.setInputVoltageLimit(3.88)) {
Serial.println("Error in set input voltage limit");
}
// set the minimum voltage used to feeding the module embed on Board
if (!PMIC.setMinimumSystemVoltage(3.5)) {
Serial.println("Error in set minimum system volage");
}
// Set the desired charge voltage to 4.2 V
if (!PMIC.setChargeVoltage(4.2)) {
Serial.println("Error in set charge volage");
}
// Set the charge current to 1250 mA
// the charge current should be defined as maximum at (C for hour)/2h
// to avoid battery explosion (for example for a 750 mAh battery set to 0.375 A)
// In my case, 2500mAh -> 1250mA
if (!PMIC.setChargeCurrent(1.250)) {
Serial.println("Error in set charge current");
}
Serial.println("Initialization done!");
// Enable the Charger
if (!PMIC.enableCharge()) {
Serial.println("Error enabling Charge mode");
}
}
Battery Management MKR 1010
Hi all, I have a behaviour of MKR 1010 with a connected rechargeable battery that I cannot understand.
1/ I start by plugging the MKR 1010 in the USB port, and attach the battery. The software initialise the batter charger BQ24195 to charge the battery, the "charge" LED happily blinks; the "power" LED happily stays solid green; the software makes the other LED blinking;
2/ I disconnect the MKR 1010 from the USB port. The software continues running (the other LED still blinks), the "charge" LED stays off, the "power" LED happily remains solid green. So far, so good;
3/ I reconnect the MKR 1010 into the USB port. I would expect the "charging" LED to restart blinking. No way.
It seems that once the power management switches from USB to battery, I could not find a way to make the other transition. From battery to USB. Any idea of where the problem is?
Here it is the sketch I use: