Posture Monitor
A simple device that alerts you when your posture is not proper.
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
- 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.
Hardware
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
Bill of Materials
Device | Usage | Price |
---|---|---|
2 Raspberry Pi Pico 2W | The microcontroller and one as a debugger | 80 lei |
MPU9250 Sensor | Detects posture | 47 lei |
Breadboard HQ (830 Puncte) | For assembling the prototype | 10 lei |
Breadboard wires | For connections | 8 lei |
Vibration Motor | Alerts the user to correct their position | 2.5 lei |
NPN Transistor 2N2222 | Controls motor via GPIO pin | 0.17 lei |
1N4007 Diode | Protects against voltage spikes | 0.49 lei |
Female-Female Jumper Wires (10 pcs, 30 cm) | For connections | 4.79 lei |
Female-Male Jumper Wires (10 pcs, 20 cm) | For connections | 4 lei |
Push Button 6x6x6 mm | For manual reset | 0.36 lei |
LED | Alerts the user to correct their position | 0.39 lei |
330 Ohm Resistor | Limits current to LED | 0.10 lei |
1k Ohm Resistor | Limits current | 0.10 lei |
Software
Library | Description | Usage |
---|---|---|
embassy | Async runtime for embedded systems | Manages tasks and system operations |
embassy-hal | Hardware Abstraction Layer | Interfaces with Raspberry Pi Pico 2W hardware |
embassy-executor | Task executor | Handles asynchronous tasks such as sensor polling |
embassy-time | Timing module | Delays and periodic alerts (vibration, LED blinking) |
embassy-gpio | GPIO management | Manages GPIO pins for LED, vibration motor, and button |
embassy-sync | Sync primitives | Coordinates between concurrent tasks safely |
defmt | Logging and formatting | Debug logging with minimal runtime overhead |
panic-probe | Panic handler | Handles runtime panics and reports via RTT |
embedded-hal | Abstraction layer | Interfaces with peripherals like I2C and digital IO |
rp2040-hal | HAL for the Raspberry Pi Pico's RP2040 chip | Direct access to microcontroller peripherals |
mpu9250-driver | Driver for the MPU9250 IMU sensor | Reads posture data from the accelerometer and gyroscope via I2C |