Skip to content

kiranj26/Posture-Tracker-Using-ESP32

Repository files navigation

Posture Tracker V2 — Product Grade Wearable

Branch: release/v2-product
Status: In development
V1 (MVP breadboard): See main branch

A product-grade evolution of the ESP32 posture tracker. V2 moves from a breadboard prototype to a wearable device — custom PCB, LiPo battery, haptic motor, and a compact shoulder-clip form factor small enough to wear all day.

Hardware: ESP32-S3-MINI-1 · MPU-6050 · DRV2605L + LRA · MAX98357A · 20mm speaker · 350mAh LiPo
Stack: ESP-IDF 5.5.0 · PlatformIO · C only (no Arduino, no C++)
Target size: 45×35×16mm (PCB + battery + clip)


What's New in V2

Feature V1 V2
Alerts Audio only Haptic (early) + Audio (escalation)
MCU ESP32 Dev Kit breakout ESP32-S3-MINI-1 stamp module (built-in PCB antenna)
Power USB only 350mAh LiPo — 12–15 hr battery life
PCB Breadboard + breakouts Custom 2-layer PCB, all ICs direct
Speaker 3W 4Ω (50mm, large) 0.5W 8Ω (20mm, compact)
USB Micro-USB USB-C with proper CC resistors
Buttons None 2 buttons — recalibrate + snooze
Form factor ~120×80mm breadboard 45×35×16mm shoulder clip

Alert UX — Layered Haptic + Audio

The key design principle: haptics for early alerts, audio only for escalation.

Time / State Haptic Audio
10° for 3s — WARNING entry Single tap Silent
WARNING sustained Double tap Silent
20° for 5s — BAD entry Strong double tap Double beep
BAD +8s Triple pulse Double beep
BAD +16s Triple pulse Double beep
BAD +24s onwards Triple pulse "Sit up straight" — repeats every 8s
Posture corrected Long reward pulse "Thank you good work"
30s good streak Gentle pulse Silent

SW2 (snooze button) mutes all audio for 10 minutes while haptics continue — for meetings, calls, or quiet environments.


Hardware

Component List

Component Part Purpose
ESP32-S3-MINI-1 Espressif MCU — dual core, BLE 5.0, native USB, built-in PCB antenna
MPU-6050 InvenSense 6-axis IMU — pitch/roll angle sensing
DRV2605L Texas Instruments Haptic driver — 123 built-in LRA waveforms
Z10SC2B LRA Jinlong 10mm linear resonant actuator — sharp haptic taps
MAX98357A Maxim I2S Class D amplifier — voice clips + tones
CMS-2009-SMT-TR CUI Devices 20mm 8Ω 0.5W speaker
MCP73831 Microchip LiPo charging IC — 100mA from USB-C
AP2112K-3.3 Diodes Inc 600mA LDO regulator — 3.3V rail
USBLC6-2SC6 STMicro USB ESD protection on D+/D- lines
350mAh LiPo Generic Battery — 12–15 hour runtime
USB-C (HRO TYPE-C-31-M-12) HRO Charging + programming port, both-orientation USB 2.0

Pin Assignment

Signal GPIO Notes
I2C SDA 8 MPU-6050 + DRV2605L shared (GPIO21/22 do not exist on ESP32-S3)
I2C SCL 9 MPU-6050 + DRV2605L shared
I2S BCLK 26 MAX98357A
I2S WS 25 MAX98357A
I2S DOUT 27 MAX98357A
SW1 BOOT/CAL 0 Recalibrate / ESP32 boot
SW2 SNOOZE 35 10-min snooze / mute toggle
SW3 RESET EN pin Hardware reset button
VBAT SENSE 34 ADC — battery voltage monitor
AUDIO MUTE 48 MAX98357A SD_MODE
USB D+ 20 Via USBLC6-2SC6 ESD protection
USB D- 19 Via USBLC6-2SC6 ESD protection

Architecture

Three FreeRTOS tasks (V1) + Two new tasks (V2)

Task Core Priority Purpose
task_read_imu 0 5 IMU read every 100ms with light sleep
task_posture_fsm 0 4 State machine — unchanged from V1
task_audio 1 3 Audio + haptic dispatch
task_buttons 0 2 Debounced button events
task_power 0 1 Battery monitor every 60s

New modules vs V1

NEW:      haptic.c    — DRV2605L I2C driver, waveform playback (non-blocking)
NEW:      power.c     — battery ADC, low-battery warning, deep sleep entry
NEW:      buttons.c   — debounced GPIO, short/long press detection

UNCHANGED: mpu6050.c  — I2C driver, atan2 angle math, EMA filter
UNCHANGED: posture_fsm.c — state machine logic (only alert commands change)
MODIFIED:  audio.c    — adds haptic command dispatch alongside audio
MODIFIED:  main.c     — init order adds haptic, power, buttons

Power System

