Skip to content

imsudoer/cyberhand-prototype-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cyberhand Prototype 1

This project is a prototype of a "Cyberhand" - a wearable device that functions as a Bluetooth mouse. It uses an MPU6050 gyroscope to track hand movements and translate them into cursor movements on a connected computer.

Cyberhand glove pic glovepic

🛠️ Features

  • Wireless Connectivity: Utilizes Bluetooth HID (Human Interface Device) to connect as a standard mouse.
  • Motion Tracking: The MPU6050 sensor measures angular velocity to detect hand movements.
  • Click Functionality: Dedicated buttons for left, right, and service clicks.
  • Drift Correction: Basic anti-drift logic to prevent unwanted cursor movement when the hand is still.
  • Battery Monitoring: Includes a pin for monitoring the battery level.
  • Task Management: Uses FreeRTOS tasks for efficient and parallel processing of sensor readings and button states.

⚙️ Hardware Components

  • ESP32 Microcontroller: The core of the device, handling Bluetooth communication and processing.
  • MPU6050 Gyroscope & Accelerometer: For capturing motion data.
  • Buttons:
    • BTN_L (Pin 32): Left mouse button
    • BTN_R (Pin 33): Right mouse button
    • BTN_S (Pin 25): Service button
  • Battery: Connected to BATTERY pin 27 (Analog) for monitoring.
  • LED (Pin 2): Status indicator for Bluetooth connection.

💻 Software

The code is written in C++ for the Arduino framework (usind PlatformIO), designed to run on an ESP32.

Key Libraries

  • BleMouse.h: Enables the ESP32 to act as a Bluetooth mouse.
  • MPU6050.h: Interface for the MPU6050 sensor.
  • Wire.h: For I2C communication with the MPU6050.
  • FreeRTOS (built into ESP32 Arduino core): Used to create separate tasks for reading button inputs and processing gyroscope data concurrently.

Task Breakdown

  • setup(): Initializes hardware components, Bluetooth, and creates the FreeRTOS tasks.
  • loop(): Manages the Bluetooth connection status and handles button presses and releases. It detects state changes (from pressed to released, and vice versa) to send appropriate signals to the computer.
  • gyroTask(): This task runs continuously in the background. It reads data from the MPU6050, performs calculations to correct for sensor orientation and convert the data into X and Y cursor movements, and then sends the movement commands via Bluetooth. An anti-drift filter is applied to ignore small movements.
  • readerTask(): This task constantly reads the state of the physical buttons and updates the corresponding variables.
  • calibrateGyro(): A utility function used for calibrating the gyroscope's initial zero-point to improve accuracy.

💡 How it Works

The gyroTask is the heart of the motion tracking. It reads raw gyroscope data (gx, gy, gz). These raw values are then mathematically corrected to align with the desired cursor movement axes. The corrected values are scaled by MOUSE_SPEED to adjust cursor sensitivity. A small threshold check (abs(moveX) > 5 || abs(moveY) > 5) is implemented to prevent the cursor from drifting when the device is not in motion.

About

Experimental project with ESP32 & MPU-6050

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages