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.

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.

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 precise climate tracking and a KY-018 photoresistor for real-time light exposure detection via ADC. The system features a dedicated I2C1 bus for the SSD1306 OLED display to ensure smooth status visualization, and an independent I2C2 bus for the sensor cluster to prevent data contention. Reliable event logging is facilitated through a MicroSD adapter interfaced via SPI, providing non-volatile storage for comprehensive trip analysis.

*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

To be added soon.

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