Smart AR Hand Physiotherapy & Wireless MyoWare 2.0 EMG Biofeedback Platform
ArtiQ is an interactive smart physiotherapy rehabilitation platform combining client-side MediaPipe Hands AR tracking with an ESP32 + MyoWare 2.0 wireless surface EMG biofeedback node. It delivers real-time
%MVCmuscle activation telemetry over MQTT, green-screen Chroma Key exercise guidance, and clinical session logging inside an Apple-grade Liquid Glass desktop web portal backed by FastAPI, PostgreSQL 15, and Resend OTP security.
- π¬π§ English Documentation (Current)
- π²πΎ Dokumentasi Bahasa Melayu
+---------------------------------------------------------------------------------------------------+
| ARTIQ SYSTEM ARCHITECTURE |
+---------------------------------------------------------------------------------------------------+
[ CLINICAL EDGE HARDWARE ] [ CLOUD & SERVER STACK ]
Folder: esp32/ Folder: ArtiQ/
+----------------------------------+ +----------------------------------+
| ESP32 EMG SENSOR NODE | | ECLIPSE MOSQUITTO |
| - MyoWare 2.0 (ENV Pin @ GPIO32)| MQTT (TCP / Port 1883) | MQTT BROKER (v2.0) |
| - 12-bit Oversampled ADC (1kHz) | <========================> | - artiq/emg/data/{MAC} (20 Hz) |
| - Attack/Decay Envelope Filter | KeepAlive 15s / LWT | - artiq/emg/status/{MAC} (LWT) |
| - Auto Baseline & 3s MVC Peak | | - artiq/emg/command/{MAC} |
+----------------------------------+ +----------------------------------+
|
v
+----------------------------------+ +----------------------------------+
| DESKTOP BROWSER EDGE AI CLIENT | | FASTAPI BACKEND (8830) |
| - MediaPipe Hands 21-Landmarks | HTTPS + HttpOnly JWT | - Modular App (Core/API/Models) |
| - Euclidean Grip Rep Counter | <========================> | - Security Headers & CSRF Guard |
| - Chroma Key Guide Video Engine | 50ms Telemetry Polling | - Rate Limit & 15m Lockout |
| - Liquid Glass UI (Min 900px) | | - Resend 6-Digit OTP Dispatcher |
+----------------------------------+ +----------------------------------+
| |
v v
+--------------+ +----------------+
| POSTGRESQL 15| | RESEND API |
| (Port 5450) | | mail.flowkraft |
| Asia/KL (+8) | | OTP + CID Logo |
+--------------+ +----------------+
The physical wiring for the ArtiQ EMG Node (Rev 1.0)βinterconnecting the ESP32 microcontroller and MyoWare 2.0 Muscle Sensorβis verified in the circuit schematic below:
- π Download Printable Schematic PDF:
Schematic_artiq_2026-11-12.pdf - π Detailed Wiring & Pinout Guide:
esp32/PINOUT_AND_WIRING.md
| Subsystem | Component / Pin | ESP32 GPIO | Operating Voltage | Signal Description |
|---|---|---|---|---|
| Power Supply | MyoWare 2.0 VIN (Pin 1) |
3V3 | 3.3V DC |
Regulated 3.3V output from ESP32 onboard LDO |
| Ground | MyoWare 2.0 GND (Pin 2) |
GND | 0V |
Common ground reference |
| EMG Envelope | MyoWare 2.0 ENV (Pin 3) |
GPIO 32 (D32) | 0.0V β 3.3V Analog |
ADC1_CH4 12-bit (0β4095) hardware-rectified envelope |
- Samples the MyoWare 2.0
ENVpin at1000 Hzon Wi-Fi-safeADC1_CH4(GPIO 32) using an 8-sample oversampling filter (readSmoothedADC()) to eliminate ADC spike jitter. - Auto-calibrates the resting muscle
baseline(0%) at boot and captures the 3-second Maximum Voluntary Contraction (mvcValue) peak via remote"calibrate"command, streaming normalized%MVC(0β150%) to the portal at20 Hz.
- Processes desktop webcam feeds locally in the browser with MediaPipe Hands (zero video uploaded to servers).
- Computes the average Euclidean distance from wrist (
landmark 0) to index (8), middle (12), and ring (16) fingertips: engaging grip below0.15and counting a completed repetition on release above0.20with an800 msanti-ghosting cooldown.
- Composites
guide.mp4dynamically onto an HTML5<canvas>via per-pixel alpha green-screen masking so patients follow target grip form alongside live AR landmarks.
- ESP32 nodes register a retained Last Will and Testament (LWT) on
artiq/emg/status/{MAC}("online"/"offline"), allowing the dashboard to reflect hardware connectivity instantaneously.
- Implements Bcrypt password hashing, HS256 JWT
HttpOnly/Secure/SameSite=Laxcookies, cryptographic 6-digit Resend OTPs (10-minute expiry, 5 max attempts, single-use) for registration and password reset, 15-minute brute-force account lockout, CSRFOrigin/Referervalidation, HTTP security headers, andAsia/Kuala_Lumpur(GMT+8) synchronization. - Includes a Liquid Glass Mobile Blocker (
<= 900 px), dedicatedprivacy.html, branded404.html,robots.txt,sitemap.xml, andllms.txt.
.
βββ README.md # Master Project Documentation (English)
βββ README_MY.md # Master Project Documentation (Bahasa Melayu)
βββ Schematic_artiq_2026-11-12.png # Rendered Hardware Circuit Schematic
βββ Schematic_artiq_2026-11-12.pdf # Printable Hardware CAD Schematic (Rev 1.0)
βββ logo.svg # Vector Project Logo
βββ favicon.svg # Vector Browser Favicon
βββ favicon.ico # Multi-Resolution ICO Favicon
βββ .env.example # Environment Variable Template
βββ .gitignore # Git Exclusion Rules
β
βββ esp32/ # ESP32 Firmware & Hardware Documentation
β βββ README.md / README_MY.md # Hardware Overview & BOM
β βββ PINOUT_AND_WIRING.md / _MY.md # Pinout Table, Electrodes & Safety
β βββ MQTT_SPECIFICATION.md / _MY.md # Topics, JSON Payloads & LWT Protocol
β βββ FLASHING_AND_SETUP.md / _MY.md # Toolchain, Libraries & Pairing Guide
β βββ artiq_emg_node/
β βββ artiq_emg_node.ino # Production MyoWare 2.0 Firmware Sketch
β
βββ ArtiQ/ # Containerized Server & Liquid Glass Web Stack
βββ README.md / README_MY.md # Server Stack Overview
βββ API_DOCUMENTATION.md / _MY.md # REST Endpoints & JSON Envelopes
βββ DOCKER_AND_SERVICES.md / _MY.md # Docker Topology, Ports & Timezone
βββ SECURITY_AND_ARCHITECTURE.md / _MY.md # Auth, CSRF, Lockout & Edge AI Logic
βββ docker-compose.yml # 3-Container Orchestration (DB, API, MQTT)
βββ .env.example # Container Environment Template
βββ mosquitto/config/mosquitto.conf # Mosquitto Broker Configuration
βββ backend/ # Modular FastAPI Application (Non-Root Docker)
β βββ Dockerfile
β βββ requirements.txt
β βββ app/
β βββ main.py
β βββ core/ # Config, Database, Security, Middleware
β βββ models/ # User, OTPRecord, ExerciseSession
β βββ schemas/ # Auth, Session & Common Response Schemas
β βββ api/ # Dependencies & v1 Routers (Auth, Sessions, EMG, Health)
β βββ services/ # Resend Email & MQTT Telemetry Engine
βββ frontend/ # Liquid Glass Clinical Web Portal
βββ index.html # Auth Wall + Desktop Webcam AR Dashboard
βββ privacy.html # Privacy Policy Page
βββ 404.html # Custom Branded 404 Page
βββ style.css # Liquid Glass Optics & Mobile Blocker
βββ app.js # MediaPipe Hands, Chroma Key & Telemetry Polling
βββ logo.png / favicon.ico / favicon.svg
βββ guide.mp4
βββ robots.txt / sitemap.xml / llms.txt
- π§° Hardware Overview & BOM: English β’ Bahasa Melayu
- β‘ Pinout & Wiring Guide: English β’ Bahasa Melayu
- π‘ MQTT Protocol & LWT: English β’ Bahasa Melayu
- πΎ Flashing & Setup Guide: English β’ Bahasa Melayu
- π§© Server Stack Overview: English β’ Bahasa Melayu
- π RESTful API Reference: English β’ Bahasa Melayu
- π’ Docker & Services: English β’ Bahasa Melayu
- π Security & Edge AI Architecture: English β’ Bahasa Melayu
cd ArtiQ
cp .env.example .env
# Edit .env with PostgreSQL credentials, RESEND_API_KEY, and SECRET_KEY
docker network inspect pwn20wnd-network >/dev/null 2>&1 || docker network create pwn20wnd-network
docker compose up -d --build- Install
PubSubClientandWiFiManager(by tzapu) in Arduino IDE, then configuremqtt_serverinesp32/artiq_emg_node/artiq_emg_node.ino. - Flash to your ESP32 (
GPIO 32connected to MyoWare 2.0ENVat3.3V). If no saved Wi-Fi is found within20 seconds, connect to theArtiQ-EMG-Setupcaptive portal to enter your Wi-Fi credentials, then note the MAC address printed on Serial Monitor (115200 baud).
- Visit
http://localhost:8830on a desktop/laptop browser (>= 900 pxwidth with webcam access). - Register an admin account with 6-digit email OTP verification and sign in.
- Open Settings, link your ESP32 MAC address, and click Calibrate to capture your 3-second MVC peak.
- Developed for Educational Purposes Only.
