Work

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.

Role
PCB design, bring-up, firmware
Course
ESE 5160, University of Pennsylvania
Recognition
Lutron Best Project Award
01

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.

MCUSilicon Labs SiWG917Y121MGABA module: ARM Cortex-M4 at 180 MHz, 2.4 GHz Wi-Fi 6 and BLE, SiT1533 32.768 kHz clock
Board80.5 × 45.5 mm, 4 layers (signal / GND / power / signal), 0.62 mm finished thickness, designed in Altium Designer 26
Assembly87 SMT parts across 50 BOM lines, all on the top side; 302 drilled holes, smallest via 0.2 mm
SensingSensirion SHT41 temperature and humidity and Vishay VEML7700 ambient light on a shared I2C bus
VisionArduCam OV2640 (ArduCAM-M-2MP) on a second SiWx917 node, HSV blob detection for pill counting
Actuation5 V PWM fan and piezo humidifier, switched by AO3400A low-side N-MOSFETs
PowerUSB-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/OmicroSD in SPI mode with ECLAMP2410 ESD protection, Mini Simplicity and 10-pin Cortex debug headers, reset, ISP and user buttons, status LEDs
FirmwareFreeRTOS via CMSIS-RTOS2 on the WiseConnect SDK, queues, semaphores and event groups
CloudMosquitto and Node-RED Dashboard 2.0 on an Azure VM, OTA images from Azure blob storage
02

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).

MAIN BOARD · custom 4-layer PCB CAMERA NODE AZURE USB-C 5 V Li-ion cell BQ24075power path, charger TPS62082buck · 3.3 V TPS63802buck-boost · 5 V CHG/PG → LEDs SiWx917 Cortex-M4 · Wi-Fi FreeRTOS · CMSIS-RTOS2 sensor · MQTT · control · OTA SHT41temp · RH · 0x44 VEML7700ambient light I2C · 400 kHz · pins 6/7 FanPWM · AO3400A low-side Humidifierpiezo · isolated driver telemetry ↑ · commands ↓ OTA image SiWx917 dev boardTJpgDec · HSV blob count OV2640 + white LEDown I2C segment (5 V pull-ups) Mosquitto brokerVM · MQTT Node-RED Dashboard 2.0caregiver view · controls · OTA button Blob storage · firmware images
Fig. 1 · System block diagram. Blue pulses mark the live data paths: I2C sensing, MQTT telemetry, camera counts and the OTA image.

Original design-review diagram

03

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.

04

Schematics

Eight hierarchical sheets from the release package. Click any sheet to read it full size.

05

PCB layout

Rendered directly from the release Gerbers, all four copper layers viewed from the top.

Stackup · 0.62 mm total

Top solder mask0.01 mm
L1 · Top signal0.04 mm Cu
Prepreg PP-0060.07 mm
L2 · GND plane0.04 mm Cu
FR-4 core0.32 mm
L3 · Power plane0.04 mm Cu
Prepreg PP-0060.07 mm
L4 · Bottom signal0.04 mm Cu
Bottom solder mask0.01 mm

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

06

Power and thermal testing

5 V rail under load

Fig. 2 · The 5 V rail held within 60 mV from 10% to 120% of rated load, inside the 100 mV budget, and stayed graceful at 20% overload.

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%.

07

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

trigger→ LED on→ OV2640 · QQVGA JPEG→ TJpgDec→ RGB → HSV→ threshold→ blob label→ count → queue→ MQTT

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.

08

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.

09

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

10

Validation

Every hardware and software requirement, scored against what the prototype actually did and how it was tested.

IDRequirementStatusHow 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.

12

What Rev 2 changes