ChebbiOS

System Design: IoT

Designing a robust, battery-powered connectivity subsystem.

The Prompt

"Design a subsystem for a battery-powered device to upload sensor data to the cloud."

1. Constraints & Trade-offs

  • Power is finite: The radio (Wifi/LTE/BLE) is the single biggest consumer of energy. You cannot keep it on.
  • Flash has limits: NAND flash wears out after 100k write cycles. You must be careful about how you write data.
  • Connectivity is spotty: Device might be offline for days. You need to buffer data locally.

2. Architecture Decisions

Power Management

Solution: Batching. Wake up, read sensor, write to Flash, go back to Sleep. Only turn on the Radio once every hour (or when buffer is full) to upload everything at once.

Data Storage

Solution: Circular Buffer (Ring Buffer).

[ Head (Write) --> ............ <-- Tail (Read/Upload) ]

This ensures we process data FIFO. To prevent flash wear leveling issues, we rely on the specific Flash Translation Layer (FTL) of the chip or implement a wear-leveling algorithm if using raw flash.

Reliability (OTA Updates)

What happens if the battery dies in the middle of a firmware update? The device becomes a brick.

Solution: A/B Partitioning (Dual Bank).

Partition A
(Active Running)
Partition B
(Downloading New Update...)

We download to B. Verify the checksum. Only then do we swap the boot pointer. If boot fails, the Watchdog Timer (WDT) resets us back to Partition A.

Connect & Discuss

Have questions about systems engineering, or found a bug in the code? Reach out!

Feedback

This blog is a static site, but I'd love to hear your thoughts. You can discuss this post by sending me an email or reaching out on social media.

Send Feedback