PMIC get/setInputCurrentLimit not setting correctly?

I noticed some weird behavior when trying to use PMIC functions get/setInputCurrentLimit. Whenever I tried to set anything over 900, it actually reported a lower value. I am using this code to test:

#include "Particle.h"

PMIC pmic;

int currentValues[] = { 100, 150, 500, 900, 1200, 1500, 2000, 3000 };

void setup() {


  Serial.print("Starting value of inputCurrentLimit: ");

  for (int i = 0; i < sizeof(currentValues) / sizeof(int); i++) {
    Serial.print("Calling setInputCurrentLimit with value: ");

    Serial.print("Calling getInputCurrentLimit.... Result: ");



void loop() { }

The results on the default 0.8.0-rc.25 and 0.9.0 are the same:

Serial monitor opened successfully:
Starting value of inputCurrentLimit: 500

Calling setInputCurrentLimit with value: 100
Calling getInputCurrentLimit.... Result: 100

Calling setInputCurrentLimit with value: 150
Calling getInputCurrentLimit.... Result: 150

Calling setInputCurrentLimit with value: 500
Calling getInputCurrentLimit.... Result: 500

Calling setInputCurrentLimit with value: 900
Calling getInputCurrentLimit.... Result: 900

Calling setInputCurrentLimit with value: 1200
Calling getInputCurrentLimit.... Result: 100

Calling setInputCurrentLimit with value: 1500
Calling getInputCurrentLimit.... Result: 150

Calling setInputCurrentLimit with value: 2000
Calling getInputCurrentLimit.... Result: 500

Calling setInputCurrentLimit with value: 3000
Calling getInputCurrentLimit.... Result: 900


I’m not sure if this is a bug in the getter or the setter… Or if we are just not “allowed” to set anything over 900 on that device and this is expected behavior? Doesn’t BQ24195 allow up to 2.5A or 3A input current? Any response would be appreciated.

1 Like

I have noticed the charge current not going much over .9 - 1 Amp of charging current even when charging from a bench power supply that can supply up to 5 amps of power.

I’m sure this has to do with battery voltage drop in the battery JST Connector, thin wires, and feeding the battery through the the battery protection circuit, which all causes the PMIC charging circuit to see the battery voltage higher than it actually is which causes the charging current to drop lower as it should and does typically as the battery voltage rises as it reaches a full charge.

I reported this and experienced this same issue with the original Electron devices years back.

Really you don’t want to charge the stock 2 AH lipo at more than 1 Amp anyways but I can see why you would want to with a bigger sized battery connected.

Wiggling the JST connector during charging to get a better connection should allow you to see more or less charging current as the resistance in the circuit changes due to pressure you apply to then JST connector contacts.

Yeah, I’m currently testing with a 4000mAH battery as a trial… and yes, having difficulties getting it charged at times. I have a separate board for a different project (using raspi) that has a custom LiPo charging circuit that can charge these quickly with no problem. And we aren’t using anything as nice as the BQ24195.

As I understand it from the datasheet, (maybe I mis-read) but you should be able to set the input charge current limit higher, and if the BQ24195 will enable dynamic power management (DPM) and reduce that if needed:

When input source is over-loaded, either the current exceeds the input current limit (REG00[2:0]) or the voltage
falls below the input voltage limit (REG00[6:3]). The device then reduces the charge current until the input current
falls below the input current limit and the input voltage rises above the input voltage limit.

So I feel like I should be able to set this to at least 1500 or something and the PMIC will drop the charge current down if needed due to problems with input voltage, etc.

I’m currently trying to charge with a 6v/6w voltaic solar panel at the moment so 900mA should be “OK” I suppose (have tested with a 5V/2.5A power supply which seems to charge it ok)… but it has trouble getting above around 3.95-4V. I’ve read through that LTE solar trials thread many times (on which your responses were really helpful as well), and have tried changing the input voltage as well. Always seems stuck at 3.95-4V max. So I wasn’t sure if bumping this up a bit would help, but seems to not be able to go over 900mA.

@RWB, it’s setInputCurrentLimit, I believe you are thinking about setChargeCurrent :wink:

The set-points that @abatardi is using come straight from spark_wiring_power.cpp
It looks like a bug.

1 Like

Thanks @Rftop – yes I am referring to setInputCurrentLimit, but I have also tested increasing the setChargeCurrent value to some high option like 4096mA in conjunction with this test just to see if that mattered at all (in case the two were related), but it doesn’t seem to change anything.

Setting anything higher than 900mA seems like it actually results in a lower value being set by the PMIC.

You’re right :blush:

I got it wrong.

It does sound like a bug then.

@abatardi I also am using a similar BQ24250 charging chip for both LiPo + LiFePO4 Battery types and it works just fine and can charge at 2.2 Amps with zero problems.

The PMIC will over-ride the setInputCurrentLimit if the input voltage drops out.
That’s likely what’s happening to you. Might not be a bug after all.

Digressing from the Thread Title a bit:
Are you having issues with Solar Recharging when Sleeping?

In my Boron Solar Trial w/ EN Pin, I had to run the following during every Startup. If not, when the Solar Panel Dropped out, it wouldn’t re-start the charging:

// Li-Po Power Management:
  pmic.setInputVoltageLimit(5080);  //  for 6V Solar Panels   
  pmic.setChargeVoltage(4208);      //  Set Li-Po charge termination voltage to 4.21V,
  pmic.enableBuck();                //  enableBuck required when using EN Pin Shutdown ??.

Once pmic.enableBuck(); was added, the daily Battery Profile became pretty boring, with no major unexpected results. The 0.5-watt Solar Panel can easily recharge the Li-Po when running a 5 minute Wake/Publish schedule. The Boron doesn’t terminate the Li-Po charge at 4.2V (SoC 100%) anymore, as with my previous tests using pmic.setChargeVoltage(4208). This isn’t necessarily a negative result, and I’m sure there is a explanation.

As you know, your panel wont produce it’s max rated 930mA @ the highest InputVoltageLimit we have access to (5.080V).
So using pmic.setChargeCurrent(0,0,1,0,0,0);// 1024mA (512 + 512 offset) should do the trick.

From the serial output it looks like he is just setting new current input limits and then reading back the setting. In that case the setting should stick but it’s not doing that so it does look like a bug to me.

The above tests were done just plugged into USB on a computer with a full battery connected (not charging), so I don’t think it’s because it’s getting overridden by the PMIC, and it’s consistently reporting back invalid values immediately after calling the set function (well, 500ms delay in this example). If it were being overridden, I’d think the values it dropped to would be consistently “near” the set max, like dropping from 1200 -> 900, not from 1200->100, and 1500->150 (every single time).

I’m not putting the boron to sleep at all during these tests, just letting it sit idle between cellular publishes. I can try to 1024mA setting, and increasing again to the 5080 max input voltage… So you suggest using enableBuck as well? I will give all those a shot now. I have it in full sun at the moment so it’s a good time to test.

Since your battery was full, I agree… smells like a bug.

You need to put the PMIC setting in the Startup() code so they are applied on every startup because the settings do not stick.

1 Like

The pmic.setInputVoltageLimit(5080) is the Minimum Voltage the PMIC will allow the source to drop to and will adjust the battery charging current so that the source Voltage does not drop below 5.080V. This is similar to a watered down MPPT. You definitely want to use this with a 6V panel.

Note: When bench testing with USB connected, this could cause you problems if your USB port can't maintain 5.x Volts. It wont be an issue when operating normally on battery + solar.

I never did fully understand enableBuck, that was old-fashioned "try-it-all" that worked for that project.

As @RWB said, If you do intend on Sleeping, you'll need to perform the PMIC adjustments every cycle.
When not sleeping, you can set this group to be performed on a schedule (say 5 minutes) if you are still having problems with Solar Re-Charging after a cloud passes over.

1 Like

@Rftop - yeah sorry I meant min input voltage.

I’ve done some more testing. I have an INA226 voltage/current monitor measuring the input voltage/amperage on this. I wanted to stay consistent so I’m powering it with a 5V/2.5A power supply. My power supply doesn’t have quite enough voltage to hit the 5080 limit after a schottky diode drop, so I have to test this with 4840 setting only…

I’ve tested a bunch of input current settings, charge rate settings, enablebuck, enabledpdm, etc… bottom line is I can’t get the current input rate above right around 245mA no matter what I do. I verified this with a meter and am getting very close to what the INA226 is reading.

4840 input voltage, no other settings = 244mA
set charge rate explicitly to 2A (just to test default), = 245mA
bump charge rate to 4A = 246mA (no change)
back to 2A charge rate, current limit increased to 900mA = 246mA
enable buck = 244mA
enable DPDM = 245mA (I noticed with this on, it sometimes changes the max input current back to 500)
disable DPDM & buck, set current limit to 100mA = 94mA
set current limit to 150mA = 139mA

So when dropping the input current max to 100 or 150, I do see the input current drop to below those levels. But curiously when set to 500 or 900, I still can’t get higher than 250mA. So I’m at a bit of a loss. Unless the INA226 is somehow restricting to 250mA, or there is something else wrong that is causing this… I can’t seem to break through that ceiling…

Not sure if anyone has tested, but I’d be curious to see if anyone else has been able to get a higher input current than this on a boron…

Now that you mention it, I looked back at some previous notes/results during Solar Testing :
310 mA was the highest I recorded, and that was using a lower InputVoltageLimit

Using pmic.setInputVoltageLimit(4840)
Actual Charging started at 5.05V, Li-Po resting at 3.83V, Current Measured w/ a µCurrent GOLD
23mA @ 5.10V
42mA @ 5.15V
80mA @ 5.20V
105mA @ 5.25V
150mA @ 5.30V
200mA @ 5.40V
310mA @ 5.50V

I’ll repeat w/ pmic.setInputVoltageLimit(5080)
"Charging" LED lights at 4.25V, 2.6mA,
22mA @ 5.30V
50mA @ 5.40V
170mA @ 5.50V
240mA @ 5.60V 

I was testing much smaller panels than your 6 watt at the time, so I was concentrating on the Termination Voltage of the Li-Po, not the charging current.

Maybe I should repeat a similar voltage swing for charging current with all the settings:

  pmic.setInputVoltageLimit(5080);    //  Highest available right now, Use for 6V Solar Panels  
  pmic.setInputCurrentLimit(900) ;    // 900 mA 
  pmic.setChargeVoltage(4208);        //  Set Li-Po charge termination voltage to 4.21V, CAUTION! not for everyone
  pmic.setChargeCurrent(0,0,1,0,0,0); // 1024mA (512 + 512 offset)

Do you see anything that you’d want me to change ?

Interesting. I’m back to a solar panel now with 5.08v input voltage and it’s gone down to around 200mA, but I’m also not getting great sun right now.

The only thing is maybe not enableDPDM, as in my testing that seemed to make changes to the max input current when enabled, and sometimes drops it back to 500.

And thank you, I appreciate you looking into this also… I’m at the point where I’m starting to feel crazy, it’s either something dead simple that I’m missing, or possibly the bq24195 current registers really aren’t getting set properly by the firmware.

The input source register seems to be getting set correctly, so maybe this is just an error in the getter. When I call pmic.readInputSourceRegister, it seems to correlate to the expected values (last 3 bits):

// setting 900ma max (expect 011)

// 1200ma (expect 100)

// 3000ma (expect 111)

All these are with 5080 input voltage which is the first part (0bx1111xxx)…

Reading through the BQ24195 datasheet, it shows the pre-charge/term-charge current is 256mA. So I have a suspicion I am getting dropped into one of these somehow, and not getting into ‘fast charge’ mode, but the “setPreChargeCurrent” method is currently not implemented so I have no way to test this. :-/

So keep in mind, I’m supplying a Constant Voltage (5.45 V) to the USB connector with this test. The power supply has the capability to meet any current demands of the Boron LTE.
A solar panel works the opposite. It produces current.

The Boron LTE was in Manual Mode on 0.9.0. The Cell Modem was Off. The Boron was using 7 mA prior to connecting a 10,000 mAh Li-Po @ a resting voltage of 3.83V for each test.
All tests used the following:

  pmic.setInputCurrentLimit(900) ;    // 900 mA 
  pmic.setChargeVoltage(4208);        //  Set Li-Po charge termination voltage to 4.21V, CAUTION! not for everyone
  pmic.setChargeCurrent(0,0,1,0,0,0); // 1024mA (512 + 512 offset)

I only changed the pmic.setInputVoltageLimit(x);

#1 pmic.setInputVoltageLimit(5080);    //  = 500 mA
#2 pmic.setInputVoltageLimit(4840);    //  = 460 mA
#3 pmic.setInputVoltageLimit(4200);    //  = 810 mA

On the last test, I checked the Voltage at the Vusb Pin, just to make sure my wiring wasn’t the limiting factor.
The Supply voltage is dropping from 5.45V at the PSU to 4.58V at Vusb during the 810 mA Charging.
I’m going to rebuild my test rig with larger & shorter wiring to eliminate that being a possibility. I’ll look for the best USB that I can find in my office.

@Rftop, Inspired by your last post, I decreased the setInputVoltageLimit to 4520, and all of a sudden I am now seeing a full amp of charging from my 5v/2.5a adapter. Switch back to 4840, it drops back down to about 250mA again. 4680 gives me around 645mA. So do you think this points to some physical problem? At 4680 voltage limit, my INA226 is reporting 4.73V, and I’m measuring 4.65V @ VUSB pin with my meter.

The PMIC is pretty sophisticated. I'm guessing it's performing exactly how it's supposed to.