AmbientRx
A medication storage box that watches its own temperature, humidity, light and pill count, corrects the climate with a fan and humidifier, and tells a caregiver when something drifts out of range.
Overview
Many medications are sensitive to heat, humidity and light, yet they live in bathroom cabinets and on kitchen counters where conditions swing all day. Someone caring for an elderly parent has no way to know whether those conditions are safe, or whether a refill is due before the bottle runs out.
AmbientRx turns a passive box into an active one. It samples the enclosure, compares every reading against medication-specific limits, drives a fan or an ultrasonic humidifier to pull conditions back, counts pills with a camera, and publishes everything over MQTT to a dashboard a caregiver can open from anywhere. The dashboard can also send commands back: run the fan, or push a firmware update over the air.
| MCU | Silicon Labs SiWG917Y121MGABA module: ARM Cortex-M4 at 180 MHz, 2.4 GHz Wi-Fi 6 and BLE, SiT1533 32.768 kHz clock |
|---|---|
| Board | 80.5 × 45.5 mm, 4 layers (signal / GND / power / signal), 0.62 mm finished thickness, designed in Altium Designer 26 |
| Assembly | 87 SMT parts across 50 BOM lines, all on the top side; 302 drilled holes, smallest via 0.2 mm |
| Sensing | Sensirion SHT41 temperature and humidity and Vishay VEML7700 ambient light on a shared I2C bus |
| Vision | ArduCam OV2640 (ArduCAM-M-2MP) on a second SiWx917 node, HSV blob detection for pill counting |
| Actuation | 5 V PWM fan and piezo humidifier, switched by AO3400A low-side N-MOSFETs |
| Power | USB-C input, single-cell Li-ion on a JST PH connector, TI BQ24075 power-path charger, TPS62082 3.3 V buck, TPS63802 5 V buck-boost |
| Storage and I/O | microSD in SPI mode with ECLAMP2410 ESD protection, Mini Simplicity and 10-pin Cortex debug headers, reset, ISP and user buttons, status LEDs |
| Firmware | FreeRTOS via CMSIS-RTOS2 on the WiseConnect SDK, queues, semaphores and event groups |
| Cloud | Mosquitto and Node-RED Dashboard 2.0 on an Azure VM, OTA images from Azure blob storage |
Architecture
Two boards and a cloud broker. The camera got its own node after it tried to pull the 3.3 V sensor bus up to 5 V (bug #03).
Original design-review diagram
Hardware design
One Li-ion cell, two regulated rails, a Wi-Fi MCU module, two sensors on a shared bus, switched actuators, storage and debug, all on one 4-layer board.
Input and protection. USB-C (GCT USB4110) with 5.1 kΩ CC pull-downs, a TDK ferrite bead on VBUS and an ST USBUF02W6 RC filter on D+ and D−, wired to the USB 1.1/2.0 recommendation.
Charging and power path. The TI BQ24075 charges the cell from USB and switches the system to battery with no dropout; hot-unplugging USB never reset the MCU. Strapping jumpers set the USB input limit to 500 mA, ILIM to 1.42 A (1610 / 1.13 kΩ) and fast-charge current to 0.788 A (890 / 1.13 kΩ).
Regulation. A TPS62082 buck with a 0.47 µH Murata inductor makes 3.3 V for the MCU and sensors. A TPS63802 buck-boost with a 1 µH Würth inductor makes 5 V for the fan, humidifier and camera, so 5 V holds across the full battery voltage range. Jumpers on the input, 3.3 V and 5 V rails let each one be isolated during bring-up, and test points sit on the key power and USB nets.
MCU. The SiWG917Y module carries the Cortex-M4 and radio. Each supply domain (VBATT, IOVDD, SDIO and ULP I/O) gets its own decoupling, and a SiTime SiT1533 provides the 32.768 kHz clock. The ground plane is cut back under the module's antenna.
Sensors. SHT41 and VEML7700 share one I2C bus and one set of pull-ups.
Actuators. Three AO3400A N-MOSFETs switch the 5 V loads low-side. The first fan driver was high-side and could not fully enhance the MOSFET, so we reworked it to the low-side topology, which gave clean PWM.
Storage, debug and I/O. A Würth push-push microSD socket runs in SPI mode, with a Semtech ECLAMP2410 in series for ESD protection and pull-ups, plus a card-detect line. A Samtec Mini Simplicity header carries SWD, the virtual COM UART and packet trace, and a 10-pin Cortex header supports a Segger J-Link. Reset, ISP, user and interrupt buttons and two green and two red LEDs round it out.
Schematics
Eight hierarchical sheets from the release package. Click any sheet to read it full size.
PCB layout
Rendered directly from the release Gerbers, all four copper layers viewed from the top.
Stackup · 0.62 mm total
L1, top signal. Every component sits here, 87 placements in all. The SiWG917 module is in the center, the power section is packed into the lower left, the microSD socket is on the right, and the debug headers sit at the top left.
L2, ground. A solid reference plane under the whole top layer, with a cut-out under the module's antenna.
L3, power. Split pours that carry the 3.3 V, 5 V and battery-side rails to their loads.
L4, bottom signal. Escape routing and longer runs, with a ground pour around the module area.
Drill. 302 holes. 178 are 0.2 mm vias, and the largest is a 1.6 mm plated hole; there are also three non-plated holes and one slot.
Copper layers rendered from the Gerbers
Copper layers in Altium
Fabrication and assembly drawings
Built board and Altium renders
Power and thermal testing
5 V rail under load
Thermal camera under the same load steps
The thermal camera spot reading moved from 21.4 °C at 10% load to 21.8 °C at 120%.
Firmware
FreeRTOS through CMSIS-RTOS2 on the WiseConnect SDK. Tasks talk only through queues, semaphores and event groups, with no shared globals.
sensor_task
Periodic non-blocking I2C reads of the SHT41 and VEML7700. Compares every sample to medication limits and raises fan, humidifier or light events.
control_task
Owns the fan PWM and humidifier line. Acts within 5 s of a breach and within 1 s of a dashboard command, without blocking sensing.
mqtt_task
Publishes telemetry and alerts, subscribes to ambrx/cooling/control. Waits on a Wi-Fi-up event group so it never races the network join.
ota_handler
Dispatched by the MQTT task within 1 s of the dashboard's OTA command. Fetches the image over HTTP, flashes it and reboots into it.
camera_task
On the camera node. Triggers on a 60 s schedule or a removal event and pushes the pill count to the publisher through a queue.
Pill counting on a Cortex-M4
The spec asked for on-device ML. The SiWx917 was already saturated by JPEG decode, colour conversion and labelling at QQVGA, so we used classical HSV blob detection instead. It finishes inside the 2 s budget, but accuracy depends on pill colour and lighting. That limit is the main reason Rev 2 changes the architecture rather than tuning the algorithm.
Cloud
Telemetry goes over MQTT to a Mosquitto broker on an Azure VM. Node-RED with Dashboard 2.0 turns it into a caregiver view of live temperature, humidity, light and pill count, plus refill and out-of-range alerts.
Control flows the other way. Dashboard toggles publish to the device to run the fan or humidifier, and an OTA button tells the board to pull a new image from Azure blob storage, flash it and reboot, so a deployed box can be patched without anyone touching it.
Bring-up log
Each subsystem worked alone long before the whole system did. Most of the time went into the seams, and into proving the datasheet wrong.
From the bench
Validation
Every hardware and software requirement, scored against what the prototype actually did and how it was tested.
| ID | Requirement | Status | How it was tested |
|---|
The two unmet items share one cause: the BQ24075 charge-status pins went to LEDs instead of MCU GPIOs. One Rev 2 routing change fixes both.
Enclosure
Modelled in CAD to hold the PCBA, camera node, fan and humidifier reservoir, with USB-C access and a window for the status LEDs.
What Rev 2 changes
Move vision off the MCU
Stream compressed frames to an edge service, or move to an SoC with an NPU.
Level-shifted I2C bridge
Bring the camera back onto the main board without dragging the sensor bus to 5 V.
Charge status to GPIO
Route CHG and PG to interrupt pins, closing HRS-17 and SRS-17.
TLS client certificates
Replace username and password MQTT auth.
Local logging
microSD buffering so a Wi-Fi outage loses no data.
Board-support shim
Freeze the SDK on day one and keep application code off SDK-specific symbols.
Plan for bring-up
Test points on every rail, gate and I2C segment, and populate two boards from the first run.