Asset Tracker Accelerometer + GPS problem


#1

Folks,
Got my Electron and Asset Tracker shield yesterday. In less than an hour i had my Electron talking to the cloud with GPS and battery data using the 1_GPS_FEATURES.CPP example from the ASSETTRACKER particle library. I then was able to get the accelerometer features working using the 2_ACCELEROMETER.CPP example. Trouble started when I tried to combine the features. As soon as I try to enable the GPS, the accelerometer stopped working. I can’t get the accelerometer to read anything but 0’s whenever I enable the GPS.

I’ve been staring at it for hours and can duplicate the problem as simply as adding the single line
t.gpsOn();

Has anyone used both the GPS and accelerometer in the same sketch on the ASSET TRACKER board. ?

FWIW… here’s an example of the problem from the code in 2_ACCELEROMETER.CPP from the ASSETTRACKER library

ie. with this Setup()… with no call to t.gpsOn() I can read the accelerometer

#include "AssetTracker/AssetTracker.h"
..
AssetTracker t = AssetTracker();
..
void setup() {
    // Sets up all the necessary AssetTracker bits
    t.begin();

   // t.gpsOn();  // no initialization of gps .. and it works
    // Opens up a Serial port so you can listen over USB
    Serial.begin(9600);

    // These three functions are useful for remote diagnostics. Read more below.
    Particle.function("aThresh",accelThresholder);
    Particle.function("tmode", transmitMode);
    Particle.function("batt", batteryStatus);
}

but… with this Setup()…if i do add the call to t.gpsOn() I can no longer read the accelerometer

#include "AssetTracker/AssetTracker.h"
..
AssetTracker t = AssetTracker();
..
void setup() {
    // Sets up all the necessary AssetTracker bits
    t.begin();

   t.gpsOn();   // initialization of gps .. and it no longer works
    // Opens up a Serial port so you can listen over USB
    Serial.begin(9600);

    // These three functions are useful for remote diagnostics. Read more below.
    Particle.function("aThresh",accelThresholder);
    Particle.function("tmode", transmitMode);
    Particle.function("batt", batteryStatus);
}

Accelerometer not working after turning off GPS
#2

Ping @Dick


#3

Thanks for the tag @kennethlimcp! Hiya @johncohn, if that’s having issues it’s probably my fault- I put together the library. gpsOn() shouldn’t cause issues for the accel, but you never know. Could you paste in the rest of your code?

You can also check out @Dave’s awesome library- https://github.com/dmiddlecamp/fancy-asset-tracker

Here’s what’s in gpsOn(), for reference:

void AssetTracker::gpsOn(){
    // Power to the GPS is controlled by a FET connected to D6
    pinMode(D6,OUTPUT);
    digitalWrite(D6,LOW);
    gps.begin(9600);
    gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
    delay(500);
    // Default is 1 Hz update rate
    gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
    delay(500);    
    gps.sendCommand(PGCMD_NOANTENNA);
    delay(500);
}

#4

Dick, Thanks for the pointer,

Dave…
I absolutely love the fancy asset code. Works great… I do have a couple of questions…

  1. When I power up the shield, it works just like I would expect… two bumps and it wakes up… … What I notice is that after awhile (not sure exactly how long… several minutes… ) it goes into deep sleep and will not wake with a bump. Isn’t the logic supposed to wake the electron even then ? I’m banking it as hard as I date… and it won’t wake. I have to hit reset to get it to turn on… any thoughts on what might be happening ?
  2. i want to also record the maximum g forces the device was subject to. do either of you guys know that if I do an accel.x,accel.y,accel.z after the bump that woke me that I would be able to read the magnitude of that first bump ? I know how to read it and keep max while the tracker is in motion
  3. (electron noob question) you are currently publishing a single combined sentence with all the gps info. I would prefer to have that info query able as a particle variable so it can also be queried whenever. I was thinking of setting a variable with lat/lon and max acceleration at the point in the code that you do the publish. Is there some power tradeoff in using a variable vs a publish ? I suspect there is.

thanks again for the excellent work !!!
-jc

.


#5

LL,
Adding some simple serial debug it looks to me like the Wake on Pin from deep sleep is not working. I can get it to wake once from deep sleep my thwacking the accelerometer… but it comes up in a mode i don’t understand. It has a breathing white status light but It does not seem either to hit the serial debug in the Setup or Loop code… Whats more… it eventually falls asleep from that and won’t wake less i push reset no matter how many times i hit the accelerometer.
I saw that there were some firmware issues related to this in versions of the Photon. is it possible that Wake on Pin is not working in the Electron ? Thanks
-jc


#6

You can not wake from PIN using Deep Sleep.

System.sleep has the wake from Pin functionality but its currently not working correctly.

Code has been fixed for System.sleep so you can wake from PIN but there are reported issues with not being able to Particle Publish if you sleep longer than 25 mins.

This issue has been raised here: https://github.com/spark/firmware/issues/888


#7

Hmmm… thats too bad… Does anyone know if there’s a fix in the works for the Sleep timeout ?
Also Can anyone help me figure out how to use the System.sleep in a way that does wake on pin, but does not hit the 25 min limit. I was trying something like System.sleep(D1,RISING,20*60); .but that doesn’t seem to work. I can’t tel from the ASEET TRACKER code or the board what Electron pin is used as a wakeup interrupt form the accelerometer and what direction it transitions to signal a bump. Does anyone know whee thats documented ? Sorry to be a little slow here.
-jc


