Arduino MKR WAN 1310 PMIC

Hi everyone,

I was hoping to use the Arduino PMIC library (GitHub - arduino-libraries/Arduino_BQ24195: [Beta] Arduino library to control TI BQ24195 PMIC on compatible MKR boards) in order to check whether the MKRWAN 1310 was connected to a power supply. The function (USBmode()) seemed promising but is only returning 0 independent on whether a USB power supply or a power supply on the 5V input was used.
This does not seem correct to me. Any idea how to fix the issue (please see my code here below)?

#include <Arduino_PMIC.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial);

  if (!PMIC.begin()) {
    Serial.println("Failed to initialize PMIC!");
    while (1);
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  PMIC.enableDPDM();
  int chargeCheck = PMIC.chargeStatus();
  int chargeGood = PMIC.canRunOnBattery();
  int powerCheck = PMIC.USBmode();

  if (!PMIC.enableCharge()) {
    Serial.println("Error enabling Charge mode");
  }

  Serial.print("Power: ");
  Serial.print(powerCheck,HEX);
  Serial.print(" Battery charge status: ");
  Serial.print(chargeCheck,HEX);
  Serial.print(" Can run on battery: ");
  Serial.println(chargeGood,HEX);

  delay(1000);
}

Thanks a lot in advance,

@jscheller, your topic was moved to amore suitable location on the forum.

1 Like