GPS and accelerometer are always zeroes

Using Tracker One and examples from github

I can get battery readings, but location is never transmitted. Also, when I uncomment accelerometer, it’s also always 0,0,0. No matter how I shake the device.

I can see that GPS LED on the device is always OFF. However, it was ON before I switched to developer firmware.

What am I doing wrong and how it can be fixed? Thanks!

I have run into this issue on TrackerOne, it is likely the IMU needs to be woken up. The example below uses the default Tracker Edge firmware, not the Electron based Asset Tracker you linked to. Using Tracker Edge, the main.cpp file provided below should log the acceleration each second.

Note that the motion service class does not provide a public API to the Bosch BMI160 IMU, you have to use the BMI160 class (or modify the motion service).

#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"
#include "motion_service.h"
#include "bmi160.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

PRODUCT_ID(TRACKER_PRODUCT_ID);
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);

STARTUP(
    Tracker::startup();
);

SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
    { "app.gps.nmea", LOG_LEVEL_INFO },
    { "app.gps.ubx",  LOG_LEVEL_INFO },
    { "ncp.at", LOG_LEVEL_INFO },
    { "net.ppp.client", LOG_LEVEL_INFO },
});

Bmi160Accelerometer accel;
system_tick_t last_imu = 0;
static constexpr system_tick_t imu_interval = 1000; // 1hz

void setup() {
    // Initialize tracker
    Tracker::instance().init();
    // Wake up IMU
    Bmi160::getInstance().wakeup();
}


void loop() {
    Tracker::instance().loop();
    
    // Get acceleration every second
    if (System.millis() - last_imu > imu_interval) {       
        int ret_accel = Bmi160::getInstance().getAccelerometer(accel);
        last_imu = System.millis();
        // Bad values, wake up IMU
        if (ret_accel != 0 || accel.x == 0 || accel.y == 0 || accel.z == 0) {
            if (!MotionService::instance().isAnyAwake()) {
                Bmi160::getInstance().wakeup();
            }
            return;
        }
        // Log acceleration
        Serial.printlnf("Acceleration: x = %f, y = %f, z = %f", accel.x, accel.y, accel.z);
    }
}
1 Like