VitalPi
Meet Your Personal Health Guardian - Real-time Vital Monitoring at Your Fingertips
Author: Bachynskyi Roi
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-frihetselsker
Description
It is a stationary health station featuring body temperature, ECG, and air quality sensors allowing evaluate your wellness from home. The system provides immediate notifications and results on site, while transmitting health data wirelessly to the server for remote monitoring and better view.
Motivation
I chose VitalPi to democratize healthcare monitoring, making vital health data accessible to everyone regardless of location or resources. This solution brings decent health monitoring into homes and underserved communities potentially improving health outcomes for those with limited access to regular medical care.
Architecture
Schematics
This diagram reflects the concept of connections of every part in this project.
Raspberry Pi Pico 2W
Role: Central controller for the entire health station system
Connections: GPIO pins for all sensors, display, LED, and buzzer
Function: Collects data from sensors, processes readings, manages notifications, and sends data to server
Touchscreen Display
Interface: SPI
Role: User interface for health monitoring station
Connections: GPIO10 - 13, GPIO16 - 22
Function: Displays real-time health metrics, allows user interaction with the system
Temperature Sensor
Interface: I2C
Role: Monitors body or ambient temperature
Connections: GPIO14 and GPIO15
Function: Provides temperature readings for health assessment
Air Quality Sensor
Interface: ADC
Role: Detects air pollutants, VOCs, or specific gases
Connections: GPIO27(ADC1)
Function: Monitors environmental air quality that could affect health
ECG Sensor
Interface: ADC
Role: Captures electrical signals from the heart
Connections: GPIO26(ADC0)
Function: Records cardiac activity for heart health monitoring
BPE-SpO2 Sensor:
Interface: I2C
Role: Measures blood oxygen saturation and pulse rate
Connections: GPIO8 and GPIO9
Function: Monitors oxygen levels in blood and heart rate, critical vital signs for overall health assessment
RGB LED
Interface: PWM
Role: Visual notification system
Connections: GPIO2, GPIO3, and GPIO4 with current-limiting resistors
Function: Color-coded alerts based on sensor readings
Passive Buzzer
Interface: PWM
Role: Audible notification system
Connections: GPIO28
Function: Sounds alerts
Web Application
Interface: Wi-Fi
Role: Data visualization and remote monitoring interface
Features: Displays historical data trends, allows data export for medical professionals
Function: Provides accessible interface for viewing health data
Log
Week 5 - 11 May
I imported all my work-in-progress materials to the project's repository where every component was tested except MAX30102, which I was trying to replace that time. I made all the connections with respect to the uploaded KiCAD schematics.
Week 12 - 18 May
My goal was to unify all the code that I had had before and make one program with several tasks from it. What is more, I have started to work on the UI of the project. The biggest issue I faced was handling the signal from BPE sensor which was too difficult to set up.
Week 19 - 25 May
During the final week, I managed to connect every single component to the holistic system, wrapped it into a convenient box. I faced some problems with Wi-Fi and PubSubChannels, but now it works and can be used by a user.
Hardware
VitalPi utilizes a Raspberry Pi Pico 2W microcontroller as its processing core and webbite communicator, paired with a TFT LCD touchscreen (240×320px) for user interaction. Health monitoring is provided through an AD8232 ECG sensor module for cardiac activity, an MLX90614ESF infrared temperature sensor for contactless temperature readings, and a GY-MAX30102 optical heart rate and blood oxygen sensor. Environmental monitoring comes from an MQ135 gas sensor configured with a 10kΩ/20kΩ resistor voltage divider. User notifications are delivered via an RGB LED (with 220Ω current-limiting resistors) for visual alerts and a passive buzzer for audible warnings.
Schematics
This is the KiCad Schematics of the project.
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2W | The microcontroller that processes all sensor data and manages wireless connectivity | 35 RON |
2.4" TFT LCD Touchscreen (240×320px) | User interface display for viewing health data and interacting with the system | 54 RON |
MLX90614ESF Infrared Temperature Sensor | Non-contact temperature measurement for body and ambient temperature monitoring | 60 RON |
AD8232 ECG Sensor Module | Single-lead electrocardiogram sensor for heart activity monitoring and analysis | 35 RON |
MQ135 Gas Sensor | Air quality detection for monitoring harmful gases and environmental conditions | 16 RON |
Breakout heart rate sensor GY-MAX30102 | Pulse oximetry sensor for monitoring blood oxygen levels and heart rate | 14 RON |
Passive Buzzer Module | Audio notification system for alerts and warnings | 2 RON |
RGB LED Common Cathode | Visual status indicator showing system and health conditions through color coding | 1 RON |
3 x 220Ω Resistors | Current-limiting components for the RGB LED | 0,30 RON |
1 kΩ Resistor | Component of voltage divider for MQ135 gas sensor | 0,10 RON |
2 kΩ Resistor | Component of voltage divider for MQ135 gas sensor | 0,10 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-rp | Embassy support for Raspberry Pi RP2350 | Runs async embedded tasks on Raspberry Pi Pico 2W |
embassy-embedded-hal | Async implementation of embedded-hal traits | Interfaces with async-compatible embedded peripherals |
embassy-sync | Synchronization primitives for async embedded Rust | Used for mutexes, signals, and channels in concurrent tasks |
embassy-executor | Async task executor for bare-metal embedded systems | Manages scheduling and running async tasks on the device |
embassy-futures | Lightweight async utilities for embedded systems | Provides futures and combinators used in async workflows |
embassy-time | Timekeeping and delays for embedded systems | Used for timers, delays, and task timeouts |
embassy-net | Async TCP/IP networking stack | Handles communication between device and remote server |
embassy-net-wiznet | Wiznet W5500 Ethernet driver for Embassy | Provides Ethernet connectivity support |
cyw43 | Driver for the CYW43 Wi-Fi chip | Provides Wi-Fi connectivity to the Raspberry Pi Pico 2W |
cyw43-pio | PIO-based CYW43 driver implementation | Allows communication with CYW43 via the Pico's PIO |
defmt | Logging framework optimized for embedded devices | Used for low-overhead logging during debugging |
defmt-rtt | Backend for defmt using RTT (Real-Time Transfer) | Enables real-time logging over debug probe |
cortex-m-rt | Runtime for Cortex-M microcontrollers | Sets up interrupt vectors and program entry point |
panic-probe | Panic handler for defmt-enabled embedded apps | Captures and displays panics for debugging |
embedded-hal-async | Asynchronous embedded-hal traits | Defines async traits for interacting with hardware |
display-interface-spi | SPI interface for display drivers | Provides abstraction for SPI-based display communication |
ili9341 | Driver for ILI9341 LCD display controller | Enables graphics output to ILI9341-based displays |
heapless | Data structures that don't require dynamic memory | Used for buffers and queues with guaranteed memory use |
xpt2046 | Touchscreen driver for XPT2046 | Reads user input from resistive touchscreen displays |
micromath | Lightweight math library for microcontrollers | Used for computations like ECG signal processing |
mlx9061x | Driver for MLX90614 temperature sensor | Used for contactless infrared temperature measurement |
embedded-graphics | 2D graphics library | Used for drawing to the display |
static_cell | Statically allocated, initialized at runtime cell | Provides safe static storage for async resources |
embedded-io-async | Async I/O traits for embedded systems | Enables async I/O operations for networking and communication |
Software Design
Architecture Overview
The software follows an async task-based architecture using the Embassy framework. The application is structured around independent async tasks that communicate through publish-subscribe channels and simple channels, enabling real-time sensor monitoring while maintaining responsive user interaction.
Core Components
Task Architecture
The system implements eight primary async tasks, each responsible for specific functionality:
main
- System initialization and task spawningwifi_task
- Network communication and cloud data transmissiondisplay_task
- User interface state machine and touchscreen handlingled_task
- Visual feedback system with color-coded health indicatorsbuzzer_task
- Audio notification system for alerts and confirmationstemp_task
- Temperature sensor monitoring via I²Cadc_task
- ECG measurement using AD8232 sensor and Air Quality measurement using MQ135 sensorbpm_task
- BPM and Saturation measurement using MAX30102 via I²C
Communication System
Inter-task communication is handled through Embassy's publish-subscribe channels. This decoupled architecture allows tasks to operate independently while coordinating through standardized Command
messages that specify source device, target device, and requested action. The data is sent via simple channels to ensure that it has been transfered successfully.
Device Abstraction
Hardware interfaces are abstracted through the pins module, which groups related GPIO pins into logical bundles. This abstraction simplifies hardware management and enables clean separation between hardware configuration and application logic.
State Management
Display State Machine
The user interface operates as a comprehensive state machine with states for each measurement workflow:
- Startup sequence with visual/audio feedback
- Main menu for measurement selection
- Measurement states (ECG, pulse/SpO₂, temperature, air quality)
- Data transmission states with cloud upload feedback
- Success/failure states with retry capabilities
Sensor Data Flow
Sensor readings follow a standardized pipeline:
- Measurement initiation through display commands
- Data collection by dedicated sensor tasks
- Processing and validation within sensor-specific logic
- Display presentation with health status indicators
- Cloud transmission via WiFi with success confirmation
Real-time Capabilities
The Embassy executor enables cooperative multitasking where tasks voluntarily yield control during I/O operations or delays. This approach ensures:
- Responsive UI - Touch events processed within 50ms polling intervals
- Continuous monitoring - Sensors operate independently without blocking other tasks
- Efficient resource usage - No preemptive context switching overhead
- Deterministic timing - Precise control over measurement windows and data transmission
Memory Management
The system uses static allocation exclusively through heapless
data structures and static_cell
for async resources.