← Back to the chapter · Previous detail

Technical detail · Capstone Projects: Selection and Fleet Tracking

Implement adaptive reporting

This firmware sketch uses 60-second reporting while moving, 300 seconds after recent movement, and 3600 seconds when parked. Its continuous moving GPS mode differs from the five-second duty cycle above. The 3000mAh estimate for four moving hours per day is therefore at most about 25 days before other loads; the parked estimate is about 90+ days. Validate each mode with a measured trace.

// Power states for maximum battery life
enum PowerState {
    DEEP_SLEEP,      // GPS off, cellular off, ~10uA
    LIGHT_SLEEP,     // GPS acquiring, cellular off, ~1mA
    ACTIVE_GPS,      // GPS tracking, cellular off, ~30mA
    ACTIVE_TRANSMIT  // GPS + cellular active, ~150mA
};

// Adaptive reporting based on movement
void adaptiveTracking() {
    if (isMoving()) {
        // Vehicle in motion: frequent updates
        reportIntervalSeconds = 60;
        gpsMode = CONTINUOUS;
    } else if (hasMovedRecently(30)) {
        // Recently stopped: medium updates
        reportIntervalSeconds = 300;
        gpsMode = PERIODIC;
    } else {
        // Parked: infrequent updates
        reportIntervalSeconds = 3600;
        gpsMode = ON_DEMAND;
    }
}

// Estimated battery life calculation
// 3000mAh battery
// Moving 4 hours/day: at most ~25 days with 30mA continuous GPS, before other loads
// Parked most of time: ~90+ days

← Back to the chapter · Previous detail