#8

Hey All,

Thanks for checking out that demo!

To answer the questions from earlier:

  1. When I power up the shield, it works just like I would expect… two bumps and it wakes up… … What I notice is that after awhile (not sure exactly how long… several minutes… ) it goes into deep sleep and will not wake with a bump. Isn’t the logic supposed to wake the electron even then ? I’m banking it as hard as I date… and it won’t wake. I have to hit reset to get it to turn on… any thoughts on what might be happening ?

– I also noticed I’m getting weird behaviors on wake. The first few wakes work normally, and then they seem to stop working. I’m not sure yet if this is an issue with my code, or with the system firmware. I had originally assumed this was the battery running out, but I think it’s a wakeup issue.

  1. i want to also record the maximum g forces the device was subject to. do either of you guys know that if I do an accel.x,accel.y,accel.z after the bump that woke me that I would be able to read the magnitude of that first bump ? I know how to read it and keep max while the tracker is in motion

The accelerometer is reading very fast (5000 reads per second). So if you call accel.read() right before Serial.println("BUMP!");, you just might catch the high value. There is probably a better way to do this, but I’m not an accelerometer expert, hopefully someone else can suggest a better solution (probably something something interrupts). :slight_smile:

  1. (electron noob question) you are currently publishing a single combined sentence with all the gps info. I would prefer to have that info query able as a particle variable so it can also be queried whenever. I was thinking of setting a variable with lat/lon and max acceleration at the point in the code that you do the publish. Is there some power tradeoff in using a variable vs a publish ? I suspect there is.

With publish you can send the data into the cloud and quickly go back to sleep, which is nice for things that come on and offline. You will use less data, and you’ll have a better chance of catching the event. If you used a variable you’d need to listen for the online event, and then have something actively getting the variable value, instead of just always passively listening for events, or using a webhook.

Thanks!
David


#9

@Dave If your missing published events after waking from System.sleep(); then its the current firmware bug.

See here for more info about it: Electron not publishing after Sleep (Stop Mode)


#10

Hmm, I managed to wake my electron from one of these “comatose” states by leaving the WKP pin higher for longer using a jumper wire… I wonder if maybe the signal from the accelerometer isn’t HIGH long enough, or maybe the WKP pin is somehow checked less frequently during sleep states? (I realize this isn’t how interrupt pins are meant to work, but that seems to reflect what I just saw)

Thanks,
David


Confusion on waking up Electron Asset Tracker
Confusion on waking up Electron Asset Tracker
#11

Have had some of the same issues with wake on motion. I had a vibration sensor (SW-18010P) on hand, and tried it across the WKP and 3.3 pins.

You have to orient it for max sensitivity, but it seems to trigger wake reliably when I have a board in the “comatose” state.


#12

@Dave did you found out the solution for the problem?

I think I have a duplicate question out Confusion on waking up Electron Asset Tracker
I will try with a jumper wire as well to test.


#13

Having
System.sleep(WKP, RISING, seconds);
when I connect WKP with 3.3 with a jumper - the board gets up. So I guess the problem is in embedded accelerometer. Maybe it doesn’t hit some threshold, but how to set it?

Anyway - for now I treat the embedded wake up from motion as not working and going to use something like SW-18020P - I will try in a few days what is the result of that.

Can anyone confirm that with Electro Asset Tracker board - he is able to wake electron on motion?


#14

@mohit @Dick have you tested wakeup on motion using the accelerometer?


#15

I just implemented wake on move for the Electron Asset Tracker accelerometer; it works great!

There’s a lot of setup that needs to be done for the LIS3DH to enable movement interrupts, but once you do it does work. I encapsulated all of that code in a library so you can make a single method call to enable it:

That’s the library repository (also available in the community libraries), but the example program inside wakes the Electron when moved.

Also, there’s code in there to get wildly inaccurate temperature readings of the temperature of your AssetTracker from the LIS3DH chip! The accuracy is the fault of the chip, not the library; it’s just not a very accurate thermometer.

Rick


#16

jc, or anyone - how’d you include the fancy-asset-tracker library?

thx,

~dab


#17

How are you building? What IDE are you using?
In order to get a proper answer, fundamental info should be provided immediately.


#18

I can use the cloud build or the CLI. What do you recommend? Thx


#19

CLI is also cloud build, just like Particle Dev or Particle Build.

But I’d recommend CLI since that’s the suggested way in the library repo
https://github.com/dmiddlecamp/fancy-asset-tracker

But the bash scripts for building will not run on all OSs - which one are you on?

Can you read the scripts to get the idea what’s required to get them ported to your OS (if required)?

If you look at the samples, you’ll also see how you’d import the actual library into your own projects.

BTW, what version Asset Tracker Shield have you got? I’ve got a v002 which seems to lack ability to wake on movement as used by motion-tracker demo.
@rickkas7, you got the LIS3DH working, what shield version have you got?


#20

I’m not positive, but I think I have the v002 version, and I did get wake-on-move to work, though I also wrote my own LIS3DH driver to do it.

From my possibly incorrect interpretation of the Eagle board file: with the AssetTracker sitting with the 3V3 rail away from you, Electron on the right.

v002: the coin cell battery holder is closest to you, on the GND rail side.
v003: the coin cell battery holder is away from you, on the 3V3 rail side.

Is that correct?

I looked for something more obvious like a version number silk screened on the board somewhere, but I didn’t see one. I might just have missed it.