Skip to main content
Version: FILS English

Smart Package Monitoring System

A device used for real-time monitoring of environmental and physical conditions of packages during transit.

info

Author: Tomikhin Dmytro
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-tomikhin

Description

The project aims to create a "black box" for shipping. It monitors mechanical shocks, orientation changes, temperature, humidity, and light exposure. Data is processed in real-time, displayed on an OLED screen, and logged to a microSD card to identify potentially harmful events during transportation.

Motivation

The motivation for this project comes from a blend of personal curiosity and practical necessity. Having a spare Arduino Sensor Kit at home, I wanted to move beyond basic tutorials and apply these sensors to a meaningful, real-world scenario. In today’s global economy, we often ship high-value or fragile items without knowing how they are handled once they leave our hands. I believe that package condition monitoring is crucial for ensuring accountability in logistics. Interestingly, part of the inspiration came from the game Death Stranding, where the core mechanic revolves around the careful delivery of cargo and monitoring its integrity. This project is my attempt to bring that "cargo monitor" concept to life using embedded programming.

Architecture

Main layers:

  • Sensor Polling Tasks: Independent asynchronous tasks for ADC (Light), I2C (Weather & IMU), and SPI (SD Card).
  • Data Aggregator (Central Logic): Consolidates raw sensor data into a unified system state.
  • Display Manager: A dedicated task for updating the OLED UI via an Embassy Channel.
  • Logging Service: A task that monitors the data stream for critical events and writes them to the microSD card.

Architecture Diagram

Log

Week 2 - 4: Conceptualization and Project Design

  • Defined the core idea of the "Smart Package Monitoring System" and drafted the system requirements, inspired by the cargo monitoring mechanics in Death Stranding.
  • Researched environmental factors critical for logistics (shocks, humidity, light exposure).

Week 5 - 7: Market Research and Component Procurement

  • Identified and sourced compatible sensors (AHT20 + BMP280, BMI160) and the OLED display along with the MicroSD module.
  • Verified compatibility between the Arduino Sensor Kit components and the 3.3V logic of the STM32 board.

Week 8 - 9: Initial Hardware Integration and Sensor Calibration

  • Successfully set up the development environment using probe-rs and defmt.
  • Assembly and Soldering: Performed precision soldering of the AHT20+BMP280 sensor module and the OLED display headers. Using a dedicated soldering station allowed for clean, high-quality joints, ensuring signal integrity on the I2C buses and mechanical durability for the "black box" prototype.
  • Light Sensing: Integrated the KY-018 photoresistor via ADC. Resolved a hardware issue where the initial pinout caused a power dip, successfully re-calibrating the analog values for dark/light transitions.
  • Weather Monitoring: Implemented I2C communication for the AHT20+BMP280 sensor.
  • Architecture Milestone: Developed a dual-bus I2C architecture. Isolated the OLED display on I2C1 and the sensors on I2C2 to ensure high-speed display updates without interference from sensor polling tasks.
  • Software Foundation: Implemented asynchronous tasks using Embassy, allowing the system to poll light and weather data concurrently while updating the UI.

Week 10: IMU Integration and I2C Bus Optimization

  • Hardware Expansion: Integrated the BMI160 (6-axis Accelerometer and Gyroscope) into the sensor cluster.
  • Bus Configuration: Connected the BMI160 to the existing I2C2 bus alongside the AHT20+BMP280 module. By sharing the SCL and SDA lines, I optimized the pin usage. Verified that both devices operate correctly on the shared bus by addressing them via their unique I2C addresses.
  • Functionality: Implemented initial motion tracking to detect orientation changes, laying the groundwork for impact detection logic.

Week 11: SD Card Integration and Power Stability Troubleshooting

  • Assembly: Soldered the headers for the MicroSD card adapter using the soldering station to ensure reliable high-speed SPI communication.
  • Technical Challenge: Encountered system instability during SD card write operations. Heavy peak current consumption by the microSD card caused voltage drops (power sagging), which led to communication errors and "hangs" on the I2C bus shared by the sensors.
  • Hardware Fix: Resolved the instability by soldering two capacitors in parallel between the VCC and GND pins of the SD module:
    • A 0.1 uF ceramic capacitor to filter out high-frequency noise.
    • A 10 uF electrolytic capacitor to act as a local energy reservoir for peak current demands.
  • Enclosure & Final Assembly: To simulate a real-world "black box," I mounted the entire system into a protective enclosure. I precision-cut a dedicated opening in the case to allow the USB Type-C cable to connect directly to the ST-LINK port on the Nucleo board. This provides both stable power and a debugging interface while keeping the internal electronics secure.
  • Result: After implementing the decoupling capacitors, the I2C bus remained stable during simultaneous data logging and sensor polling, ensuring the reliability of the "black box" recording.

