PosturePulse

by Nischeith Ravindra Boddapati in Circuits > Raspberry Pi

33 Views, 0 Favorites, 0 Comments

PosturePulse

IMG_2257.jpg


PosturePulse is an AI-powered posture monitoring system designed to help users maintain healthy sitting habits. Using a Raspberry Pi, camera, and computer vision model, the system detects different sitting postures in real time and provides feedback when poor posture is identified. It also records posture data, tracks monitoring sessions, and displays statistics through an interactive dashboard. The goal of PosturePulse is to promote better posture awareness and reduce the risk of discomfort and long-term health issues caused by prolonged poor sitting posture.

Supplies

Screenshot 2026-06-17 at 1.52.48 PM.png
Screenshot 2026-06-17 at 1.53.25 PM.png
Screenshot 2026-06-17 at 1.58.17 PM.png
Screenshot 2026-06-17 at 1.47.24 PM.png
Screenshot 2026-06-17 at 1.49.27 PM.png
Screenshot 2026-06-17 at 1.51.55 PM.png
Screenshot 2026-06-17 at 1.52.21 PM.png
4255998-40.jpg
PSU-White-EU.jpg

HARDWARE:

  1. Raspberry Pi 5
  2. Raspberry Pi 5 Power Adapter
  3. Logitech C270 USB Webcam
  4. HC-SR04 Ultrasonic Distance Sensor
  5. 16×2 LCD Display with I2C Interface
  6. Push Button
  7. Active Buzzer
  8. Jumper Wires
  9. RBG led

Preparing the RaspberryPi

What You Need

  1. Raspberry Pi 5
  2. MicroSD Card (32 GB or larger recommended)
  3. Power Supply
  4. Internet Connection
  5. Computer for remote access

Step 1: Install Raspberry Pi OS

Open Raspberry Pi Imager on your computer and insert the microSD card. Select your Raspberry Pi model and choose Raspberry Pi OS Lite (64-bit) as the operating system.

Step 2: Configuring the Pi

Before writing the operating system to the microSD card, configure the Raspberry Pi settings. Set a hostname, username, password, and enable SSH so that the Raspberry Pi can be accessed remotely.

Once the configuration is complete, write the operating system to the microSD card.

Step 3: Boot the Raspberry Pi

Insert the microSD card into the Raspberry Pi and connect the power supply. Allow the device to boot and connect to the network.

Step 4: Connecting via SSH

Using a computer on the same network, connect to the Raspberry Pi through SSH. This allows the system to be configured and managed remotely without requiring a separate monitor, keyboard, or mouse.

Step 5: Update the System

After connecting successfully, update the operating system and installed packages using the following commands:

sudo apt update

sudo apt upgrade -y

Step 6: Install Project Dependencies

Install all required software packages and Python libraries needed for PosturePulse, including OpenCV, FastAPI, Gradio, SQLModel, PostgreSQL , and Raspberry Pi GPIO libraries.

Once these steps are completed, the Raspberry Pi is ready for hardware integration and software development.

Collecting Dataset

good_posture_20260602_180252_0018.jpg
Photo on 04-06-26 at 11.01 AM #5.jpg
leaning_sideways_20260602_201601_0013.jpg
Photo on 06-06-26 at 10.12 PM #6.jpg
looking_up_20260602_201528_0017.jpg
leaning_back_20260602_201430_0037.jpg

To train the posture detection model, a custom dataset was collected containing images of different sitting postures. Since the goal of PosturePulse is to monitor users while they are working at a desk, the images were captured from a side-view perspective to closely match the final system setup.

During the early stages of the project, a front-view dataset was considered. However, after further evaluation, the project was redesigned to use side-view posture detection because it provides a clearer representation of a user's sitting posture and better reflects real-world usage.

The dataset was created by capturing images of different posture variations, including both good and bad postures.

1. Good Posture

  1. The user sits upright with their back straight and shoulders aligned.
  2. This posture represents the recommended sitting position.

2. Slouching

  1. The user leans forward with a rounded upper back and shoulders.
  2. This posture can increase strain on the neck and spine.

