TinyZero with Accelerometer & Wake from Sleep


  • Newbie
  • *
    • Posts: 1
    • View Profile
I just purchased a Tiny Zero with the built-in accelerometer.  I would like to build a small app that goes into low-power mode and wakes up via an interrupt from the accelerometer if it detects significant movement.

I have the accelerometer working, but I'm looking for some sample code which puts it to sleep and codes the accelerometer to generate the interrupt appropriately.  From what I read people were soldering connections to make INT1 work on the proto board, but I'm wondering about the TinyZero which has it all integrated on the same board.

Thanks for your help.


  • Administrator
  • Full Member
  • *****
    • Posts: 20
    • View Profile
Hi Steve,

As can be seen in the TinyZero schematic and board files, the INT1 pin of the BMA250 accelerometer is only broken out to a solder pad on the bottom side of the board. This is the small copper circle labeled "INT1" next to the "BOOT" button.

Because of this, a wire would have to be soldered to this pad and then input to the processor via a Proto Board TinyShield. According to the official Arduino documentation for interrupts, any digital pin except for digital pin 4 is usable for interrupt input to the TinyZero processor.

If this is something you'd still like to pursue, I can look into getting some sample code for this.

Hope this helps.
- Hunter


  • Jr. Member
  • **
    • Posts: 9
    • View Profile
Hi, I'm also interested in this functionality and wondered if there is any sample code available?

btw I have this working via the following code

the setup() code for the interrupt - note the use of FALLING is so the rtc.standbyMode() triggers

  pinMode(1, INPUT_PULLDOWN); //BMA raises pin high on interrupt
  attachInterrupt(digitalPinToInterrupt(1), BMAInterrupt, FALLING); // try RISING?

The interrupt routine itself - bare bones

void BMAInterrupt()
  motionInterrupt = true; // flag motion

And the code for initialising interrupt for 'any motion' which is added to the begin() routine

   // set the interrupt mode - this is temporary 500 usec
   // note we don't not latched the interrupt
   Wire.write(0x21); // interrupt mode - see page 23 of the spec
   // enable slope interrupts - used for 'any motion' detection
   // Map slope interrupt to pin 1
   // Use 4 samples for the slope interrupt - threshold duration
   Wire.write(0x02); // reduce to 3 from 4
   // And set slope threshold
   Wire.write(0x28); // slope threshold
   Wire.write(0x14); // note this is the default value - see page 47 of the spec
« Last Edit: December 27, 2021, 10:45:44 AM by greg.brougham »


SMF spam blocked by CleanTalk