Smart Glove for interpreting ASL (Sign Language) alphabet

Author: Andrei-Alexandru Georgescu
Group: 332-CD

Introduction

The intent is to make a hand-worn device that uses several sensors to internally store the position of each finger, as well as orientation measured with a gyroscope, and then using this data to interpret, based on set of logistic regressions, a corresponding letter according to the ASL standard alphabet.
The ML based interpretation of the gestures makes the device highly personalizable, as it could be trained for a specific individual's range of motion and manner of making the gestures.
Its primary and intended purpose is to interpret gestures, but it can also be used, once trained, in an educational fashion as it uses an LED to signal if the gesture is recognized.

General description


An important part of the project's logic is based on the 6 IMUs used. One is the “Reference Sensor” and it is mounted on the wrist such that it doesn't much experience the rotational movements of the hand. The other 5 are each mounted on a fingertip and all funnel their outputs towards the controller through an I²C multiplexer. The microcontroller is going to in turn request data from each of the sensors over the I²C line, and use the values to determine the position of each fingertip relative to the wrist.

The intended function of the project has 2 possible running modes, which determine how the positional data is used:

  • Learning Mode - In Learning Mode, the expectation is that the controller is connected to a companion computer that deals with the mathematical computation of the regression weights. It is also in this mode that the connected button is intended to be used, serving as a snapshot “trigger”, recording the data at the pressing moment and sending it over USART to the companion for processing.
  • Interpreting Mode - In Interpreting Mode, the expectation is that the controller has been pre-loaded with the necessary weights from a prior learning session. Here the positional data is used to sequentially calculate the “probability” of the gesture being associated to known symbol, interpreting the gesture to be the symbol with the highest “probability”, but only if it passes a minimum threshold of 80%. While a value is interpreted as known, a green led is active and internally a clock is started. If the guessed position is still the same after a half a seconds has passed, the interpretation is considered valid and written over I²C to the LCD. In Interpreting Mode, the connected button is instead used to clear the LCD screen of prior written content.

Hardware Design

Components:

Conexions: In my project I used the following color coding:

  • For Power & GND (twisted together) I used the pairs Red/Black and Orange/Grey
  • For Data/Clk (also twisted together) I used the pairs Yellow/Brown, Blue/White and Green/Purple
  • This format allowed me to get 6 distinct pairing of Power/GND/Data/Clk, one for each of the sensors, for easier distinction!

The Pins used are as such:

  • The whole system is powered directly or indirectly from the 5v supplied by the Micro-USB
  • SDA - D21
  • SCL - D22
  • LED Control - D26
  • Button Control - 14
  • 3v3 to power the IMUs
  • VIN as a 5v output to power the LCD and TCA9548
  • RST on the TCA9548 is connected to 5v (VIN) over a 4.7k resistor
  • SDA and SCL are connected to 3v3 over 4.7k resistor each
  • The SDn and SCn (outputs of the multiplexors) do not require pull-up resistors as those exist internally on the IMU breakout boards
  • The LED is connected to its Control Pin through a 200 resistor.
  • Thumb sensor is connected to line 7 (SD7, SC7)
  • Index sensor is connected to line 6 (SD7, SC6)
  • Middle sensor is connected to line 5 (SD7, SC5)
  • Ring sensor is connected to line 4 (SD7, SC4)
  • Pinky sensor is connected to line 3 (SD7, SC3)
  • Reference sensor is connected to line 2 (SD2, SC2)

Physical Wiring:

Software Design

Development Medium: Arduino IDE Libraries:

  • Wire.h - For I²C communication.
  • LiquidCrystal_I2C.h - For controlling the LCD over I²C.
  • math.h - For the mathematical functions required for inference.
  • MPU6500_WE.h - For controlling the IMUs used and polling them for data.

Algorithms and Datastructures:

  • Multinomial Logistic Regression/Softmax Regression - Using sklearn in Python on the companion / math operation locally on the ESP32
  • Wrapper Class over MPU6500
  • Wrapper functions over Wire for using TCA9548
  • Wrapper functions over Wire and LiquidCrystal_I2C for communicating with the LCD1602

Implemented Functions:
TCA9548 Functions:

  • init - to be called during setup, activates the I²C connection
  • tca9548_select - sets the TCA9548 multiplexor to channel i, provided that i is a valid channel (0 to 7)

MPU6500 Functions:

  • Constructor - makes the MPU6500 library object and memorizes the TCA9548 channel it is on
  • init - to be called by setup, launches the IMU into autocalibration and configures it for maximum precision
  • get_data - to be called inside the loops, makes sure the communication is over the correct TCA9548 channel and fetches current angular data

