Smart Package Monitoring System
A device used for real-time monitoring of environmental and physical conditions of packages during transit.
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.
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
| Device | Usage | Price |
|---|---|---|
| STM32 Nucleo-U545RE-Q | The microcontroller | Borrowed |
| AHT20 + BMP280 | Weather monitoring (temperature, humidity, pressure) | ~11 RON |
| BMI160 IMU | Shock and orientation detection (Accelerometer & Gyroscope) | ~11 RON |
| KY-018 Photoresistor | Detecting light exposure | Already owned |
| 0.96 "OLED SSD1306 | Real-time local status visualization | ~16 RON |
| MicroSD Adapter | Interface for data logging to SD card | ~24 RON |
| 16GB MicroSD Card | Non-volatile storage for trip logs | Already owned |
| Breadboard (400 points) | Prototyping | Already owned |
| Jumper Wires Set (Male-Male, Male-Female, U-Shape Preformed) | Wiring | Already owned |
Software
| Library | Description | Usage |
|---|---|---|
| embassy-stm32 | Hardware Abstraction Layer (HAL) for STM32 | Used for low-level peripheral control: GPIO, ADC, I2C, SPI, and DMA configuration |
| embassy-executor | An async/await executor for embedded systems | Manages concurrent tasks without a traditional RTOS |
| embassy-time | Timekeeping and delay provider | Handles precise delays for sensor initialization and task intervals |
| embassy-sync | Synchronization primitives for async tasks | Used for inter-task communication via Channels (sending sensor data to the display) |
| ssd1306 | Driver for the SSD1306 OLED display | Handles I2C communication and buffer management for the 0.96" OLED screen |
| embedded-graphics | 2D graphics library for embedded systems | Used for drawing text and UI elements on the OLED display |
| aht20-driver | Driver for the AHT20 humidity and temperature sensor | Manages the initialization and data reading from the AHT20 sensor via I2C |
| defmt | Efficient deferred logging framework | Provides real-time debugging information and sensor readings via RTT |
| embassy-futures | Future Utilities | Provides tools to handle multiple asynchronous events simultaneously |
| defmt-rtt | RTT Transport | Provides the physical transport layer for logs, allowing them to be viewed on the PC |
| cortex-m | Processor Core Support | Provides low-level access to the ARM Cortex-M33 core |
| cortex-m-rt | Startup Runtime | Handles the reset handler and memory initialization (stack, heap) before calling main |
| panic-probe | Panic Handler | Catches code errors (panics) and prints the file and line number to the terminal for debugging |
| static_cell | Static Allocation Utility | Safely allocates static memory for task arguments and long-lived drivers at runtime |