USB-C (5V) → Polyfuse → MCP73831 LiPo charger → 350mAh LiPo
                                                        ↓
                                                  AP2112K LDO
                                                        ↓
                                                    3.3V rail → all ICs

Battery life estimate:

  • Active draw (IMU reading, no alerts): ~6mA average with light sleep
  • 350mAh ÷ 6mA = ~58 hours theoretical
  • Real world (audio bursts, haptic, occasional BLE): 12–15 hours

Low battery handling:

  • < 3.5V → warning beep + haptic
  • < 3.3V → shutdown tone + deep sleep

Form Factor

Assembled dimensions:
  PCB alone:        45 × 35 × 1.6mm
  PCB + battery:    45 × 35 × 8mm
  With clip:        45 × 38 × 16mm   ← final wearable size

Comparable to a car key fob.
Clips onto shirt collar, bra strap, or epaulette.
LRA motor faces the body for best haptic transmission.
Speaker grille faces outward.
USB-C and buttons accessible on edges.

Development Phases

Phase Description Status Hardware
7 Haptic validation on breadboard (DRV2605L + LRA) ⏳ Next 📦 Parts ordered
8 Speaker swap validation (20mm 8Ω 1W) ⏳ Next 📦 Parts ordered
9 Battery system validation (MCP73831 + LiPo) ⏳ Pending 📦 Parts ordered
10 PCB V2 schematic + layout + fabrication (JLCPCB) 🔄 PCB complete — awaiting order Schematic ✅ ERC clean. Layout ✅ fully routed. DRC ✅ 0 errors, 0 unconnected, 2 cosmetic silk warnings. Gerbers ✅ hardware/pcb/v2/. JLCPCB order ⏳ pending.
11 Full integration + enclosure (3D printed clip) ⏳ Pending 🛒 Order after Phase 10

Branch Structure

main                        ← V1 MVP (public, breadboard, complete)
  └── release/v2-product    ← this branch — all V2 work
        └── feature/haptics
        └── feature/speaker-swap
        └── feature/power-system
        └── feature/pcb-v2
        └── feature/enclosure

PCB Layout — Complete

Design decisions locked

  • 2-layer board — F.Cu for all signal and power traces, B.Cu solid GND copper pour
  • Trace widths (IPC-2221 verified, 1oz copper, 10°C rise) — VBUS/VBUS_FUSED: 0.4mm, +3V3/VBAT/audio/motor: 0.3mm, all signals: 0.2mm
  • Net classes — HighCurrent (0.4mm), Power (0.3mm), Audio (0.3mm), Motor (0.3mm), USB_Diff (0.2mm impedance-controlled), Default (0.2mm)
  • Via spec — 0.8mm outer / 0.4mm drill (JLCPCB standard rule compliant)
  • Board size — ~47.6 × 28.3mm (fits 45×35×16mm wearable form factor with battery)
  • Connectors — J1: USB-C (HRO TYPE-C-31-M-12), J2: JST PH 2mm (battery), J3: Molex PicoBlade 53261-0271 (LRA haptic), LS1: Molex PicoBlade 53261-0271 (speaker)

Routing status

Net group Connections Status
GND ~72 ✅ B.Cu + F.Cu copper pour, stitching vias placed
+3V3 23 ✅ Routed
VBAT 7 ✅ Routed
VBUS / VBUS_FUSED 4 ✅ Routed
I2C (SDA/SCL) 6 ✅ Routed
USB_DP / USB_DM 8 ✅ Routed
I2S (BCLK/WS/DOUT) 3 ✅ Routed
Signals + buttons ~31 ✅ Routed

Final DRC (2026-06-09): 0 errors, 0 unconnected, 2 cosmetic silk warnings (U1 silkscreen clips board edge — JLCPCB trims automatically).

File locations

hardware/
├── kicad/posture_tracker_v2/
│   └── posture_tracker_v2/    ← KiCad source (schematic + PCB + project files)
│       └── reports/           ← DRC.rpt, ERC.rpt
├── schematics/                ← Exported schematic PDF (posture_tracker_v2_v2.pdf)
├── pcb/
│   └── v2/
│       ├── gerbers/           ← 12 Gerber + drill files (canonical fab outputs)
│       └── posture_tracker_v2_gerbers.zip  ← upload this to JLCPCB
├── bom/                       ← Bill of materials
└── datasheets/                ← Component datasheets

Hardware Visuals

PCB — 3D View

PCB V2 3D view

PCB — Top Layer

PCB V2 top layer

PCB — Bottom Layer

PCB V2 bottom layer

PCB — Combined

PCB V2 combined

Schematic

V2 Schematic

Full schematic PDF: hardware/schematics/posture_tracker_v2_v2.pdf

PCB layer PDFs (vector): Top · Bottom · Combined


Reference Docs

About

Posture Correction using ESP32-MINI-1 and MU sensor (GY-521 / MPU-6050)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors