Waking up using 12V and IMU

Currently, I am looking for a way to wake up the Particle One device. We would like to put it in a sleep mode and wake up using two sources: an input from the M8 pin 2 connector OR any motion.

I checked this link

https://docs.particle.io/reference/asset-tracking/tracker-edge-firmware/#trackersleep

it mentioned

motion (IMU), BLE, GPIO pin interrupts,

However, I wasn’t able to see any APIs regarding the motion wake-up. I am able to see time based wakeup, BLE, and GPIO. I saw the motionservice but the document discourages to use that.

Second, the wake up from +12V input (rising edge trigger). I looked at the schematic, Tracker One | Datasheets | Particle and I can’t see if there is a way to wake up the Particle one. If that isn’t possible, I think what we can do is do a voltage divider and connect the output to one GPIO pin for wake-up.

Also, is there a way to tell if the Particle Tracker one is operating on battery or on M8 pin 2 12V?

Third, is it possible to have two wake-up sources at the same time (motion and power +12V)?

thanks!

Yes, this is possible. Wake on movement is not on the sleep settings is that it’s handled automatically based on the configuration you’ve set in the product configuration in the console. Essentially the options you pass in code are in addition to the ones from the cloud.

To wake on power applied, see this post. Basically, you wake on the pin:

TrackerSleep::instance().wakeFor(PMIC_INT, FALLING);

Hi Rick,

Thanks for the reply. I implemented it but I am having challenges making it work.

This is the code on my initialization setup

    // Initialize tracker stuff
    Tracker::instance().init();

    TrackerSleep::instance().wakeFor(PMIC_INT, FALLING);

    // https://docs.particle.io/reference/asset-tracking/tracker-edge-firmware/#trackersleep
    TrackerSleep::instance().registerSleepPrepare(prepareSleepCallback);
    TrackerSleep::instance().registerWake(wakeCallback);

The callbacks just prints statements to see when they are activated

