All posts
AIIoTOpenCVRaspberry PiFlask

Care Companion: Designing an AI + IoT Healthcare Rover

9 min readUpdated
A conceptual rover connects vision, processing, sensing and control with a caregiver dashboard.
Conceptual illustration of an AI and IoT rover system. The hardware layout and dashboard are illustrative, not photographs or exact specifications of our prototype.
In this article · 12 sections

A rover that displays a camera feed, sensor readings and a caregiver dashboard looks like one system. In practice, those functions operate on different clocks. A camera produces frames, a sensor can fail halfway through a read, a network request can block, and a motor command must stop being valid when its source becomes stale.

Care Companion is my project context for exploring those boundaries. This article is an engineering walkthrough of a prototype, not a clinical validation report. It separates features described in the project from source-level observations and proposed reliability improvements. The goal is to teach how to reason about a small embedded system when components are slow, disconnected or wrong.

Start with the age of information

“Real-time” is not a single property. A display can refresh quickly while showing old data. A detector can process many frames per second while its input queue grows, leaving a controller to react to where someone was several seconds ago.

For each signal, record when it was sampled, when it was received and when it was acted upon. The difference between sampling and action is often more useful than an isolated throughput number. Include the unit, source and a quality indicator so that a plausible numeric value is not mistaken for a trustworthy measurement.

I would define freshness requirements separately for motor commands, camera detections, environmental readings and dashboard history. A historical chart can tolerate delayed delivery. A command that moves hardware should not remain active indefinitely because a network packet was never followed by a stop message.

Distinguish prototype hardware paths

The portfolio describes a Raspberry Pi and Arduino rover arrangement. The inspected repository also contains a Pi-side reader using GPIO and I2C devices directly, together with a Django dashboard, Channels and Celery components. These are not interchangeable wiring descriptions. A deployment needs to name the specific board, sensor, interface and software path actually in use.

That distinction matters when writing documentation. A diagram that combines every component ever tried can imply an integrated configuration that was never tested. I would version the hardware configuration alongside the software and identify which adapters are enabled for a particular prototype.

For the architecture discussion below, the separation is logical: acquisition collects readings, vision produces detections, control decides permitted motion, and the application persists and displays observations. Those boundaries can run on separate boards or processes without changing the questions each stage must answer.

Do not let network delivery own the sampling clock

A loop that reads a sensor and immediately posts the result over HTTP inherits the network request's delay. When the server is slow, the sampling rate changes. If the request has no timeout, the acquisition loop may stop making progress entirely.

Separate acquisition from delivery through a bounded buffer. The producer samples and timestamps; the sender batches or transmits with explicit timeouts and retry limits. Decide what to do when the buffer fills. Dropping an old routine reading can be acceptable for a live display, while an alert may need durable delivery.

For a serial-based adapter, pySerial's API documents read and write timeout behavior. Configure those limits and frame the messages deliberately. “Read until a newline eventually arrives” is not a recovery strategy for a disconnected or partially transmitting device.

A reading needs provenance and quality

A useful reading envelope includes a device identifier, a sequence number, the measurement name, a unit, timestamps and a quality state. Use explicit states such as valid, unavailable, stale and simulated. Do not substitute zero for a failed read: zero is a value that a graph may plot and an alert rule may evaluate.

Device clocks can drift or reset. Keep a server-received timestamp in addition to the device's sampling timestamp, and use a monotonic clock for elapsed-time checks within a process. A timestamp without a defined clock source creates false precision.

Sequence numbers also need a restart strategy. Pair them with a boot or session identifier so that a device returning to sequence zero after reboot does not look like an endless stream of duplicate old readings. This is a small protocol detail with a large effect on recovery.

A source-level limitation worth making visible

The inspected Pi sensor reader includes a pulse calculation explicitly marked as a placeholder. It maps an ADC value into a displayed BPM range rather than deriving heart rate from detected pulse intervals. Its gas conversion also scales a raw ADC value without establishing a sensor-specific calibrated concentration measurement.

Those observations are important because a number with a familiar unit can look authoritative on a dashboard. A placeholder conversion should remain labeled simulated or uncalibrated; it should not silently become evidence of physiological accuracy. The article does not provide clinical thresholds or treat this prototype as a substitute for validated monitoring equipment.

A useful improvement is to persist the quality flag with the value and propagate it through the API and chart. The UI should not be the only place that knows a reading was simulated, because later exports and alert jobs also consume the data.

Keep frame latency bounded

