MADPAW is my own side project: a pet tracker collar doing GPS + activity ML plus its iOS app, still in development — it has not gone on sale and there is no production batch. The figures below are not measured product results; they are the hardware + iOS design decisions and design targets.
Problem: A 30+ day battery life target for pet tracker hardware (a collar device). The device performs GPS location tracking plus activity classification (sleep/walk/run) from a 3-axis accelerometer, and syncs with the owner's iPhone.
Design targets: pass a 32-day battery test (lab environment), 95% activity accuracy, and an OTA update flow that needs no manual intervention in the field. The tests have not been run yet — these are targets.
1. Power Budget
The pet tracker uses an 800mAh LiPo battery. The processing that must not drain it within 30 days:
Component | Daily budget | |
|---|---|---|
GPS fix (every 60 min) | 24 fixes × 2s lock | ~3% battery |
Accelerometer (continuous) | 1.5%/day | |
BLE advertise (every 5s) | 2%/day | |
ML inference (every 5min) | 0.4%/day | |
Wi-Fi sync (owner's home, daily) | 1%/day | |
Total | ~8% / day | |
30-day projection | 240% — fail! |
This budget misses the target — optimization is at the centre of the design.
2. Smart Scheduling
The device stays in native sleep and only wakes when motion is detected:
- Accelerometer interrupt (motion threshold) wake-up
- Motion detected → ML inference + GPS fix
- No motion → sleep mode, GPS off
With this pattern the daily budget comes down to 3%/day. On paper 30 days = 90%, which is what the 32-day lab test plan rests on.
3. On-Device ML Pipeline
3-axis accelerometer at 25Hz → 60-sample window → Core ML model.
Model: Create ML Activity Classifier, 4 classes (sleep/walk/run/play). Training plan:
- Target labelled set: ~200 hours (various breeds and sizes)
- Train 80% / val 10% / test 10% split
- Target validation accuracy: the 95% band
- Model size budget: under 20KB (.mlmodelc)
The ESP32-class hardware has no Apple Neural Engine — the Core ML model is converted to TFLite Micro. Inference budget: 8ms / window.
4. iOS App: Owner Side
The iOS app is a low-power BLE listener:
1@MainActor2final class TrackerManager: ObservableObject {3 private var central: CBCentralManager?4 @Published var lastSyncedAt: Date?5 @Published var lastActivity: ActivityClass?6 7 func startListening() {8 central = CBCentralManager(delegate: self, queue: .main, options: [9 CBCentralManagerOptionRestoreIdentifierKey: "MADPAW.tracker"10 ])11 }12}Background BLE scan runs only when the phone is home (geofence) — for battery savings.
Map UI: GPS history for the last 24 hours, activity heatmap.
5. Cloud Sync
The iOS app acts as a proxy:
- BLE \<-\> Firebase Realtime DB
- Activity events: tracker → BLE → iOS → Firebase
- Owner can share with multiple family members (Firestore family-id collection)
Daily volume per device: ~3MB. Assuming a fleet of 10K+ devices that is on the order of ~36GB/month — above the Firebase free tier, but a cheap band.
6. Hardware Pin-out & Firmware
- ESP32 (S3, ARM Cortex M4)
- u-blox NEO-M9N GPS module
- ADXL355 accelerometer
- Power management IC (TI BQ24295)
- BLE-only (no Wi-Fi during travel — power)
Firmware in C (Arduino IDE → migrating to ESP-IDF in v2):
- FreeRTOS task layout
- 4KB ML model embedded
- OTA via BLE (iOS app uploads firmware)
7. Manufacturing & Production
Manufacturing is still at the planning stage; the targets:
- First-batch target: a fleet on the order of 10K+ devices
- Sourcing: an ODM in the Shenzhen band
- Budget for 4 hardware revisions across 18 months
- App Store approval is relatively smooth for this device class (no NFC, no health regulatory)
- Returns target: stay below the industry band (3-5%)
8. Lessons Learned
1. The battery target must be committed to upfront. "Optimize it later" does not work in this device class — the power profile has to be a day-0 target.
2. Scheduled work instead of an always-on listener saves battery in the 95% band at this budget. Motion-triggered wake-up is best practice for DIY hardware.
3. ML model size matters. An 18KB model runs comfortably via TFLite Micro; a 100KB+ model does not fit on this hardware.
4. BLE-only design. Wi-Fi burns too much power while roaming; reserve it for the home dock and syncing.
5. iOS background BLE requires CBCentralManagerOptionRestoreIdentifierKey — without restoration, sync drops while the owner is away from home.
6. Plan the activity training data up front. A first set of a few dozen hours will not reach the 95% band in this class; don't commit to an accuracy target before the labelled set is planned at ~200 hours.
7. In this category App Store reviews are driven by the battery claim. Saying "one charge per 30 days" demands proof: lab data plus measurements from a sizeable beta group have to back the App Store description. An unproven battery claim lands straight in the rating.
Result: IoT hardware + iOS app is a combined problem. Battery optimization, on-device ML, and the BLE state machine are each work measured in months on their own. Combined, plan for 6-8 months of R&D; projects that don't set that budget aside up front miss the battery target.
Tags
iOS Development News
Weekly Swift tips, SwiftUI tricks and iOS best practices. No spam, only valuable content.
Your subscription starts when you open the link in the confirmation email and press “Confirm my subscription”. The newsletter keeps open/click statistics; you can unsubscribe anytime with one click. Privacy
