Skip to main content
Version: FILS English

Posture Monitor

A simple device that alerts you when your posture is not proper.

info

Author: Daria-Florentina Sanda
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-dariasanda11

Description

This project aims to be a wearable device that detects when the user is sloughing using an MPU9250 accelerometer and gyroscope sensor. When bad posture is detected, the system provides alerts via vibrations, and an LED turns on so the users knows they should improve their posture.

Motivation

I chose this project because I spent a lot of time sitting at a desk in school and at home, often without maintaining proper posture. Besides not being aesthetically pleasing, bad posture can lead to various back problems that could be prevented with regular reminders to sit up straight. Also, a key factor in my decision for this project is that it uses sensor interaction and LED/motor control, which are elements that I found in the labs.

Architecture

Architecture

  • MPU9250 Sensor: It is used to detect the user's posture with the accelerometer and gyroscope that are connected to the Raspberry Pi Pico 2W via I2C
  • Raspberry Pi Pico 2W:Acts as the central processing unit, interpreting signals from the MPU9250 sensor and controlling the other components
  • Raspberry Pi Pico 2W: Used as debugger
  • Vibration Motor and LED: Used to alert the user and both are connected to the GPIO pins via a transistor for the motor and a resistor for the LED
  • Transistor: Used to switch the motor on and off
  • Diode:: Potects the circuit from back-voltage that could be generated when turning off the motor
  • Resistors: Used to limit the current where needed, such as for the LED and the base of the transistor
  • Push Button: Used for user input, such as to reset

Log

Week 5 - 11 May

I gathered and assembled all the necessary components for the device, carefully arranging and securing the cables with tape as they were not long enough to reach their intended positions. I then sewed the sensor and the motor onto a harness, allowing the device to be integrated into a wearable form.

Week 12 - 18 May

I did the schematic in KiCad and I tried simple codes to see if the connections were correct and if all components were working properly.

Week 19 - 25 May

I configured the push button to act as a stop control for the device, allowing users to halt operations when needed. Additionally, I set up the sensor to enable the accelerometer to start recording data. When the sensor detects a position that deviates from the calibrated "correct" position, the system activates both the LED and motor to provide immediate feedback.

Week 26 - 31 May

I've added a buzzer on GPIO 18, using PWM to control it. I also implemented user input functionality, allowing each user to calibrate the device to their own correct position. This makes the system more personalized and accurate for individual use. I enhanced the functionality of the push button with multi-action controls: Single press: Stops the LED, buzzer, and motor immediately. Double press: Restarts the system, reactivating the LED, buzzer, and motor. Long press: Initiates the calibration process. During this time, the LED blinks for a few seconds to indicate that calibration is in progress. Also, the cable connections proved to be unstable, requiring frequent adjustments. Additionally, the motor needed regular fixing to maintain reliable operation.

Hardware3 Hardware4

Hardware

Hardware1 Hardware2 Complete

The Raspberry Pi Pico 2W in the middle of the breadboard is the microcontroller and the other one acts as a debugger. The LED is connected through the resistor to GPIO 13, the push button is connected to GPIO 16. The motor is connected to the collector of the transistor and to VCC, and it is also connected in parallel with the diode. The base of the transistor is connected through a resistor to GPIO 10. The MPU9250 Sensor is connected through I2C to the microcontroller using GPIO 14 as SDA and GPIO 15 as SCL.

Schematics

Kicad schematic

Bill of Materials

DeviceUsagePrice
2 Raspberry Pi Pico 2WThe microcontroller and one as a debugger80 lei
MPU9250 Sensor Detects posture47 lei
Breadboard HQ (830 Puncte)For assembling the prototype10 lei
Breadboard wiresFor connections8 lei
Vibration MotorAlerts the user to correct their position2.5 lei
NPN Transistor 2N2222Controls motor via GPIO pin0.17 lei
1N4007 DiodeProtects against voltage spikes0.49 lei
Female-Female Jumper Wires (10 pcs, 30 cm)For connections4.79 lei
Female-Male Jumper Wires (10 pcs, 20 cm)For connections4 lei
Push Button 6x6x6 mmFor manual reset0.36 lei
LED Alerts the user to correct their position0.39 lei
330 Ohm ResistorLimits current to LED0.10 lei
1k Ohm ResistorLimits current0.10 lei

Software

LibraryDescriptionUsage
embassyAsync runtime for embedded systemsManages tasks and system operations
embassy-halHardware Abstraction LayerInterfaces with Raspberry Pi Pico 2W hardware
embassy-executorTask executorHandles asynchronous tasks such as sensor polling
embassy-timeTiming moduleDelays and periodic alerts (vibration, LED blinking)
embassy-gpioGPIO managementManages GPIO pins for LED, vibration motor, and button
embassy-syncSync primitivesCoordinates between concurrent tasks safely
defmtLogging and formattingDebug logging with minimal runtime overhead
panic-probePanic handlerHandles runtime panics and reports via RTT
embedded-halAbstraction layerInterfaces with peripherals like I2C and digital IO
rp2040-halHAL for the Raspberry Pi Pico's RP2040 chipDirect access to microcontroller peripherals
mpu9250-driverDriver for the MPU9250 IMU sensorReads posture data from the accelerometer and gyroscope via I2C

1.https://www.mdpi.com/2076-3417/14/19/9075