Sleep Mode; can't Wakeup for short period of time

This is a relatively minor issue for my application, but one that still seems to affect some of my results every now and then. I have an accelerometer (ADXL-362) with the INT pin connected to the WKP pin on the Electron. I call the following code:

  	accel.writeFilterControl(accel.RANGE_4G, false, false, accel.ODR_50);
  	accel.writeActivityThreshold(450);
  	accel.writeInactivityThreshold(150);
  	accel.writeInactivityTime(500);
  	accel.writeActivityControl(accel.LINKLOOP_LOOP, true, true, true, true);
  	accel.writeIntmap1(accel.STATUS_AWAKE);
  	accel.writePowerCtl(false, false, false, true, accel.MEASURE_MEASUREMENT);

after which the Electron enters Deep Sleep. Now the issue is that for the first 8 seconds or so after entering Deep Sleep, movement will not wake up the Electron. It needs to be held relatively still for a while, before the accelerometer can actually interrupt it. If the Electron continues to move a lot after entering Deep Sleep, this could easily prevent the accelerometer from waking it up for a long period of time.

Ideally I'd like the accelerometer to be able to Wakeup the Electron instantly after it enters Deep Sleep (provided it detected movement). Can anyone provide any insight on this?

Are you sure it’s a wake issue and not an acceleration calibration issue? The best way to troubleshoot that is instead of going to sleep, print the value of the WKP pin to the serial console frequently.

2 Likes

@Vitesze,

I am using a different accelerometer (MMA8451Q) but have the same use case as you. I have not had any issue with the Electron waking, servicing the interrupt and going back to sleep all in well under a second whether from reset or in normal operation. All this to say that @rikkas7 may be on the right point with his comments.

Good luck.

Thanks, Chip

1 Like

That’s what I figured. The accelerometer functions absolutely fine, but the value of the WKP pin seems to remain high for a while after it has gone to sleep…I will do some testing with the value-printing tomorrow.

The WKP is not allowed to be HIGH when the device enters sleep mode.
You could try to postpone the sleep call with something like this while(digitalRead(WKP)) Particle.process(); to make sure a subsequent rising edge can trigger the wake.

1 Like

ScruffR is correct, because WKP is active high, if your accelerometer leaves WKP high, you won’t go to sleep. When I did the LIS3DH wake-on-move support, I switched the INT output to latching. That way, when I service the wake interrupt I can write to a register to clear it so it’s possible to go back to sleep immediately. Also, it provides a convenient way to tell if I was wakened by movement (WKP=HIGH) or time (WKP=LOW).

2 Likes

I checked this, and after the calibration (or any movement) the INT pin always remain high for 6 to 8 seconds. I know that you mentioned it’s not possible to sleep while WKP is still high, however when I call analogRead(WKP) right before Deep Sleep, it still shows up as High, and the 6-8 seconds of cooldown period still applies.

Your LIS3DH example works totally fine for me however. Unfortunately, I already have 60 ADXL-362 sensors right now, and would prefer to find a workaround for this with them.

Make sure you're reading the status register of the ADXL362 when waking up. That's what clears the activity interrupt.

Reading the STATUS register (Address 0x0B) clears
activity and inactivity interrupts.

In the AssetTrackerRK WakeOnMoveExample you can see how the interrupt is cleared after stop mode sleep (pin + time).

When using SLEEP_MODE_DEEP you should call clearInterrupt() in setup().

That's for the LIS3DH, but it's basically the same with the ADXL362. If using my ADXL362DMA library, use the readStatus() method instead of clearInterrupt(), but any library should have a similar function.

5 Likes