Electron : fast red blink when Vin connected without LIPo

This is the implementation of PMIC::begin()

/*******************************************************************************
 * Function Name  : begin
 * Description    : Initializes the I2C for the PMIC module
 * Input          : NONE
 * Return         : 0 Error, 1 Success
 *******************************************************************************/
bool PMIC::begin()
{
#if Wiring_Wire3
    Wire3.begin();
#endif
    return 1;
}

It would be good practice to call begin() prior first use (if sys hasn’t done this at that time already) just to make sure the required interface is definetly enabled.
This way you should be able to do your setup tasks in STARTUP().

1 Like

@RWB and @ScruffR thanks for your input last night. I spent most of today trying to get a workable solution.

When I added to setup():
_pmic.begin();
it made no difference the red LED would still blink after wake up from deep sleep.

I then added to setup() and loop() right at the beginning of each:

 _pmic.begin();
 _pmic.disableCharging(); 
 delay(10000); 

It was a little better but not reliable, the LED after the deep sleep started would just start blinking.

Next step was to reduce the deep sleep from one hour to three minutes and work my way back up to an hour testing the performance after three or four iteration of each time loop. I also further changed the code.

In Setup()

_pmic.begin();
_pmic.disableCharging(); 
delay(10000); 

At the start of the Loop()

_pmic.begin();
_pmic.disableCharging(); 
delay(10000); 

and right before the deep sleep another call to PMIC:

_pmic.begin();
_pmic.disableCharging(); 
delay(10000); 
System.sleep(SLEEP_MODE_DEEP,3600);

The above scenario has worked the best but not 100% reliable. I know I am a little heavy on _pmic.begin(); but I wanted to try anything to get it to work.

These are some of the anomalies I found;

  • after three 15 minute sessions that worked flawlessly on the fourth session at the 12 minute mark the red LED started to blink. Once the 15 minute sleep session was over (3 minutes later) the code executed and the red LED stopped blinking.

  • in one of the 30 minuted sessions out of the clear blue at the 24 minute mark the red LED started to blink and again stopped once the sleep session was over and the code executed.

  • in an hour session the same scenario took place as above at the 58 minuted mark the red LED started to blink.

  • in the sessions when the time loop ran with no blinking red LED it would start to blink once the connection was made to the cloud but stop right before the deep sleep mode.

Here is the bottom line the code is now doable but not perfect.
Why do you think during the sleep cycle the red LED will start to flash at no set time and for no reason?

Looks like you did a fair amount of testing. I wonder if 2 Electrons would provide the same behavior? How many Electrons do you have?

After all that if you don’t need the LED then I would just remove it and sleep well knowing that the pesky RED charging LED is for sure not wasting power. You can still read battery voltage and SOC later if you want to add the battery back at some point.

@RWB thanks for getting back. I just ordered two more Electrons tonight. I would hate to take out the LED on the fear of wrecking the device. There has got to be a software solution to this issue, could there possibly be a bug in the firmware? I will continue to keep testing. If you come up with any new ideas please let me know.

After some trial and error it’s maybe time to ask someone who knows best.

@BDub, is there a better way to deactivate the red charging LED on the Electron than “abusing” PMIC::disableCharging()?

2 Likes

Hi @BDub any idea when you can give your expert advice on how to solve this issue?
is there a better way to deactivate the red charging LED on the Electron than “abusing” PMIC::disableCharging()?

The rapid flashing behavior of the status LED is undocumented in the TI’s BQ24195 datasheet and is an unwanted side effect of an absent battery. The easiest way around is to disconnect the battery from the PMIC by turning off the internal FET by issuing a command power.disableBATFET(); followed by disabling the charging power.disableCharging();

Here is a sample code it was tested with:

PMIC power;

void setup() {
    power.disableBATFET();
    power.disableCharging(); // if you comment this out, the red LED will be steady ON
    delay(50);
    pinMode(D7,OUTPUT);
    digitalWrite(D7,HIGH);

}

void loop() {
    
    delay(2000);
    System.sleep(SLEEP_MODE_DEEP,20);
}

The other obvious solution in your use case is to remove the red LED altogether.

Hope this helps!

3 Likes

@mohit thanks for your help. It has been sleeping now for 50 minutes and the red LED just started flashing! Do you think I need to add power.disableWatchdog();? Even though it is in deep sleep something is monitoring the chip and reseting the power.disableCharging();

Thanks @mohit, I was there already in another thread with similar issue but got Brets response :confused:

So I unfortunately refrained from suggesting it here :weary:

Just to follow up… I didn’t want to suggest something that I have not personally tested or know has been tested to be working. It appears that @mohit 's suggested code is also not quite working for @autolib while the system is in deep sleep.

