So I'm relatively new to microcontrollers, and I'm having a problem implementing a feature I want for a project.
I've learned about putting an Atmega328P to sleep from this tutorial. I'm using an Arduino Nano, so I only get my current down to ~9mA rather than the µAs the tutor is getting. Nonetheless, it demonstrates the abstraction I want to learn for when I move to just the Atmega328 with no board.
I've learned to wake up my microcontroller from sleep with a falling external interrupt on INT0/D2 from a simple button. My ISR is empty and just boots me back to the loop, which is fine. As an aside, I have heard that it is better to have simple and short ISR's, but I am not completely sure why.
My question is, can I use my ADXL345 to trigger an interrupt that wakes my Arduino? I am semi-familiar with using an ADXL345 over I2C, although I don't understand why my Sparkfun ADXL345 requires different wiring than my unbranded one, but that's for a separate question I suppose.
So my question is, is it possible, and if so, how? Also, is the I2C connection meaningful for an ADXL345 that is primarily being used as a wake-up interrupt on the Z-axis only? (My use case is an item someone picks up, which wakes my embedded circuit out of sleep and begins logging load cell and UWB sensor data, and is put back to sleep after a period of inactivity).
Thanks in advance - I appreciate any and all help!
EMPTY_INTERRUPT(INT0_vect);
instead. Secondly, the Atmega328P can wake up from falling edge interrupt to (though the datasheets states differently). What I sometimes to is disabled the INT0 interrupt inside the ISR, so it only fires once; then enable it again before I go to sleep. The accelerometer probably doesn't remember any settings, so you'd still need the I2C to setup the ADXL345 at power-up.