System.sleep and WKP Pin

I’m using the exact one from the examples:

case SLEEP_STATE:
  // Wait for Electron to stop moving for 2 seconds so we can recalibrate the accelerometer
  accel.calibrateFilter(2000);

  // Is this necessary?
  //digitalWrite(D6, HIGH);
  //pinMode(D6, INPUT);

  Serial.println("going to sleep");
  delay(500);

  // Sleep
  System.sleep(WKP, RISING, TIME_PUBLISH_BATTERY_SEC, SLEEP_NETWORK_STANDBY);

  // This delay should not be necessary, but sometimes things don't seem to work right
  // immediately coming out of sleep.
  delay(500);

  awake = ((accel.clearInterrupt() & LIS3DH::INT1_SRC_IA) != 0);

  Serial.printlnf("awake=%d", awake);

  // Restart the GPS
  //pinMode(D6, OUTPUT);
  digitalWrite(D6, LOW);
  startFix = millis();
  gettingFix = true;

  state = GPS_WAIT_STATE;
  stateTime = millis();
  break;

Am I missing something?

rickkas7 - on the topic of accel.calibrateFilter() - when does this need done and how often?

I would call it every time before sleep. That is especially important there is a possibility if the Electron will ever be tilted at all.

	/**
	 * The movement interrupt needs to be calculated to take into account gravity and its
	 * current orientation. For this to work, the object must be stationary. You typically
	 * call this method before putting the device to sleep for wake-on-move. The stationnaryTime
	 * is the amount of time the device needs to be stationary, in milliseconds. Typically, you'd
	 * wait a few seconds. The maxWaitTime is the amount of time in milliseconds to wait for
	 * the device to stop moving. 0 means wait forever.
	 */
	bool calibrateFilter(unsigned long stationaryTime, unsigned long maxWaitTime = 0);

Thank you - good advice. I couldn’t think of a reason NOT to call it but I’m still wrapping my head around how to squeeze the most battery life out of the electron.

Hello,
I have replaced Electron with Photon in Asset tracker. I am using Asset tracker library and wake on move example by rikkas7. The problem is after several minutes, when the device is bumped, Photon powers up but goes back to sleep without publishing the coordinates.

There is also a strange problem when the photon is sleeping for 45+ minutes. The photon wakes up on its own and starts blinking green. I think Blinking green indicates a lose of wifi connection. but the wifi is working OK and dont know why it starts blinking green. And it do not stop blinking until I reset the device. Any suggestions?

Which AssetTracker library? The official one or my library, AssetTrackerRK?

I wrote the wake-on-move code in both, but the official AssetTracker library does not work particularly well for wake-on-move because I misunderstood how the LIS3DH wake-on-move worked. I wrote the modified version in AssetTrackerRK and it seems to work much better.

Since I wasn’t sure whether it would work better or not, I haven’t merged the change back into the official build yet.

I am using AssetTrackerRK library. As the official library was not giving me accurate gps coordinates.

@rickkas7 I am trying to use your piece of firmware on a 2G electron with the asset tracker shield with no success. it keeps looping recalibrating, even though the electron is stationary.

Am I missing something? (tried 0.5.0, 0.5.3, 0.6.0-rc.2)

thank you for your help.
regards


recalibrating
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
recalibrating
resetting lastMovement int1_src=0x56
recalibrating
resetting lastMovement int1_src=0x56
recalibrating
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
recalibrating
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
recalibrating
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
resetting lastMovement int1_src=0x56
recalibrating

I presume you’re using the 3_WakeOnMove example?

Is the Electron sitting still? It must not be moving at all for 2 seconds before it will go to sleep.

If it’s too sensitive, change the value passed to setLowPowerWakeMode to a value larger than 16.

@rickkas7 Hi Rick. I am using the the sample program you provided earlier in this thread to test calibration. The electron is indeed standing still and I changed the setLowPowerWakeMode to larger values (32). but still looping / recalibrating. and once in a while, movementInterrupt detection when I shake the electron like crazy.

thank you

Oh, if you’re using the calibration example, that’s all it’s supposed to do! You’ll have to pick one of the other examples if you want it to do something useful.

Rickkas7 - Now that the asset tracker library (official library) has incremented a few times since I last looked at it, do we know if your updates were rolled into the current asset tracker library?

Thanks
Tony