There were a couple of requests for examples of accelerometer use with optimized power, so I played around to create some examples and measure their power usage. The attached zip files contain a series of sketches that help quantify incremental power usage for a few accelerometer features.
PowerTests.zip (8.3 KB)
-
gpioWakeUp: 4.2 uA idle, 1.9 uA system_off sleep. I think this is close to minimal power usage for the Xiao sense and provides a baseline. Demonstrates wake up with a GPIO input. No attached interrupt routine.
-
gpioInterrupt: 18.6 uA idle, 1.9 uA system_off sleep. Adds an interrupt service routine attached to a button. Arduino uses āhigh accuracyā interrupts, so adds 14uA to idle power usage. Increased power can be avoided using a custom interrupt routine as described here: Getting lower power consumption on Seeed XIAO nRF52840.
-
nudgeWakeUp: 4.2 uA idle, 7.9uA system_off sleep. Uses the āwake-upā feature of the accelerometer to wake from system_off. The accelerometer only used for wake-up. No interrupt handling.
There is a trade-off between accelerator performance and power usage. The wake-up function power usage depends on the āoutput data rateā (ODR). The application note uses a default of 416Hz with a resulting power usage of 162 uA in system_off sleep. The nudgeWakeUp sketch is using the minimum rate of 1.6Hz. It still detects movement, but the movement detection is noticeably different. For a specific application with a low power design goal I would imagine starting with the low power setting and then tuning parameters until it performed as desired.
- doubleTapWakeUp: 4.2 uA idle, 28 uA system_off sleep. Uses the double-tap feature to wake from system_off. No interrupt handling.
The double-tap detection parameters are affected more by the ODR. The sketch ODR value of 52Hz is the lowest I could use and still get it to work somewhat reliably. (I didnāt play around that long, so someone might get different results). The application note uses 416Hz which results in 162 uA. If you change the ODR, you need to adjust other detection parameters to match the results of the application note.
- combination: 179.3 uA idle, 7.9 uA system_off sleep. Combines all of the above and includes response to the double-tap. Uses the low power accelerator wake-up function during system_off sleep and turns on the double-tap response once awake. (My fitbit seems to work this way.)
Next Iāll add some Bluetooth functionality and see how it affects the power usage.