3. Leaning Forward

  1. The user bends their upper body excessively toward the desk or screen.
  2. This often occurs when focusing closely on a monitor.

4. Leaning Backward

  1. The user reclines too far backward, reducing proper ergonomic support.
  2. This posture can affect balance and sitting stability.

5. Looking Down

  1. The user's head and neck are tilted downward for an extended period.
  2. This posture may contribute to neck discomfort and poor spinal alignment.

6. Looking Up

  1. The user's head is tilted upward beyond a neutral position.
  2. This posture can place unnecessary strain on the neck muscles.


Extracting Keypoints and Training the Model

After collecting the dataset, the next step was to extract body keypoints from each image. For this, I used the MediaPipe Pose Landmarker, which detects important body landmarks such as the head, shoulders, and hips.

The extracted landmark coordinates were then processed through feature engineering. Additional features were created from the keypoints to better represent body posture and improve the model's ability to distinguish between different sitting positions.The extracted keypoints and engineered features were saved to a CSV file, which was then used for model training and evaluation.

Several classification algorithms were trained and evaluated using the engineered features. The performance of each model was compared based on classification accuracy and overall reliability. After testing multiple approaches, the Random Forest classifier achieved the best results and was selected as the final model.

Images → MediaPipe Pose Landmarker → Keypoint Extraction → Feature Engineering → CSV Dataset → Multiple Classifiers → Random Forest Selected

Creating Database

Screenshot 2026-06-18 at 6.25.09 PM.png

To store posture monitoring data, a PostgreSQL database was created. The database allows PosturePulse to keep track of monitoring sessions, posture classifications, and posture events generated during operation.

Three main tables were used:

Sessions

This table stores information about each monitoring session, including start time, end time, and session id.

Posture Events

This table records every detected posture event along with its confidence score, sensor presence and alert triggered.

Posture Classes

This table contains the available posture(6).

By storing this information in a database, PosturePulse can generate statistics, visualize posture trends, and provide users with a detailed session history through the dashboard.

Relationships

The database follows a relational structure:

  1. One Session can contain multiple Posture Events.
  2. One Posture Class can appear in multiple Posture Events.
  3. Each Posture Event belongs to exactly one Session and one Posture Class.

Designing PosturePulse

Picture1.png
Picture2.png
Picture3.png

Before assembling the system, a housing was designed to safely contain all electronic components while keeping the device easy to use and maintain.

The enclosure consists of a rectangular MDF box with dimensions of 260 mm (width), 250 mm (depth), and 140 mm (height), using 4 mm thick MDF sheets. The design provides enough space for the Raspberry Pi, wiring, sensors, and other electronic components.

Front View

The front panel contains all user-facing components. A raised camera holder is positioned at the top to capture the user's posture from the side. The panel also includes an I2C LCD display for system information, a push button to enable or disable monitoring and turning off, an ultrasonic sensor for user presence detection, and an LED indicator for visual feedback.

Left View

The left side includes a ventilation opening to improve airflow inside the enclosure. A dedicated opening is also provided for the power cable connection.

Right View

The right side contains an additional ventilation opening to help prevent heat buildup during operation.

Construction Materials and Assembly

The enclosure can be manufactured using laser-cut MDF. The main structure is assembled using wood glue, while electronic components are mounted using screws where necessary.

  1. The I2C LCD display is mounted into the box.
  2. The ultrasonic sensor is mounted into the box.
  3. The push button and LED are fixed through dedicated cut-outs in the front panel.
  4. A custom camera holder is created using two MDF sections to elevate the camera above the main enclosure.
  5. Jumper wires are used to connect the Raspberry Pi to the ultrasonic sensor, LCD display, LED, and other electronic components.
  6. The buzzer is integrated into the electronics assembly and provides audio feedback during posture monitoring.

This enclosure provides a compact and organized structure that protects the electronics while ensuring all sensors and feedback components remain easily accessible.

Hardware Components

Screenshot 2026-06-18 at 7.21.06 PM.png

Ultrasonic Sensor (HC-SR04):

The ultrasonic sensor detects whether a user is present at the desk. It is used to automatically start and stop posture monitoring sessions.