There is an interrupt service routine in main.cpp that will potentially re-enable the charging by setting the charging rate (while the system is awake). If you deep sleep, it will reset the system when you wake back up and battery charging stuff will re-initialize. Code in setup() should fix that. However while sleeping the PMIC still has power and can react to changes in VIN voltage levels. The fuel gauge can possibly be doing something here as well since it’s alarm output is tied to the same interrupt line as the PMIC. You should sleep the fuel gauge as well.

FuelGauge fuel;
fuel.sleep();

Again, this is something we need to spend more time testing and documenting. But feel free to experiment and tell us what works and what doesn’t :wink:

4 Likes

@BDub thank your for input. I did further testing this past weekend using the Sample code @mohit provided modified with your input and some ideas of my own.

PMIC power;
FuelGauge fuel;

void setup() {

 //Sets up the internal I2C to communicate with the PMIC
    power.begin();
    delay(1000);
    
    //Disables the PMIC's internal watchdog timer
    power.disableWatchdog();
    delay(1000);
    
    // Disable Power = this did not work - never would come back on, totally powered off
    //  power.disableBuck();
    //  delay(1000);
    
    // disconnects the battery
    power.disableBATFET();
    delay(1000);
    
    // Disables charging
    power.disableCharging(); // if you comment this out, the red LED will be steady ON
   delay(1000);
   
   fuel.sleep();
   delay(1000);
}

void loop() {
    // Do something
     digitalWrite(D7,HIGH);
    delay(2000);
    
    power.begin();
    delay(1000);
    
    //Disables the PMIC's internal watchdog timer
    power.disableWatchdog();
    delay(1000);
    
    // Disable Power = this did not work never would come back on
    //  power.disableBuck();
    //  delay(1000);
    
    // disconnects the battery
    power.disableBATFET();
     delay(1000);
   
    // Disables charging
    power.disableCharging(); // if you comment this out, the red LED will be steady ON
   delay(1000);
    
    fuel.sleep();
   delay(1000);
    
    
    //System.sleep(SLEEP_MODE_DEEP,20);
    System.sleep(SLEEP_MODE_DEEP,3600); // sleep for one hour
}

I know I am redundant with code in Setup() and Loop() but without the code in the Loop() area the blinking would stop for one sleep iteration only and never stop again. When the code is added to the Loop() the blinking does stop but the result is not consistent. Sometimes it makes it alway through the hour sleep cycle and other times the blinking starts after 20 minutes, other times after 40 minutes no rhyme or reason. Any sleep cycle longer than one hour the blinking starts up almost right away. Does it matter what order the PMIC or FuelGauge calls are made?

Open to more ideas to try.

Pull off the LED and forget about it :smile:

Hello @mohit,@BDub,@ScruffR,@RWB it has been 7 days now since my last findings and I never heard back from any of you except to

which I do not want to do. So I guess the short answer to my question of “Open to more ideas to try” is to wait for a possible firmware update.

While I have your attention I want to ask your collective thoughts on another possible solution. The whole premise of connecting to VIN and avoiding the LiPo battery is that the Electron will be located in a location where charging a LiPo battery is not an option and changing LiPo batteries is harder than replacing four AA batteries. The location is indoors so solar is not an option.

Would the following scenario work:
Keep the LiPo battery plugged in but also connect the four AA batteries to VIN. When the LiPo battery starts to draw down power would it take power from the AA batteries to charge up and then leave the AA batteries alone until the next LiPo draw down? The idea being the LED problem is solved, I leave the LiPo in place and only replace the AA batteries when needed which is the practicality that I need. Or does VIN act like batteries being plugged into the USB port and totally powering them down before drawing power from the LiPo battery, as mentioned in the Electron Power Management on Four AA Batteries post?

I would love to get a workable solution to this problem.

Thanks

I am sorry to see with the Firmware 0.5.0 ver update the "fast red blink when Vin connected without LiPo" was never addressed. The battery led will go off when put into sleep mode but comes back blinking after about an hour.
Does anyone know if this will ever be addressed?
How much power does the flashing battery indicator led consume in sleep mode?

I think your Electron may have a issue with it’s PMIC chip because my 2 Electrons never flash the RED charging LED when they are in sleep mode.

Thanks for responding @RWB. Remember I am running on four AA batteries connected to VIN and GND. LiPo and USB are not connected.

I still say just pull the Led off and problem is solved for this particular application.

Yes @RWB that probably is the real option! Do you have any idea how much power the led uses flashing?

I have no idea but probably very little and probably not enough to worry about but pulling it off will for sure drop it down to zero.

Thanks @RWB