FemFit-Industrial: Edge-AI Ergonomic Smart Safety Vest
FemFit-Industrial is an edge-AI powered smart safety vest designed specifically for female industrial workers. It aims to prevent work-related Musculoskeletal Disorders (MSDs) caused by improper lifting, ergonomic strain, and high-vibration heavy machinery environments.
Project Overview & System Architecture
- Synthetic Data Generator (Python): Simulates 3-axis accelerometer and 3-axis gyroscope data at 50Hz, modeling four distinct ergonomic and vibratory work conditions.
- On-Device Firmware (C++): Real-time posture tracking and vibration analysis running directly on an ESP32 or Arduino Nano 33 BLE Sense. Uses a drift-free complementary filter, rolling-window variance estimation, and a non-blocking haptic alert state machine.
+---------------------------------------------+
| Python Simulator |
| (Generates Labeled IMU Data at 50 Hz) |
+-----------------------+---------------------+
|
v
+---------------------------------------------+
| Edge Impulse Studio |
| - Upload Segmented CSV Trials |
| - DSP Spectral Features Extraction |
| - Train 1D Convolutional Neural Network |
| - Export as C++ TFLite Micro Library |
+-----------------------+---------------------+
|
v
+---------------------------------------------+
| Microcontroller |
| (ESP32 / Arduino Nano 33 BLE Sense) |
| - Acquires 6-Axis IMU Streams (50 Hz) |
| - Runs TFLite Micro Model (or Heuristics) |
| - Triggers Non-Blocking Haptic Vibrations |
+---------------------------------------------+
Female Biomechanical Ergonomics
Standard ergonomics frameworks (RULA/REBA) and safety equipment are typically calibrated against male anthropometric averages. FemFit-Industrial addresses this gap by adjusting thresholds based on female biomechanics:
- Lower Center of Gravity (CoG): Bending forward from the waist (trunk flexion) shifts loading forces to the lower lumbar spine (L4-S1) differently in females. Unsafe forward trunk flexion starts at >20° (REBA Trunk Score 2) and becomes critical at >45° (REBA Trunk Score 3/4).
- Pelvic & Lumbar Angle Differences: Asymmetric lateral bending or rotation (spine twisting) significantly amplifies loading pressure on spinal discs. Lateral tilt or twisting is capped at >15° under load to prevent acute injury.
- Micro-Vibrations: Operators of hand tools or machinery are exposed to high-frequency micro-vibrations (10Hz – 50Hz) which trigger vascular and neurological micro-strain. The system detects this by calculating the variance of the acceleration signal.
Firmware Details (FemFit_Firmware.ino)
The firmware runs a high-performance, non-blocking execution loop at exactly 50Hz.
- Board Selection: Toggle selection using preprocessor macros:
#define BOARD_ESP32(uses MPU6050 via Wire I2C; haptics on GPIO 25).#define BOARD_NANO_BLE(uses onboard LSM9DS1 IMU; haptics on GPIO 2).
- Complementary Filter: Estimates pitch and roll while eliminating gyro drift: $$\text{Pitch}{new} = 0.98 \times (\text{Pitch}{prev} + \text{GyroX} \times dt) + 0.02 \times \text{Pitch}_{acc}$$
- High-Frequency Vibration Detection: Calculates rolling variance on a window of 10 samples (200ms) of accelerometer magnitude. If the variance exceeds
2.25(equivalent to standard deviation of $1.5\text{ m/s}^2$), a machinery vibration alert is raised. - Non-Blocking Haptic State Machine: Pulsing patterns are managed using
millis()to avoid blocking sensor readings:- ALERT_POSTURE_WARNING: Slow pulsing (200ms ON, 400ms OFF).
- ALERT_CRITICAL_STRAIN: Rapid double pulse (100ms ON, 100ms OFF, 100ms ON, 500ms OFF).
- ALERT_MACHINERY_VIBRATION: Long sustained pulse (800ms ON, 200ms OFF).
Step-by-Step TinyML Migration Plan (Edge Impulse & TFLite)
To replace the heuristic decision matrix in the firmware with a true Edge-AI TinyML classifier, follow these steps:
Step 1: Upload Data to Edge Impulse Studio
- Sign up/log in at Edge Impulse Studio. Create a new project called FemFit-Industrial.
- Install the Edge Impulse CLI or use the Web Uploader under the Data Acquisition tab.
- Click "Upload Files". Select all CSV files inside
dataset/safe_ergonomic/,dataset/unsafe_bend/,dataset/unsafe_twist/, anddataset/heavy_vibration/. - Choose Infer category from folder name to automatically label the uploads based on folder structures (
safe_ergonomic,unsafe_bend,unsafe_twist,heavy_vibration). - Let Edge Impulse split your files automatically into Training (80%) and Test (20%) datasets.
Step 2: Configure the Impulse (DSP & ML Blocks)
- Go to Create Impulse.
- Set the Window size to
10000ms(10 seconds, matching our generated duration) and the Window increase to1000ms(creating overlapping windows for better training). - Set the frequency to
50Hz. - Add a Spectral Analysis processing block (great for separating physical postures from high-frequency vibration signals). Select
ax, ay, az, gx, gy, gzas input axes. - Add a Classification (Keras) learning block (this outputs a Neural Network classifier).
- Click Save Impulse.
Step 3: Extract Spectral Features
- Go to the Spectral Features tab.
- Select Filter Type: High-pass filter (cut-off at ~0.5Hz to remove baseline gravity bias) or keep the raw spectrum. The default parameters are optimized for IMU sensors.
- Click Save parameters and then click Generate Features.
- Review the Feature Explorer (a 3D plot of extracted characteristics). You should see clear spatial separation between your 4 classes.
Step 4: Train the Neural Network Model
- Navigate to the Classifier tab.
- Configure your neural network. A recommended model is a 1D Convolutional Neural Network (1D CNN) or a standard Dense neural network.
- Set the training parameters:
- Epochs:
30 - Learning rate:
0.0005 - Validation size:
20%
- Epochs:
- Click Start Training.
- Once complete, review the model accuracy (targeting >95% accuracy) and the Confusion Matrix. Check the calculated on-device latency and RAM/Flash footprint estimation.
Step 5: Export as C++ TFLite Micro Library
- Navigate to the Deployment tab.
- Under "Search for board or library", select C++ Library (this packages the model as a generic, highly optimized C++ library containing the TensorFlow Lite Micro compiler).
- Under "Select optimizations", choose Quantized (int8) for maximum efficiency and low memory usage.
- Click Build to download a compressed
.zipfile containing the source code.
Step 6: Deploy on the Microcontroller
- Unzip the downloaded library and copy the folder into your Arduino library directory (usually
Documents/Arduino/libraries/). - Open the example sketch generated by Edge Impulse (e.g.,
nano_ble_sense_accelerometeror a generic static buffer classifier example). - In
FemFit_Firmware.ino, replace the heuristic functionupdateHapticAlerts()with the Edge Impulse inference runner:- Copy the sensor features (
ax, ay, az, gx, gy, gz) into the input signal buffer. - Call
run_classifier(&signal, &result, false)to run on-device inference. - Read output probabilities:
cpp float safe_prob = result.classification[0].value; float bend_prob = result.classification[1].value; float twist_prob = result.classification[2].value; float vibe_prob = result.classification[3].value; - Update the alert state based on the highest probability:
cpp if (bend_prob > 0.70) currentAlert = ALERT_CRITICAL_STRAIN; else if (twist_prob > 0.70) currentAlert = ALERT_CRITICAL_STRAIN; else if (vibe_prob > 0.70) currentAlert = ALERT_MACHINERY_VIBRATION; else if (pitch > THRESHOLD_PITCH_WARN) currentAlert = ALERT_POSTURE_WARNING; // fallback else currentAlert = ALERT_NONE;
- Copy the sensor features (
- Compile and upload the code! Your system is now running true edge machine learning.
Built With
- 1d-convolutional-neural-networks-(1d-cnn)
- arduino
- arduino-nano-33-ble-sense
- ble-(bluetooth-low-energy)
- c++
- complementary-filter
- digital-signal-processing-(dsp)
- edge-impulse-studio
- embedded-machine-learning
- esp32
- gpio
- i2c-communication
- lsm9ds1-imu
- mpu6050
- pwm
- python
- reba
- rolling-window-variance-estimation
- rula
- signal-processing
- spectral-analysis
- tensorflow-lite-micro-(tflite-micro)
- tinyml