I2C LCD Display

The LCD display provides information, such as monitoring status and detected posture.


Buzzer

The buzzer generates audio alerts whenever poor posture is detected, helping users correct their sitting position.


Push Button

The push button is used to enable or disable posture monitoring. A short press toggles the monitoring state, while holding the button for 3 seconds safely shuts down the Raspberry Pi.


RGB LED

The RGB LED provides visual feedback about the current system status:

  1. Blue – Waiting for a user to be detected.
  2. Green – Good posture detected.
  3. Red – Poor posture detected

Making the Makercase

MakerCaseMakerCase was used to design the enclosure for PosturePulse. It allowed the dimensions of the box to be specified and automatically generated laser-cut panels with finger joints for assembly. The generated design was then customized by adding cut-outs for the LCD display, ultrasonic sensor, push button, LED, ventilation slots, and power cable access. Using MakerCase simplified the enclosure design process and ensured that all components could be mounted securely inside the MDF housing.


MakerCase was used to generate the SVG files for the enclosure panels based on the required dimensions of the PosturePulse housing. The SVG files were then imported into Adobe Illustrator, where additional modifications were made, including cut-outs for the LCD display, ultrasonic sensor, push button, LED, and ventilation openings. Labels and graphics were also added for laser engraving. The final design files were used for both laser cutting and engraving the MDF enclosure components before assembly.

How the System Works

Screenshot 2026-06-19 at 12.05.45 AM.png

Workflow

  1. User presses the push button to enable monitoring.
  2. Ultrasonic sensor detects whether the user is sitting at the desk.
  3. A monitoring session automatically starts using ultrasonic sensor.
  4. USB webcam captures live video.
  5. MediaPipe extracts body landmarks.
  6. Trained AI model classifies posture as:
  7. Good Posture
  8. Leaning forward
  9. Slouching
  10. Looking down
  11. Looking up
  12. Leaning sideways
  13. Poor posture maintained for a period triggers an alert.
  14. Posture events are stored in PostgreSQL.
  15. Dashboard visualizes statistics and session history.
  16. Session ends automatically when the user leaves the desk.


User

Ultrasonic Sensor

Raspberry Pi

Camera → AI Model

Posture Detection

FastAPI Backend

PostgreSQL Database

Gradio Dashboard

Developing the Gradio Interface

To make PosturePulse easy to use, a web-based user interface was developed using Gradio. The interface allows users to interact with the system, monitor their posture, and view collected data through a simple and intuitive dashboard.

The application consists of four main pages:

About and Onboarding

This page introduces the project and explains how the system works. It also provides setup instructions, hardware information, and guidance for first-time users.

Operating Page

The Operating page is used for posture monitoring. Users can view the live camera feed, monitor posture predictions, confidence scores, and session duration. The page also supports image uploads for posture analysis and displays real-time monitoring information.

Data Page

The Data page provides an overview of collected posture data. It displays statistics such as total sessions, monitoring time, posture distribution, alerts, and session history. Users can also inspect detailed information for individual monitoring sessions.

Debug Page

The Debug page was created to assist with system testing and troubleshooting during development. It provides access to diagnostic information from the hardware components and software services, making it easier to verify sensor readings, monitor system status, and identify potential issues while developing and testing PosturePulse.

By using Gradio, the system provides a user-friendly way to interact with the posture monitoring system without requiring users to access the underlying code or database directly.

Automation

Screenshot 2026-06-18 at 7.26.56 PM.png

To improve usability, PosturePulse was configured to start automatically whenever the Raspberry Pi is powered on. The required backend services, posture detection application, and Gradio interface launch during startup without requiring any manual intervention.

This automation transforms PosturePulse into a plug-and-play device. Users simply connect power, wait for the system to boot, and begin monitoring their posture without needing to access the terminal or run any commands.

Github

The GitHub repository contains all files required to recreate and understand the PosturePulse project. This includes the source code for the Raspberry Pi application, machine learning model training notebooks, Gradio user interface, FastAPI backend, database implementation, and hardware control scripts.

PosturePulse-Github