Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
I2C AND attachInterrupt current consumption in sleep mode #291
I'm using a module with NRF52832 (as a Generic NRF52 board with RC oscillator and s132) without any conections, excepting SWD interface. I put it into sleep mode with __WFI(); and it consumes 2.6 uA.
But when I initialise my accelerometer (using Sparkfun's MMA8452Q library, but in sleep mode (~8 uA)) the current jumps to 450 uA, which is not ok.
Now, if I remove attachInterrupt and keep only the accelerometer, it consume only 2.6 uA (like in the begining).
It's normal to consume 450 uA when are both?
I know nothing about the Sandeepmistry implementation of the gpiote driver but I know in the Nordic SDK if you enable the high accuracy mode on the pin change interrupt you'll see exactly the 450 uA power consumption you described. Setting hi_accuracy to false will fix it.
I looked into the sandeepmistry WInterrupts.c file for the attachInterrupt function and it does look like they only implemented the hi_accu version of the nRF52 pin interrupt. Also, with the NRF52 if you don't disable the TWI interface before sleeping you will get increased power consumption. I always disable the TWI when I'm not using it. You can probably use Wire.end() to achieve this.
Thanks a lot for guiding!
I've tried with Wire.endTransmission() but nothing important happened.
So I've added:
and it worked great.
Thank you again!