Here is the test code (there are some more codes but I just extracted the part that we are concerned with on the loop function

    // Must call this on every loop
    Tracker::instance().loop();

    static uint32_t executiontime = millis();
    if(millis()-executiontime>5000 ) // every 5 seconds
    {
        if (!TrackerSleep::instance().isSleepDisabled()) {
            Log.info("Sleep Enabled");  // This never gets called
        }

        Log.info("ExtendExecutionFromNow");
        TrackerSleep::instance().resumeSleep();
        TrackerSleep::instance().extendExecutionFromNow(2, true); // force the sleep within 2 seconds
        TrackerSleep::instance().resumeSleep();
        executiontime = millis();
    }


    if(millis()-recordedmillis>2000 ) // every 2 seconds
    {
        Log.info("Alive");
        recordedmillis = millis();
    }

I am wondering why the “Sleep Enabled” never gets printed. I did set that on the config but it seems the sleep isn’t enabled (I restarted the unit multiple times to ensure that it communicates to the cloud and get the configurations)

Here is the log.

0000001595 [system.nm] INFO: State changed: DISABLED -> IFACE_DOWN
0000001598 [system.nm] INFO: State changed: IFACE_DOWN -> IFACE_REQUEST_UP
0000001601 [ncp.client] TRACE: Modem already on
0000001644 [system.nm] INFO: State changed: IFACE_REQUEST_UP -> IFACE_UP
0000001670 [mux] INFO: Starting GSM07.10 muxer
0000001670 [mux] INFO: Openning mux channel 0
0000001670 [mux] INFO: GSM07.10 muxer thread started
0000001672 [mux] INFO: Openning mux channel 1
0000001680 [app] INFO: loading config sleep: {"version":1,"hash":"8E9D079E453B3A2824D69F608677ADBB","sleep":{"mode":"disable","exe_min":10,"conn_max":90}}
0000001686 [app] INFO: loading config tracker: {"version":1,"hash":"F53736A0E3B271B9273988F4273988F4","tracker":{"usb_cmd":true}}
0000001724 [ncp.client] TRACE: NCP ready to accept AT commands
0000001970 [mux] INFO: Mux channel 1 already opened
0000001973 [ncp.client] TRACE: NCP state changed: 1
0000001973 [net.pppncp] TRACE: NCP event 1
0000002323 [ncp.client] TRACE: NCP connection state changed: 1
0000002324 [net.pppncp] TRACE: NCP event 2
0000002324 [net.pppncp] TRACE: State changed event: 1
0000002727 [app.gps.ubx] INFO: enable PUBX-POSITION
0000002738 [app.gps.ubx] INFO: enable PUBX-SVSTATUS
0000002742 [app.gps.ubx] INFO: enable PUBX-TIME
0000002778 [app.gps.ubx] INFO: enable GPS
0000002778 [app.gps.ubx] INFO: enable QZSS
0000002779 [app.gps.ubx] INFO: enable SBAS
0000002779 [app.gps.ubx] INFO: enable Galileo
0000002779 [app.gps.ubx] INFO: enable BeiDou
0000002780 [app.gps.ubx] INFO: enable GLONASS
0000002785 [app.gps.ubx] INFO: set to power management mode 0
0000002788 [app.gps.ubx] INFO: set dynamic platform model to 0
0000002800 [app] INFO: loading config temp_trig: {"version":1,"hash":"5E7EBC8151C42627DEBDB6A5FFA70B76","temp_trig":{"high":25,"high_en":false,"high_latch":true,"low":25,"low_en":fa~
0000002857 [app] INFO: loading config location: {"version":1,"hash":"86CA9730BC7D499F063BA22E2EC66B24","location":{"radius":0,"interval_min":900,"interval_max":3600,"min_publish":fa~
0000002864 [app] INFO: loading config imu_trig: {"version":1,"hash":"5E5488D40858A17D5C214BA3319647FD","imu_trig":{"motion":"disable","high_g":"disable"}}
0000002881 [app] INFO: loading config rgb: {"version":1,"hash":"2B1CD6509BBD4801D3AF1DE32E1A9D23","rgb":{"type":"particle","direct":{"brightness":255,"red":0,"green":0,"blue":255}}}
0000002989 [app] INFO: CAN initialization succeeded
0000003000 [app] INFO: EEPROM Not Blank!
0000003001 [app] INFO: Date 2021/7/24  22:0:46
0000003002 [app] INFO: Starting modem
0000003003 [app] TRACE: onSleepState starting GNSS
0000004068 [app.gps.ubx] INFO: enable PUBX-POSITION
0000004079 [app.gps.ubx] INFO: enable PUBX-SVSTATUS
0000004085 [app.gps.ubx] INFO: enable PUBX-TIME
0000004143 [app.gps.ubx] INFO: enable GPS
0000004144 [app.gps.ubx] INFO: enable QZSS
0000004144 [app.gps.ubx] INFO: enable SBAS
0000004144 [app.gps.ubx] INFO: enable Galileo
0000004145 [app.gps.ubx] INFO: enable BeiDou
0000004145 [app.gps.ubx] INFO: enable GLONASS
0000004154 [app.gps.ubx] INFO: set to power management mode 0
0000004160 [app.gps.ubx] INFO: set dynamic platform model to 0
0000004169 [ncp.client] TRACE: NCP connection state changed: 2
0000004169 [mux] INFO: Openning mux channel 2
0000004219 [net.pppncp] TRACE: NCP event 100
0000004220 [net.pppncp] TRACE: New auth info
0000004221 [net.pppncp] TRACE: NCP event 2
0000004222 [net.pppncp] TRACE: State changed event: 2
0000005246 [app.gps.ubx] INFO: enable PUBX-POSITION
0000005258 [app.gps.ubx] INFO: enable PUBX-SVSTATUS
0000005263 [app.gps.ubx] INFO: enable PUBX-TIME
0000005322 [app.gps.ubx] INFO: enable GPS
0000005323 [app.gps.ubx] INFO: enable QZSS
0000005323 [app.gps.ubx] INFO: enable SBAS
0000005324 [app.gps.ubx] INFO: enable Galileo
0000005324 [app.gps.ubx] INFO: enable BeiDou
0000005324 [app.gps.ubx] INFO: enable GLONASS
0000005386 [app.gps.ubx] INFO: set to power management mode 0
0000005392 [app.gps.ubx] INFO: set dynamic platform model to 0
0000005400 [app] TRACE: evaluatePublish first
0000005402 [system.nm] TRACE: Request to power on the interface
0000005403 [app] TRACE: waiting for stable GNSS lock for triggers
0000005405 [app] INFO: Alive
0000005417 [app] TRACE: evaluatePublish first
0000005417 [app] TRACE: waiting for stable GNSS lock for triggers
0000005432 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0000005434 [net.pppncp] TRACE: Negotiated MTU: 1500
0000005435 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0000005436 [system] INFO: Cloud: connecting
0000005440 [system] INFO: Cloud socket connected
0000005440 [comm.protocol.handshake] INFO: Establish secure connection
0000005723 [hal] ERROR: Not found response
0000005742 [hal] ERROR: CMD0 response error, expect 0x1, response 0
0000005743 [hal] ERROR: Please restart slave and test again,error code:264
0000005955 [hal] TRACE: Cached ESP32 NCP firmware version: 7
0000005957 [comm.protocol.handshake] INFO: Skipping HELLO message
0000005963 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0000005965 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0000006230 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000006230 [comm.protocol] TRACE: message id 80 complete with code 0.00
0000006232 [comm.protocol] TRACE: rcv'd message type=13
0000006245 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000006245 [comm.protocol] TRACE: message id 81 complete with code 0.00
0000006247 [comm.protocol] TRACE: rcv'd message type=13
0000006256 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000006258 [comm.protocol] TRACE: message id 82 complete with code 0.00
0000006258 [comm.protocol] TRACE: rcv'd message type=13
0000006360 [system] INFO: Cloud connected
0000006411 [app] TRACE: evaluatePublish first
0000006411 [app] TRACE: waiting for stable GNSS lock for triggers
0000007001 [app] INFO: cloud sent: {"cmd":"sync","time":1627164050,"hash":"78B454AB23887B369800A1766B21C878"}
0000007199 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000007201 [comm.protocol] TRACE: message id 83 complete with code 0.00
0000007203 [comm.protocol] TRACE: rcv'd message type=13
0000007408 [app] INFO: Alive
0000007409 [comm.protocol] TRACE: rcv'd message type=8
0000007411 [app] TRACE: evaluatePublish first
0000007411 [app] TRACE: publishing from triggers
0000007412 [app] INFO: publishing now...
0000007413 [app] TRACE: extending execution
0000007805 [ncp.esp32.at] TRACE: > AT
0000007808 [ncp.esp32.at] TRACE: < OK
0000008808 [ncp.esp32.client] TRACE: NCP ready to accept AT commands
0000008810 [ncp.esp32.at] TRACE: > AT+MVER
0000008812 [ncp.esp32.at] TRACE: < 7
0000008812 [ncp.esp32.at] TRACE: < OK
0000008814 [ncp.esp32.at] TRACE: > AT+CMUX=0
0000008817 [ncp.esp32.at] TRACE: < OK
0000008817 [ncp.esp32.mux] INFO: Starting GSM07.10 muxer
0000008818 [ncp.esp32.mux] INFO: Openning mux channel 0
0000008818 [ncp.esp32.mux] INFO: GSM07.10 muxer thread started
0000008824 [ncp.esp32.mux] INFO: Openning mux channel 1
0000008835 [ncp.esp32.at] TRACE: > AT
0000008841 [ncp.esp32.at] TRACE: < OK
0000008845 [ncp.esp32.at] TRACE: > AT+CWDHCP=0,3
0000008852 [ncp.esp32.at] TRACE: < OK
0000008852 [ncp.esp32.client] TRACE: NCP state changed: 1
0000008853 [system.nm] TRACE: Interface 5 power state changed: 2
0000008858 [ncp.esp32.at] TRACE: > AT+CWLAP
0000010975 [ncp.esp32.at] TRACE: < OK
0000010977 [app] INFO: {"cmd":"loc","time":1627164050,"loc":{"lck":1,"time":1627164051,"lat":35.11519623,"lon":-106.55680847,"alt":1621.942,"hd":161.18,"spd":0.00,"h_acc":2.500,"v_a~
0000010979 [app] INFO: cloud sent: {"cmd":"loc","time":1627164050,"loc":{"lck":1,"time":1627164051,"lat":35.11519623,"lon":-106.55680847,"alt":1621.942,"hd":161.18,"spd":0.00,"h_acc~
0000010981 [app] INFO: extendExecutionFromNow
0000010982 [app] TRACE: extending execution
0000010983 [app] INFO: Alive
0000010984 [app] TRACE: published and transitioning to EXECUTE
0000011377 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000011379 [comm.protocol] TRACE: message id 84 complete with code 0.00
0000011379 [comm.protocol] TRACE: rcv'd message type=13
0000011683 [comm.protocol] TRACE: rcv'd message type=2
0000011684 [app] INFO: cloud received: {"cmd":"ack","req_id":1,"src_cmd":"loc","status":0}
0000011685 [app] INFO: location cb publish 10 success!
0000011880 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000011882 [comm.protocol] TRACE: message id 85 complete with code 0.00
0000011882 [comm.protocol] TRACE: rcv'd message type=13
0000012984 [app] INFO: Alive
0000014985 [app] INFO: Alive
0000015984 [app] INFO: extendExecutionFromNow
0000015984 [app] TRACE: extending execution
0000016986 [app] INFO: Alive
0000018987 [app] INFO: Alive
0000020986 [app] INFO: extendExecutionFromNow
0000020986 [app] TRACE: extending execution
0000020988 [app] INFO: Alive
0000022989 [app] INFO: Alive

It just continues on printing and never sleeps. I guess the sleep is not enabled.

Second is the motion detection. I enabled it on the Tracker Fleet Config, but when I saw the JSON

0000002759 [net.pppncp] TRACE: State changed event: 1
0000002784 [app] INFO: loading config temp_trig: {"version":1,"hash":"5E7EBC8151C42627DEBDB6A5FFA70B76","temp_trig":{"high":25,"high_en":false,"high_latch":true,"low":25,"low_en":fa~
0000002841 [app] INFO: loading config location: {"version":1,"hash":"86CA9730BC7D499F063BA22E2EC66B24","location":{"radius":0,"interval_min":900,"interval_max":3600,"min_publish":fa~
0000002848 [app] INFO: loading config imu_trig: {"version":1,"hash":"5E5488D40858A17D5C214BA3319647FD","imu_trig":{"motion":"disable","high_g":"disable"}}
0000002865 [app] INFO: loading config rgb: {"version":1,"hash":"2B1CD6509BBD4801D3AF1DE32E1A9D23","rgb":{"type":"particle","direct":{"brightness":255,"red":0,"green":0,"blue":255}}}

Highly appreciate any help.

Thanks!

Hi,

I was able to make it work. There is another identical page for the device regarding settings. That’s the one I used instead of the Asset Tracker Fleet settings.

Thanks!