Skip to content

7vanessang/retain

Repository files navigation

Retain — MedSprint 2026

A hackathon prototype for muscular dystrophy patients. The system is a knee brace with an electromagnetic solenoid lock that holds the knee in an extended position to prevent collapse. It is controlled by two push buttons on a mouth retainer.


Files

brace_receiver.inoFlash this file to the ESP32

The only firmware file that needs to be flashed. Controls the solenoid lock via the Funduino motor driver.

  • Language: C++ (Arduino)
  • Board: ESP32
  • Libraries: None beyond the standard ESP32 Arduino core
  • Inputs: Two push buttons (GPIO 4 = lock, GPIO 5 = unlock)
  • Output: GPIO 18 → Funduino motor driver IN1 → solenoid

main.html — Live monitoring dashboard

A browser-based dashboard that connects to the ESP32 over WebSocket and displays brace state, sensor readings, and an event log in real time. Open directly in a browser — no server needed.

  • Language: HTML / CSS / JavaScript
  • Dependencies: Chart.js (loaded from CDN)
  • Protocol: WebSocket on port 81
  • Usage: Enter the ESP32's IP address in the dashboard, click Connect

esp32.cpp — Earlier firmware draft (not used)

A previous iteration of the brace firmware. It used a servo motor instead of a solenoid, tongue pressure pads instead of push buttons, WiFi + WebSocket for the dashboard, and a BNO085 IMU for fall detection. Superseded by brace_receiver.ino.

  • Language: C++ (Arduino)
  • Libraries: ESP32Servo, ArduinoJson, WebSockets

esp32_ble_patch.cpp — BLE add-on patch (not used)

A patch file written to add Bluetooth Low Energy (BLE) support to esp32.cpp. It defines a BLE server on the brace that accepts LOCK, UNLOCK, and TOGGLE commands from a separate retainer transmitter device. Not applicable to the current hardware setup.

  • Language: C++ (Arduino)
  • Libraries: BLEDevice, BLEServer, BLEUtils, BLE2902 (all built into the ESP32 Arduino core)

retainer_transmitter.ino — Second ESP32 firmware (not used)

Firmware for a second ESP32 that would be embedded in a dental retainer. It scans for and connects to the brace over BLE, then sends lock/unlock commands when buttons are pressed. Not used in the current single-button prototype.

  • Language: C++ (Arduino)
  • Libraries: BLEDevice, BLEClient, BLEScan (all built into the ESP32 Arduino core)

train.py — LSTM fall prediction model (not used in prototype)

A Python script that trains a small LSTM neural network to predict fall events from IMU accelerometer and gyroscope data. Uses synthetic data for the hackathon; includes notes on using real datasets (SisFall). Produces a fall_model.h5 file intended for deployment on a Raspberry Pi or via EloquentML on the ESP32.

  • Language: Python 3
  • Libraries: TensorFlow / Keras, NumPy, pandas, scikit-learn
  • Run: pip install tensorflow numpy pandas scikit-learn then python train.py
  • Output: fall_model.h5, scaler.pkl

Hardware (current prototype)

Component Role
ESP32 Microcontroller
Funduino motor driver (L293D) Drives the solenoid
Solenoid Physical knee lock
Button (GPIO 4) Engages lock
Button (GPIO 5) Releases lock
1N4007 flyback diode Protects driver from solenoid voltage spikes
100µF capacitor Smooths power supply when solenoid fires

Power: Solenoid runs on its own supply connected to the driver's +M terminal. The driver's 5V output powers the ESP32 — one power source total.

About

retain is a medium fidelity tongue-controlled knee brace design developed for MedSprint 2026, winning 1st Place in its division and 3rd place overall

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors