Build an energy budget before changing code
Battery life cannot be inferred from battery capacity alone. List every operating state: deep sleep, sensor sampling, GPS acquisition, LoRa transmit, receive window, BLE advertising, Wi-Fi maintenance, SD write, LED indication, and error retry. Estimate current and duration for each state, then calculate daily energy use.
Measure on the real board because regulators, displays, pull-ups, SD cards, and debug interfaces add current that firmware estimates miss. Record battery voltage and current at representative states. A device that draws little during sleep can still discharge quickly if GPS repeatedly waits for a fix or Wi-Fi remains enabled.
Use a conditional GPS policy
GPS is often one of the largest energy users. Define when a fresh fix is required, how long acquisition is allowed, and when a recent cached location is acceptable. In difficult indoor or obstructed locations, an endless search wastes energy without improving the packet.
Log time to first fix, satellite count, HDOP or accuracy estimate, and whether the transmitted location is fresh or cached. This lets the server and technician interpret the data correctly. Consider longer location intervals when stationary and shorter intervals after detected movement.
Keep the LoRa packet compact and versioned
A field packet should include a protocol version, device ID, sequence number, timestamp or age, location fields, battery measurement, status flags, and integrity information appropriate to the chosen protocol. Use scaled integers where practical and document byte order. A version field allows the decoder to evolve without guessing.
Distinguish LoRaWAN from a custom mesh. LoRaWAN provides a standardized network and security model, while a mesh requires explicit routing, retry, duplicate suppression, and path logging. Whichever is used, preserve sequence numbers and receive metadata so missed or duplicated messages can be diagnosed.
Control retries instead of repeating forever
Retries improve delivery only up to a point. Define maximum attempts, spacing, backoff, and what data is retained for the next opportunity. Continuous retries during poor coverage consume energy and may worsen channel use. A device should eventually return to a low-power state and record that delivery was not confirmed.
Use acknowledgements selectively. Critical deployment or configuration events may justify confirmation; routine periodic telemetry may not. In a mesh, log hop count, selected next hop, RSSI, retry count, and failure reason so route behavior can be evaluated rather than described only as “reachable” or “not reachable.”
Keep BLE and Wi-Fi under deliberate user control
BLE can provide local status and configuration with less energy than leaving Wi-Fi active. Wi-Fi should be enabled only for a defined operation, such as a double-click maintenance mode, and should time out automatically. Indicate the mode clearly so a technician knows why current consumption changed.
Protect configuration changes. Validate ranges, save atomically, and include a configuration version in logs. A factory reset should not silently erase identity or security data unless that behavior is explicitly intended and documented.
Use local logging as field evidence
SD or flash logs can preserve events when radio delivery fails. Log at a controlled interval and include boot reason, firmware version, battery, GPS result, packet sequence, transmit result, route or gateway metadata, and configuration changes. Use file rotation and recovery-friendly writes so an interrupted write does not corrupt the full history.
Local storage is not free: powering and writing an SD card can consume significant energy. Buffer records and write in batches where the risk is acceptable. If the card is missing or full, the device should continue its primary task and expose the storage fault in telemetry.
Validate the battery measurement and shutdown behavior
Confirm the resistor divider, ADC reference, calibration, and load conditions used to translate ADC counts into voltage. Battery voltage under radio transmit may dip compared with an idle reading. Report both raw and calibrated values during development so incorrect scaling is visible.
Run discharge tests that include the intended reporting cycle, not a continuous stress mode unless that is the objective. Record start voltage, time, packet count, resets, and final behavior. Define a safe low-voltage policy that preserves data and prevents unstable reboot loops.