Boron - Wake up on VIN - BAT_INT pin?

Can I program an interrupt on a Boron to wake it up from a sleep mode when power is detected or is this only available in the Tracker? Many times a device is sleeping and then is plugged into power. Currently the device doesn't know it until it wakes up again (anywhere from 20 minutes to 2 hours). I'd prefer to just wake up via an interrupt anytime power is applied.

Similar to this:

Per the boron schematics it looks like the interrupt pin of BQ24195L is connected to the nRF52840:


But how do I access that pin so when I sleep I can sleep with an interrupt on that pin? Looks like it's P0.05 but I am struggling to find the reference to that PIN in any documentation or device OS reference. Maybe I'm overlooking something?

Alright, I think I found the answer to my own question. Posting here in case anyone else wants to know. The pin is LOW_BAT_UC and to wake a device up using this you can use:

gpio(LOW_BAT_UC, FALLING);

I should of looked harder as it is called out here in the docs. I was just a bit confused as when I read this I assumed it was for the tracker only but turns out this works for the Boron as well.

Only question I have is it better to use FALLING or RISING or does it matter? Is there any increase leakage current or power draw by using one vs the other when sleeping?

Here is a larger code snippet if someone finds it useful:

//Configure sleep. Duration is total duration plus 1 second as we should always wake up from AB1805 interrupt. The duration is used just in case we didn't wake up by the AB1805 alarm we set.  
        SystemSleepConfiguration config;
        config.mode(SystemSleepMode::ULTRA_LOW_POWER)
              .duration(tm.nxtRptStart_Millis - millis()+1000)
              .gpio(AB1805_IRQ, FALLING)
              .gpio(LOW_BAT_UC, FALLING);
        
        // Let's now go to sleep but let's capture the wake up reason as that dictates what state we go to next.
        SystemSleepResult result = System.sleep(config);
        if (result.wakeupReason() == SystemSleepWakeupReason::BY_GPIO) {
          // Waken by pin 
          pin_t whichPin = result.wakeupPin();
          if (whichPin == LOW_BAT_UC) {
            
            // Waken by Power being applied. Let's resume the watchdog, update wake reason, publish our own sensor data, which connects to the cloud. 
            ab1805.resumeWDT();
            ab1805.updateWakeReason();
            newState = st_PubStat;
            break;
          }
        }

I believe you need to use FALLING.

The reason is that the PMIC interrupt is open-collector, and on the Boron there is a hardware pull-up on the pin.

When you use a RISING interrupt for sleep, a software pull-down is applied (13K on the Boron), so you effectively have a voltage divider and the signal may never go high to wake.

When you use FALLING, there is a hardware pull-up (13K) but this will be in parallel with the hardware pull-up, and the resistance is still acceptable.

If you use CHANGE, there is no pull applied.

1 Like