Electron : fast red blink when Vin connected without LIPo

I like to run Electron on my car battery only.
When I connect car 12V to Vin without LiPo battery I get fast red blink which change to fixed red when LiPo
is connected. Same thing happens if Vin = 9V. Electron still works fine.
Is the fast red blink according spec? If so , I suggest you switch off red in this mode as it is quite difficult to differ
from red error codes.

This LED indicates charging and is connected with the power management IC only.

The device modes are shown on the RGB-LED between MODE and RESET button. Maybe there is a way to turn off the poer management IC LED using PMIC or FuelGauge functions,…

regards

1 Like

What filtering are you using between the 12V car supply and your device?
Car electronics has to deal with spikes and drops, you don’t want your device to get damaged by these.
Have a quick read here
Connect to your car with Carloop

Found the following functions below to handle the flashing battery led when the LiPo is not connected and you are using Vin for a power source. The Electron specs say “You can stop this behavior, Rapid blinking, by either plugging in the LiPo battery or by disabling the charging using the appropriate firmware command.” Question is how do you call the functions in your code?

/*******************************************************************************
 * Function Name  : enableCharging
 * Description    :
 * Input          :
 * Return         :
 *******************************************************************************/
bool PMIC::enableCharging() {

    byte DATA = readRegister(POWERON_CONFIG_REGISTER);
    DATA = DATA & 0b11001111;
    DATA = DATA | 0b00010000;
    writeRegister(POWERON_CONFIG_REGISTER, DATA);
    return 1;
}

/*******************************************************************************
 * Function Name  : disableCharging
 * Description    :
 * Input          :
 * Return         :
*******************************************************************************/
bool PMIC::disableCharging() {

    byte DATA = readRegister(POWERON_CONFIG_REGISTER);
    writeRegister(POWERON_CONFIG_REGISTER, (DATA & 0b11001111));
    return 1;
}

Try calling this function in the setup.

_pmic.disableCharging();

@RWB, I think this is not a really helpful suggestion, especially since you yourself had a similar problem to which I responded with this

So again

PMIC _pmic; // instantiate an object
...
void setup()
{
  _pmic.disableCharging();
  ...
}

Thanks for editing your post accordingly :+1:

3 Likes

Excellent this is what I needed :sunglasses:

Thanks.

Did it turn the red charging led off?

Sorry @RWB I will not be able to test it until tomorrow. I plan on connecting VIN to four AA batteries, as I have mentioned in another post. I should be well with the Electron VIN Specs: “VIN pin is 3.9VDC to 12VDC”

Thanks for the tip!
I already ordered the unit to test .
https://shop.trycelery.com/page/candlestick

1 Like

LED is now off, thanks a lot!

2 Likes

@ScruffR, @RWB
It worked for me too! But I guess I spoke to soon! After the following line of code executed:

System.sleep(SLEEP_MODE_DEEP,3600);

the Electron woke back up with a flashing Red LED again.
I have added the function pmic.disableCharging(); to the beginning of the Loop ( besides being in the Setup section too) but it makes no difference.

When the Electron wakes backup the Red LED starts flashing again and stays flashing even when it goes back to sleep again with the System.sleep(SLEEP_MODE_DEEP,3600); line.

Any ideas?

1 Like

It looks like on ever power up the PMIC goes back to its default programmed state which is to Charge the battery. See below:

I think when you wake up from deep sleep the micro processor is starting from scratch again so at first it’s loading the firmware where the default is to charge the battery.

I would think that calling disable charging in setup would stop the red light from flashing just as it did on the first power up. I’m not sure what is going on.

I think if you were able to change the default PMIC start settings to no charging then it would no longer be a issue but to do this you have to be building the firmware locally from how I understand it.

I would say the 2 option would be to remove the RED led or a resistor that is inline with it so it now longer lights up which will lower your standby power consumption.

Those are all the ideas have at the moment.

Thanks for the input @RWB. After four sleep cycles of turning on it now turned off when it went to sleep. In the other cycles when the Electron came online the led went off until sleep was called then it came on. Bottom line it is inconsistent behavior. Does bool begin(); have to be called? What does it do? Just grasping at straws!
https://docs.particle.io/reference/firmware/electron/#pmic-power-managment-ic-

Try adding a short delay after calling the PMIC.disablecharging and see if it acts any more consistently.

I have never tried the functions in the link you provided but I don’t think you need to call bool begin(); since the firmware is already handling that. I think these functions only return status info for the PMIC. To set data in the PMIC you have to call the PMIC. class first and then the function.

But I’m not expert so it probably would not hurt to ask @ScruffR for clarification.

Do let us know if anything changes.

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.