Week 11 progress

Smart Package Monitoring System

Hardware

Components:

  • MCU: STM32 Nucleo-U545RE-Q.
  • Sensors:
    • KY-018 Photoresistor (Analog/ADC).
    • AHT20 + BMP280 (Temperature, Humidity, Pressure - I2C).
    • BMI160 (3-axis Accelerometer & 3-axis Gyroscope - I2C/SPI).
  • Display: 0.96-inch OLED SSD1306 (I2C).
  • Storage: MicroSD Card Adapter (SPI) + 16GB MicroSD Card.
  • Power Stability:
    • 0.1 uF Ceramic Capacitor (High-frequency noise filtering).
    • 10 uF Electrolytic Capacitor (Power reservoir for SD card peak loads).

The hardware architecture of the Smart Package Monitoring System utilizes an STM32 Nucleo-U545RE-Q microcontroller as its high-performance processing core, managing concurrent data streams through a multi-bus configuration. Environmental sensing is handled by an AHT20+BMP280 module for climate tracking and a BMI160 inertial measurement unit for motion detection, both interfaced via a shared I2C2 sensor bus. Light exposure is monitored in real-time through a KY-018 photoresistor via ADC. The system features a dedicated I2C1 bus for the SSD1306 OLED display to ensure smooth status visualization and prevent data contention. Reliable event logging is facilitated through a MicroSD adapter interfaced via SPI. To ensure system stability during high-current SD card write operations, a decoupling pair of capacitors (0.1 uF and 10 uF) was integrated into the power rail to mitigate voltage sags and filter electrical noise.

*The system architecture is designed to be modular. Thanks to the asynchronous nature of the Embassy executor, new components/functions might be integrated in future sprints with minimal changes to the core logic.

Schematics

KiCad schematic

Bill of Materials

DeviceUsagePrice
STM32 Nucleo-U545RE-QThe microcontrollerBorrowed
AHT20 + BMP280Weather monitoring (temperature, humidity, pressure)~11 RON
BMI160 IMUShock and orientation detection (Accelerometer & Gyroscope)~11 RON
KY-018 PhotoresistorDetecting light exposureAlready owned
0.96 "OLED SSD1306Real-time local status visualization~16 RON
MicroSD AdapterInterface for data logging to SD card~24 RON
16GB MicroSD CardNon-volatile storage for trip logsAlready owned
Breadboard (400 points)PrototypingAlready owned
Ceramic Capacitor (0.1 uF)High-frequency noise filtering for SD module.Already owned
Electrolytic Capacitor (10 uF)Power reservoir for SD card peak current demands.Already owned
Jumper Wires Set (Male-Male, Male-Female, U-Shape Preformed)WiringAlready owned

Software

LibraryDescriptionUsage
embassy-stm32Hardware Abstraction Layer (HAL) for STM32Used for low-level peripheral control: GPIO, ADC, I2C, SPI, and DMA configuration
embassy-executorAn async/await executor for embedded systemsManages concurrent tasks without a traditional RTOS
embassy-timeTimekeeping and delay providerHandles precise delays for sensor initialization and task intervals
embassy-syncSynchronization primitives for async tasksUsed for inter-task communication via Channels (sending sensor data to the display)
ssd1306Driver for the SSD1306 OLED displayHandles I2C communication and buffer management for the 0.96" OLED screen
embedded-graphics2D graphics library for embedded systemsUsed for drawing text and UI elements on the OLED display
aht20-driverDriver for the AHT20 humidity and temperature sensorManages the initialization and data reading from the AHT20 sensor via I2C
defmtEfficient deferred logging frameworkProvides real-time debugging information and sensor readings via RTT
embassy-futuresFuture UtilitiesProvides tools to handle multiple asynchronous events simultaneously
defmt-rttRTT TransportProvides the physical transport layer for logs, allowing them to be viewed on the PC
cortex-mProcessor Core SupportProvides low-level access to the ARM Cortex-M33 core
cortex-m-rtStartup RuntimeHandles the reset handler and memory initialization (stack, heap) before calling main
panic-probePanic HandlerCatches code errors (panics) and prints the file and line number to the terminal for debugging
static_cellStatic Allocation UtilitySafely allocates static memory for task arguments and long-lived drivers at runtime
  1. Rust Embedded Book
  2. Embassy Framework
  3. STM32U545 Datasheet
  4. Arduino | 37 in 1 Sensors Kit Explained
  5. AHT20+BMP280 Guide
  6. BMI160 Explained
  7. The Rusty Bits
  8. Embedded Rust course