Computer vision creates another producer-consumer problem. If capture runs faster than inference, an unbounded queue accumulates old frames. The detector may remain busy while the control system receives increasingly stale observations.

For a live tracking display, a latest-frame buffer can be preferable to preserving every frame. The following example demonstrates that policy with a thread-safe queue; it is not the deployed rover implementation:

from queue import Queue, Empty, Full

frames = Queue(maxsize=1)

def offer_latest(frame):
    try:
        frames.put_nowait(frame)
        return
    except Full:
        pass
    try:
        frames.get_nowait()
    except Empty:
        pass
    try:
        frames.put_nowait(frame)
    except Full:
        pass  # Another producer won; memory still remains bounded.

offer_latest({"sequence": 1})
offer_latest({"sequence": 2})
assert frames.get_nowait()["sequence"] == 2

This buffer sacrifices completeness to preserve freshness. It is inappropriate for a task that must retain every frame for offline analysis. The Python queue documentation provides the blocking and non-blocking semantics; the application still chooses its data-loss policy.

Benchmark the entire vision path

Capture, resizing, preprocessing, inference, postprocessing, rendering and transmission all contribute to observed delay. Measure them separately, then measure end-to-end age at the point where a detection is used. Include warm-up behavior, image resolution, model variant, thread count and processor temperature.

The MobileNets paper describes efficient convolutional building blocks, while the SSD paper describes a single-stage detection approach. Neither establishes the frame rate of an unspecified model on this project's Raspberry Pi configuration.

The old blog stated approximately 60 FPS without a reproducible benchmark configuration in the material inspected. I have removed that as a measured project result. A more useful report would give sustained throughput, latency percentiles, dropped-frame counts and behavior while sensing and network delivery run concurrently.

Control must reject stale commands

A motor controller should receive a constrained command rather than an unrestricted stream of prose or raw model output. Define allowed directions, limits and a short validity period. A watchdog can stop accepting a command when the controller has not received a fresh authorized update.

Avoid equating a person detection with permission to move. Perception provides an observation with uncertainty; a control policy decides whether movement is permitted. Missing detections, multiple people, occlusion and an outdated frame should all have defined behavior.

For a prototype review, I would ask whether the stop path remains available during inference overload and network loss. A software check in a busy browser is not equivalent to a local control mechanism. The required hardware safeguards depend on the physical setup and must be evaluated as part of that setup.

Alerts and reminders need different delivery semantics

A reminder is a scheduled occurrence, not a side effect of a browser being open. The repository's Celery-based application structure provides a place for background jobs, but adding a queue alone does not guarantee timely or duplicate-free delivery.

Assign each scheduled occurrence a stable identifier. A retried task should find whether that occurrence already completed before repeating an external action. Celery's task documentation discusses idempotence, acknowledgements and I/O timeouts; the exact retry and acknowledgement settings still need to match the operation.

Separate “condition observed,” “notification sent,” “notification received” and “someone acknowledged it.” They represent different events. A server returning HTTP 200 for an alert request does not establish that a caregiver saw it or took action.

Design the dashboard around uncertainty

Show the last update time and quality status alongside the value. Render stale or unavailable data explicitly rather than freezing a green indicator at its last valid state. On reconnect, fetch authoritative recent state instead of assuming that the live stream delivered every observation.

Keep historical storage and live display separate enough to recover after a socket interruption. Protect patient-related data through authenticated APIs and resource-level authorization. Screenshots and demo modes should use synthetic records rather than accidentally exposing real personal information.

The visual design question is therefore not only “does the chart look smooth?” It is “can someone distinguish a current observation from an old, missing or simulated one?” Honest uncertainty is part of the interface contract.

A failure-injection exercise

Run the acquisition and delivery components with synthetic input. Delay the server response, disconnect the network, restart the device and inject an invalid reading. Record whether memory stays bounded, whether sequence identities remain interpretable and whether the dashboard marks stale data.

Then slow the vision worker and verify that the latest-frame policy actually limits observation age. Repeat with a burst of alerts and check that routine telemetry cannot indefinitely delay them. These are proposed tests, not completed reliability measurements for the prototype.

The system becomes easier to improve once each failure has a visible owner: acquisition quality, buffering policy, control validity, delivery recovery or presentation. That is the central lesson of an AI-and-IoT project for me. Integration is the behavior of the boundaries, especially when one side stops cooperating.

Sources and project context

The code example and failure exercises are teaching material. Hardware-specific performance, calibrated sensing accuracy and clinical suitability require their own evidence.