SignConnect Wiki
Sign Language Translator Glove: Reference Study
Amr Bedir
Nov 27, 2026
# Reference Study: Sign Language Translator Glove (ESP32 + Flex Sensors + Android) **Published:** November 27, 2026 **Images:** diagrams and charts made by the SignConnect team from the repository's code and dataset; hand-sign drawings come from the repository's app assets. **Category:** Hardware / Data Glove / Reference Projects **Source:** Open-source GitHub repository `Sign-Language-Translator-Glove` (originally a university course project named `coen390-project`). We downloaded it during the SignConnect graduation project as a reference for the data-glove track. > This article is a full walkthrough of that repository: what is inside, how every part works, how data flows from the finger to the spoken word, how to rebuild it, and what we learned from it (including its weak points). It is written so anyone starting a glove-based sign language project can save weeks of work. --- ## 1. What the Project Does The project is a **wearable glove** that reads how much each finger is bent, sends the readings to an **Android phone over Bluetooth**, and the phone runs a small **on-device neural network (TensorFlow Lite)** to recognize the hand sign. The recognized sign is shown as text plus a reference image and is **spoken out loud** with Text-to-Speech. It recognizes **13 static American Sign Language (ASL) hand shapes**: | Type | Signs | | :--- | :--- | | Numbers | 1, 2, 3, 4, 5, 6, 7, 8, 9 | | Letters | E, I, L, Y |  *The 13 signs the model knows. The "class" number is the output index of the neural network (section 7).* "Static" means the hand holds a still shape. Signs that need movement (like J or Z, or most words) are out of scope for this version. On top of translation, the app also has a learning game, a text-to-sign dictionary, custom meanings for each gesture, dark mode, and English/French support. --- ## 2. Repository Layout ``` Sign-Language-Translator-Glove-main/ ├── .gitignore Android Studio ignore rules └── codes/ ├── arduino/ │ ├── glove_main.ino Main glove firmware (flex only, Bluetooth) │ ├── code Alternative firmware: flex + MPU6050 IMU (no extension!) │ └── datacollection.ino Firmware used to record training data over USB ├── arduino.zip Same three files, zipped ├── ml_training/ │ ├── requirements.txt Python dependencies │ └── static_gestures_final/ │ ├── data_processing/ │ │ ├── dataset.csv Training data (165,734 rows) │ │ ├── sample.txt Example raw recording │ │ ├── process_textfile.py Cleans a raw recording and relabels it │ │ ├── data_generator.py Generates synthetic (fake) readings │ │ └── processeddata.csv Output of process_textfile.py (empty here) │ ├── model_training/ │ │ └── main.py Trains Random Forest + the TFLite network │ └── model_files/ │ ├── gesture_random_forest.pkl │ ├── scaler.pkl │ ├── label_encoder.pkl │ └── gesture_model.tflite The model the phone actually uses (13 KB) ├── android/code/ Full Android Studio project (Java) └── android.zip Same Android project, zipped ``` The `.zip` files are just duplicates of the folders next to them. --- ## 3. System Architecture  Four layers: **sensing** (glove), **transport** (Bluetooth), **decision** (stability + model), **presentation** (UI + voice). --- ## 4. Hardware ### 4.1 Components | Part | Role | Notes | | :--- | :--- | :--- | | ESP32 dev board | Microcontroller + Bluetooth | Uses classic Bluetooth (not BLE) | | 5 × flex sensors | One per finger | Resistance rises as the finger bends | | 5 × fixed resistors | Voltage dividers | Turn resistance into a voltage the ADC can read (value not documented in the repo; typically 10k to 47k Ω, pick one close to the sensor's flat resistance) | | MPU6050 (optional) | Accelerometer + gyroscope | Only used by the alternative firmware `code` | | Glove + battery | Wearable base | | ### 4.2 Pin Map | Finger | ESP32 pin | | :--- | :--- | | Thumb | GPIO 36 (VP) | | Index | GPIO 39 (VN) | | Middle | GPIO 34 | | Ring | GPIO 35 | | Little (pinky) | GPIO 32 | | MPU6050 SDA / SCL | Default I²C pins (GPIO 21 / 22) |  Each flex sensor and a fixed resistor form a **voltage divider**: one end to 3.3 V, the other through the resistor to GND, and the point between them goes to the ESP32 pin. As the finger bends, the sensor's resistance changes, so the voltage at that point changes too. **Why these pins matter:** all five are on the ESP32's **ADC1**. ADC2 pins cannot be read while the Wi-Fi/Bluetooth radio is on, so if you move a sensor to an ADC2 pin (for example GPIO 4, 12-15, 25-27) it will stop working once Bluetooth starts. Keep flex sensors on ADC1 (GPIO 32-39). ### 4.3 Calibration The firmware turns each raw ADC reading into an angle-like value from **0 to 180**: ```cpp const int minValues[5] = {0, 0, 0, 0, 0}; const int maxValues[5] = {675, 800, 750, 120, 430}; int flexMapPrecise(int sensorValue, int minVal, int maxVal) { int constrainedValue = constrain(sensorValue, minVal, maxVal); return map(constrainedValue, minVal, maxVal, 0, 180); } ```  The chart shows why per-finger calibration matters: the ring finger reaches 180 at a raw value of only 120, while the index needs 800. Any small noise on the ring sensor becomes a big jump after scaling. - The `maxValues` are the raw readings of **their** sensors when fully bent. Every flex sensor and every resistor is different, so **you must measure your own** values (print `analogRead()` while bending each finger fully and use the highest stable number). - Note the ring finger's max is only 120, which means that sensor had a very small range. Small ranges make the reading noisy after scaling, so a better resistor choice helps. - The ESP32 ADC is 12-bit (0-4095) and not perfectly linear, especially near the ends. That is fine here because the model only needs consistent numbers, not true degrees. --- ## 5. Firmware (ESP32 / Arduino) There are three sketches. Use them in this order: **datacollection → (train) → glove_main**. ### 5.1 `glove_main.ino` (the one the app expects) - Starts serial at 115200 baud and Bluetooth Classic with the name **`ESP32_BT`**. - Every **20 ms** (about 50 times a second) it reads the five sensors, maps each to 0-180, and sends one text line: ``` 180,4,180,180,180 ``` - Order is always **thumb, index, middle, ring, little**. - It sends the same line to USB serial (for debugging) and to Bluetooth. - It includes the MPU6050 libraries but does not use them. They can be removed. ### 5.2 `code` (flex + IMU version) This file has no `.ino` extension; rename it to `glove_imu.ino` inside a folder of the same name to open it in the Arduino IDE. It adds an MPU6050: - Accelerometer range ±8 g, gyroscope ±500 °/s, built-in low-pass filter 21 Hz. - **Startup calibration:** takes 1000 samples while the hand is still and averages them to find the sensor bias (subtracting 9.8 m/s² gravity from Z). - **Moving average filter** with a window of 10 on all six IMU axes. - Sends **11 values** per line: 5 flex + accX, accY, accZ + gyroX, gyroY, gyroZ. **Important:** the Android app and the model expect exactly **5** values. If you flash this version, the app will throw an error ("Expected 5 sensor readings"). It was clearly a step toward dynamic (moving) signs that was not finished. If you want to use it, you need to retrain the model with 11 features and change `INPUT_FEATURES` in the app. Two things to know if you build on it: the code subtracts gravity twice from Z (once in calibration, once in the loop), so accZ ends up offset; and the board halts forever (`while(1)`) if the MPU6050 is not found. ### 5.3 `datacollection.ino` (recording training data) - No Bluetooth; prints to USB serial only. - Each round records **100 readings back-to-back** for one "sample", waits one second, then repeats. - Line format: ``` sample_id, reading_number, thumb, index, middle, ring, little, myGesture ``` How it was used: hold one gesture, open the Serial Monitor, let it record a few rounds, copy the output into a text file, then clean it with the Python script (next section). Repeat for every gesture. **Tip:** while recording, move the hand slightly, rotate the wrist, and relax/tense the fingers a little. If all 100 readings are identical, the model learns a very narrow version of the sign and fails on other people's hands. --- ## 6. Dataset `dataset.csv` has a header `THUMB, INDEX, MIDDLE, RING, LITTLE, LABEL` and **165,734 rows**. Every value is already in the 0-180 range. | Label | Rows | Label | Rows | | :--- | ---: | :--- | ---: | | 1 | 10,904 | 8 | 14,600 | | 2 | 11,857 | 9 | 9,900 | | 3 | 15,351 | E | 10,200 | | 4 | 13,900 | I | 11,300 | | 5 | 13,900 | L | 10,800 | | 6 | 10,400 | Y | 21,721 | | 7 | 10,900 | | | The classes are fairly balanced, except **Y**, which has about twice as many rows as the others.  ### What the data actually looks like The heatmap below is the **average value of each finger for each gesture** across the whole dataset (0 = straight, 180 = fully bent). It is the best way to understand what the model is learning:  What it tells us: - **Numbers are easy to separate.** Each of 1-9 has a clear pattern of straight and bent fingers (for example 5 is all zeros, 3 is thumb + index + middle straight). - **E and I are almost the same** except for the little finger (141 vs 5). One sensor decides between them, so a weak little-finger sensor means E/I confusion. - **2 and L differ only by the thumb** (149 vs 1), and **1 and L** differ mainly by the thumb too. Thumb calibration is critical. - **Y's little finger averages 97**, not near 0 as you would expect for an extended pinky. That points to a sensor that did not straighten fully, or mixed recordings. This is the kind of thing worth checking before training. - With only 5 bend values, signs that differ by **finger contact, palm direction, or movement** (for example U vs V, or J) cannot be told apart at all. That is why the IMU and more sensors matter for a full alphabet. ### 6.1 Helper scripts - **`process_textfile.py`**: reads `sample.txt`, drops the first two columns (sample id and reading number), replaces the last column with the real label you pass to `convert_label("2")`, and writes `processeddata.csv`. You then append that file to `dataset.csv`. - **`data_generator.py`**: makes **synthetic** data by rule: a "bent" finger is a random number 90-180 and a "straight" finger is 0-45. It prints 100 rows for each of 11 hand shapes. Useful to test the pipeline before you have a glove, but **do not train your final model on it**: real fingers sit in between (45-90) a lot and it would teach the model a fake, too-clean world. --- ## 7. Machine Learning Pipeline (`model_training/main.py`) Install dependencies first (Python 3.10-3.12 recommended): ```bash pip install -r requirements.txt # joblib, keras 3.9, matplotlib, numpy 2.0, pandas, scikit-learn 1.6, tensorflow 2.18 cd codes/ml_training/static_gestures_final python model_training/main.py ``` Run it from `static_gestures_final/`, because the paths inside are relative (`data_processing/dataset.csv`, `model_files/...`). ### 7.1 Step 1: Random Forest 1. Load `dataset.csv` and strip spaces from column names. 2. `LabelEncoder` turns labels into numbers. It sorts them as text, so the order is `1,2,...,9,E,I,L,Y` → indexes **0 to 12**. 3. `MinMaxScaler` scales each finger to 0-1. 4. 80/20 train/test split (`random_state=42`). 5. `RandomForestClassifier(n_estimators=100)` is trained and its accuracy printed. 6. Saves `gesture_random_forest.pkl`, `label_encoder.pkl`, `scaler.pkl`. ### 7.2 Step 2: the "conversion" to TensorFlow Lite The function is called `convert_to_tflite()`, but it is worth being precise: **a Random Forest cannot be converted to TFLite directly, and this code does not convert it.** It trains a **separate small neural network** on the same data and converts *that* network: ```python nn_model = keras.Sequential([ layers.Input(shape=(5,)), layers.Dense(64, activation="relu"), layers.Dense(32, activation="relu"), layers.Dense(13, activation="softmax") ]) # adam, sparse_categorical_crossentropy, 50 epochs, batch size 8 ```  So the model on the phone is this **5 → 64 → 32 → 13 MLP** (about 2,900 parameters, 13 KB). The Random Forest is only used to fit the scaler/encoder and as an accuracy reference. Also note the network is trained on **all** data with no test split, so its real accuracy is never measured in the script. If you reuse this, add `validation_split=0.2` and a larger batch size (8 with 165k rows makes training very slow; 64-256 is fine). ### 7.3 Why it matches the phone - The app normalizes by dividing by 180. The scaler was fitted on data whose min/max is exactly 0/180 for every finger, so both give the same numbers. If your new data does not span 0-180 fully, this breaks silently; safer to export the scaler's min/max into the app. - The model's output index order (alphabetical label order) must match the row order of `gesture_info.csv` in the app. It does: 1-9, then E, I, L, Y. --- ## 8. Android App **Stack:** Java, Android Gradle Plugin 8.8, compileSdk/targetSdk 35, **minSdk 24** (Android 7.0), Java 11, TensorFlow Lite 2.9.0, Material Components, ViewBinding. ### 8.1 Code structure ``` com.example.handsign_translator_app/ ├── MainActivity Live translation screen ├── LearningActivity Practice game ├── TextToASLActivity Type text → see signs ├── GesturesActivity Gesture list, custom meanings, collections ├── SettingActivity Theme + language ├── LogsActivity History screen ├── GestureInfoHelper Loads gesture_info.csv (or _fr.csv) ├── bluetooth/ │ ├── BluetoothModule Socket connect + read thread + disconnect monitor │ └── BluetoothService Bound Service that keeps one shared connection ├── controllers/ │ └── GestureController Main loop: read → window → stable? → classify ├── ml_module/ │ ├── GestureClassifier Loads and runs gesture_model.tflite │ └── GestureStabilityChecker ├── database/GestureLogDbHelper SQLite table gesture_logs ├── models/Gesture, GestureLog └── utils/Constants ``` ### 8.2 Bluetooth - Uses the classic **Serial Port Profile** UUID `00001101-0000-1000-8000-00805F9B34FB`. Pair the phone with `ESP32_BT` from Android settings first, then pick it from the app's device dialog. - A background thread reads lines continuously and only keeps the **latest** line. - A monitor thread checks every 2 seconds whether the socket is still alive and shows a "disconnected, please reconnect" toast. - The connection lives inside a bound `BluetoothService`, so switching screens does not drop it. - Permissions requested: `BLUETOOTH`, `BLUETOOTH_ADMIN`, `BLUETOOTH_CONNECT`, `BLUETOOTH_SCAN`, `ACCESS_FINE_LOCATION`. ### 8.3 The recognition loop (`GestureController`) Every **300 ms**: 1. Take the latest glove line and split it into 5 integers. 2. Push it into a sliding window of the last **10** readings (so the window covers about 3 seconds). 3. Ask `GestureStabilityChecker` if the hand is still: for each finger it computes the standard deviation across the window; if any finger is above the threshold, the gesture is "in progress". 4. If stable, normalize the current reading, run the TFLite model, take the class with the highest probability, and look up its text and image. 5. Main screen shows the image and text and speaks it.  Constants (`utils/Constants.java`): ```java STABILITY_WINDOW = 10; SENSOR_READ_DELAY_MS = 300; STABILITY_STANDARD_DEVIATION_THRESHOLD = 200; STABILITY_VARIANCE_THRESHOLD = 15; // declared but not used OUTPUT_CLASSES = 13; ``` **Lesson learned:** values only go from 0 to 180, so the standard deviation can never exceed 90. A threshold of 200 means the check is **always true** once the window is full; in practice the "stability" step only adds a 3-second warm-up. A threshold around 8-15 would actually detect movement. Tune it with real data. ### 8.4 Screens - **Main (Translate):** connect button, live image of the detected sign, translated text, speaker/mute toggle (Text-to-Speech), shortcut to Text-to-ASL and history. - **Learning:** shows a random gesture and asks you to perform it. A correct sign plays a sound, turns the frame green, and moves on after 3 seconds; a wrong one turns it red. - **Text to ASL:** type text and get a strip of sign images. In word mode it first matches known phrases (hello, thank you, I love you, my name is, help, please, sorry, yes, no, eat, drink, more, pain, bathroom, stop, what, when, where), otherwise it fingerspells letter by letter (A-Z) and digit by digit. This works without the glove.  - **Gestures:** grid of the 13 gestures. You can give any gesture a **custom meaning** (for example make "Y" say "call me"), group custom meanings into **collections**, switch between them, and reset. Stored in `SharedPreferences`. - **Settings:** dark/light theme and English/French. French uses `gesture_info_fr.csv` and `values-fr/strings.xml`. - **Logs:** history of detected gestures from SQLite. Note: the line that saves logs is commented out in `GestureController`, so this screen stays empty unless you re-enable `dbHelper.addGestureLog(log)`. ### 8.5 Adding or changing gestures To add a new sign you must keep **four things in sync**: 1. Record data and add rows to `dataset.csv` with the new label. 2. Retrain with `main.py` and copy the new `gesture_model.tflite` to `app/src/main/assets/`. 3. Add a row to `gesture_info.csv` **and** `gesture_info_fr.csv` in the correct alphabetical position of the label, with an image path. 4. Update `OUTPUT_CLASSES` in `Constants.java`. If the order in the CSV does not match the label encoder order, the app will show the wrong sign for every gesture after the new one. --- ## 9. How to Run It Yourself 1. **Build the glove:** wire each flex sensor as a voltage divider into the pins in section 4.2. 2. **Calibrate:** flash a simple sketch that prints `analogRead()` for each pin; bend each finger fully and write down the max values into `maxValues`. 3. **Flash the firmware:** Arduino IDE → install the ESP32 board package → open `glove_main.ino` → upload. (Install "Adafruit MPU6050" and "Adafruit Unified Sensor" libraries if you keep the includes.) 4. **Check output:** Serial Monitor at 115200 should show lines like `12,170,175,168,160`. 5. **(Optional) Retrain:** if your readings look different from the dataset, record your own data with `datacollection.ino` and retrain (section 7). With a different glove you will almost certainly need this. 6. **Build the app:** open `codes/android/code` in Android Studio, let Gradle sync, run on a real phone (emulators have no Bluetooth). 7. **Pair and connect:** pair with `ESP32_BT` in Android settings, open the app, press connect, choose the device, and make a sign. Hold it for about 3 seconds. --- ## 10. Known Issues and Limitations | Issue | Effect | Fix idea | | :--- | :--- | :--- | | Only 13 static signs | No motion signs, no words | Add IMU + sequence model (LSTM/GRU/1D-CNN) | | Model trained on one person's glove | Poor results on other hands/gloves | Collect from many users, per-user calibration step in the app | | Stability threshold 200 is never reached | No real movement detection | Lower to ~10 and tune | | Only the latest reading is classified | Ignores 50 Hz data, more jitter | Average the window before classifying, or majority vote | | No confidence threshold | Random hand shapes still return one of 13 signs | Show "unknown" if max probability < ~0.7 | | One bad Bluetooth line marks the device as disconnected | Random disconnect toasts | Skip bad lines instead of nulling the socket | | IMU firmware sends 11 values | App crashes on parse/classify | Keep firmware and model features in sync | | Logging disabled | Empty history screen | Re-enable `addGestureLog` | | Fixed /180 normalization in app | Breaks if new data range differs | Ship scaler parameters with the model | | Leftover files (`lebronjames.png`, duplicate drawables and zips) | Bigger APK/repo | Clean up | --- ## 11. Why This Matters for SignConnect This repository is a clean, small, end-to-end example of the **hardware path** we compared in [Computer Vision vs. Hardware](?page=computer-vision-vs-hardware): - It proves that **5 numbers per frame** are enough to separate a good set of static signs with a tiny model running fully offline on the phone. No server, no GPU, no internet. - It shows the real cost of the hardware path: calibration per sensor, data that does not transfer between gloves, and the extra work needed for motion. - Its app ideas (learning game, text-to-sign, custom meanings, TTS) are directly reusable for an **Arabic Sign Language** version: swap the CSVs and images, retrain with Arabic signs, and add Arabic TTS. The app also ships a full ASL alphabet and numbers reference chart, used by the Text-to-ASL screen. It shows how far the glove still is from the full alphabet (13 of 36 shapes, and only static ones):  **Takeaway for anyone starting a glove project:** start from this pipeline, but (1) add the IMU from day one, (2) collect data from several people, (3) add a confidence threshold and a real stability check, and (4) keep the firmware, dataset, model, and app label list as one versioned unit. --- ## 12. Quick Reference | Item | Value | | :--- | :--- | | Microcontroller | ESP32 | | Bluetooth | Classic SPP, name `ESP32_BT`, UUID `00001101-0000-1000-8000-00805F9B34FB` | | Data format | `thumb,index,middle,ring,little\n`, each 0-180 | | Send rate | Every 20 ms (~50 Hz) | | App sampling | Every 300 ms, window of 10 | | Model | MLP 5 → 64 → 32 → 13, TFLite, 13 KB | | Classes | 1-9, E, I, L, Y | | Dataset | 165,734 rows | | Android | Java, minSdk 24, targetSdk 35, TFLite 2.9.0 | | Languages | English, French | *Credit: all code and data belong to the original authors of the open-source repository. This article is our own analysis for learning and reference within the SignConnect project.*