LCD1602 Functions:

  • lcd1602_init - to be called during setup, initializes the LCD and turns on the backlight
  • lcd1602_write_char - writes a character at the specified position, provided that position is valid
  • lcd1602_write_char - writes a character at the current cursor position
  • lcd1602_write_string - writes a string at the specified positon
  • lcd1602_set_first_row - moves the cursor to point at the begining of the first row
  • lcd1602_set_second_row - moves the cursor to point at the begining of the second row
  • lcd1602_test - displays a basic text for testing purposes
  • lcd1602_clear - clears the text from the LCD and sets the cursor to point to 0, 0

Interpreter Functions:

  • make_score - for a given row, calculates the score as the bias of said row + the sum of all input values with the coresponding weights
  • softmax - determines the class with the highest probability and yields both it and the probability, after calculating using the Log-Sum-Exp Trick.
  • classify - yields the class the data was classified to if the probability of it being corect is above 80%, otherwise yielding -1 (gesture not recognised)
  • translate - converts the input x into an apropriate letter

Main Functions:

  • handleButtonInterrupt - the interrupt function that toggles when a button is pressed. Debounces digitialy
  • perpare_lcd - to be called during setup, initialises and tests the lcd
  • prepare_glove - to be called during setup, warns the wearer to sit still before launching into sensor initailisatian and callibratian
  • seek_i2c_connections - unused dev function, used for verifying I²C connectivity through the TCA9548 multiplexor
  • setup - initialises the serial communication stream, the multiplexor and lcd, then the senors. Configures pins for the connected led and button. Finally, if in recording mode, prints the csv header to the serial line
  • print_angles - to be used in recording/learning mode, prints to the serial the data from a sensor
  • record_loop - waits for the button to be pressed, printing a snapshot of the position the serial line in csv data format
  • read_angles - to be used in interpreting mode, reads the data from a sensor to a float array buffer
  • interpret_loop - reads data from the sensors, then classifies it, interpreting gestures held for at least 2 seconds depending on their value: -1 as a non-recognised position, 0 to 25 as letters 'A' to 'Z', 26 as “move cursor to first line of LCD”, 27 as “move cursor to second line of LCD” and 28 as “clear lcd”. While detecting a gesture it doesnt know, the LED is of, while it is detecting a gesture it knows, the LED is on
  • loop - runs either record_loop or interpret_loop, based on the hardcoded FUNCTION_MODE currently set

Results

The overall result is a system that can be configured for either gesture interpretation or gesture learning. Functionally the ESP32 used could learn even more complex or larger matrices to continue using multionomial regression for more potential classes, learning new gestures that don't strinctly have to me mapped onto a character. The ESP32 has bluetooth/wifi functionality so it is completely plausible to modify a system like this to interact with smart devices by issuing commands. The choice to interpret sign-language is arbitrary. For my current learning set (30 entries for each gesture) inference analysis yields great results:

  • Average precision - 0.98
  • Average recall - 0.98
  • F1-score - 0.98
  • Accuracy - 0.98
  • (PS. I know it looks odd that they are the same, but this is the result as calculated my sklearn's script)

Conclusions and Lessons

  • Not a final conclusion really, but I realised half-way through development that I bought MPU6500 instead of MPU6050s like originally intended, which is a lesson to read more clearly when buying parts, I suppose.
  • Sometimes, the breakout schemes of the various components have diagrams that just actually lie, the TCA9548A for example was supposed to have its own pull up resistors, but I needed to at my own.
  • Positional tracking is difficult to realise with 6DOF systems, I was able to salvage my idea only because hand gestures have limited freedom of movement, but Z-rotation instability ruins any attempts at keeping a valid virtual Oxyz coordinate system.
  • I know it is minimal in effect, but I think solidly color coding my wiring by function may be the single best decision I made during the project.
  • LCD factory settings set contrast to 0, took a while of code/verify/upload cycles before I realised that one.
  • Always check if cables you buy are data-capable.
  • Although it worked for this project, sensors with pins going out like the ones I am using are cumbersome due to their volume occupied blocking natural finger positions. Same issue with the wiring being to long. I think using hard wires might've possibly been more beneficial in retrospect.
  • Avoid using textiles as a base support for projects, I had to sew my sensors in with thread and use a zip tie to position the breadboard because nothing was sticking.

Code Repository

Available here!

pm/prj2025/iotelea/ageorgescu2407.txt · Last modified: 2025/05/28 10:50 by ageorgescu2407
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0