Skip to main content
Version: FILS English

VitalPi

Meet Your Personal Health Guardian - Real-time Vital Monitoring at Your Fingertips

info

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.

Architecture


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.

HardwareWeek1

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.

HardwareWeek2

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.

HardwareWeek3

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.

Hardware

Schematics

This is the KiCad Schematics of the project.

KiCAD Schematics

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2WThe microcontroller that processes all sensor data and manages wireless connectivity35 RON
2.4" TFT LCD Touchscreen (240×320px)User interface display for viewing health data and interacting with the system54 RON
MLX90614ESF Infrared Temperature SensorNon-contact temperature measurement for body and ambient temperature monitoring60 RON
AD8232 ECG Sensor ModuleSingle-lead electrocardiogram sensor for heart activity monitoring and analysis35 RON
MQ135 Gas SensorAir quality detection for monitoring harmful gases and environmental conditions16 RON
Breakout heart rate sensor GY-MAX30102Pulse oximetry sensor for monitoring blood oxygen levels and heart rate14 RON
Passive Buzzer ModuleAudio notification system for alerts and warnings2 RON
RGB LED Common CathodeVisual status indicator showing system and health conditions through color coding1 RON
3 x 220Ω ResistorsCurrent-limiting components for the RGB LED0,30 RON
1 kΩ ResistorComponent of voltage divider for MQ135 gas sensor0,10 RON
2 kΩ ResistorComponent of voltage divider for MQ135 gas sensor0,10 RON

Software

LibraryDescriptionUsage
embassy-rpEmbassy support for Raspberry Pi RP2350Runs async embedded tasks on Raspberry Pi Pico 2W
embassy-embedded-halAsync implementation of embedded-hal traitsInterfaces with async-compatible embedded peripherals
embassy-syncSynchronization primitives for async embedded RustUsed for mutexes, signals, and channels in concurrent tasks
embassy-executorAsync task executor for bare-metal embedded systemsManages scheduling and running async tasks on the device
embassy-futuresLightweight async utilities for embedded systemsProvides futures and combinators used in async workflows
embassy-timeTimekeeping and delays for embedded systemsUsed for timers, delays, and task timeouts
embassy-netAsync TCP/IP networking stackHandles communication between device and remote server
embassy-net-wiznetWiznet W5500 Ethernet driver for EmbassyProvides Ethernet connectivity support
cyw43Driver for the CYW43 Wi-Fi chipProvides Wi-Fi connectivity to the Raspberry Pi Pico 2W
cyw43-pioPIO-based CYW43 driver implementationAllows communication with CYW43 via the Pico's PIO
defmtLogging framework optimized for embedded devicesUsed for low-overhead logging during debugging
defmt-rttBackend for defmt using RTT (Real-Time Transfer)Enables real-time logging over debug probe
cortex-m-rtRuntime for Cortex-M microcontrollersSets up interrupt vectors and program entry point
panic-probePanic handler for defmt-enabled embedded appsCaptures and displays panics for debugging
embedded-hal-asyncAsynchronous embedded-hal traitsDefines async traits for interacting with hardware
display-interface-spiSPI interface for display driversProvides abstraction for SPI-based display communication
ili9341Driver for ILI9341 LCD display controllerEnables graphics output to ILI9341-based displays
heaplessData structures that don't require dynamic memoryUsed for buffers and queues with guaranteed memory use
xpt2046Touchscreen driver for XPT2046Reads user input from resistive touchscreen displays
micromathLightweight math library for microcontrollersUsed for computations like ECG signal processing
mlx9061xDriver for MLX90614 temperature sensorUsed for contactless infrared temperature measurement
embedded-graphics2D graphics libraryUsed for drawing to the display
static_cellStatically allocated, initialized at runtime cellProvides safe static storage for async resources
embedded-io-asyncAsync I/O traits for embedded systemsEnables 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 spawning
  • wifi_task - Network communication and cloud data transmission
  • display_task - User interface state machine and touchscreen handling
  • led_task - Visual feedback system with color-coded health indicators
  • buzzer_task - Audio notification system for alerts and confirmations
  • temp_task - Temperature sensor monitoring via I²C
  • adc_task - ECG measurement using AD8232 sensor and Air Quality measurement using MQ135 sensor
  • bpm_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:

  1. Measurement initiation through display commands
  2. Data collection by dedicated sensor tasks
  3. Processing and validation within sensor-specific logic
  4. Display presentation with health status indicators
  5. 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.

Software Diagram

Software Architecture

  1. Datasheet for MAX30102
  2. Embedded-canvas for better update on the screen