Esp32 Ble Gamepad
About the project
A DIY handheld Gamepad using ESP32 and Communicates over BLE
Project info
Items used in this project
Hardware components
View all
Story
1 / 4
DescriptionThis is a DIY handheld gamepad, made using ESP32 microcontroller. You might have seen such game controllers before. But most of them use Arduino. Or more specifically Arduino pro micro or Leonardo board. Because these boards support HID, or human interface devices over USB. but esp32 doesn't have such feature. So how do we do it? Well, esp32 does have BLE, or Bluetooth low energy, which we can use to communicate wirelessly, over Bluetooth.
DETAILSSo we have ESP32 module, as the central controller, then we have the USB type-C port, and a 3.3v regulator to convert 5v to 3.3v. Then we have the programming circuit, using ch340c usb to serial converter with auto programming mode and auto reset circuitry using duel transistors. We also have a battery charging circuit, along with overcharge, and over discharge protection. Which then boost up to 5v, using the boost converter ic. Next we have the joysticks, D-Pad buttons, trigger buttons, Neopixel LEDs, i2c port. And finally a 3way switch, to toggle between USB power and battery power.
The gamepad has
- 2 analog joysticks
- 2 trigger buttons
- 2 D-Pads
- 6 addressable RGB LEDs
- and a i2c port
It can run using 2 18650 Li ion cells, which can be changed using the USB type-C port. And it can also be used to program the microcontroller. The design is inspired by the new ps5 controller, to give it a better look. The GPIO4 is connected to the battery using a voltage divider. So that we can measure the battery voltage. the NeoPixel LEDs will indicates if the controller is connected to a device or battery voltage is low.
The code is based on BLE Gamepad library by lemmingDev. In the code I have defined all the GPIO pins for different inputs. Then in the setup there are some initial led animations. And as soon as the board is connected to the device, all LEDs will turn Green. And it will check battery voltage, in a time interval, which is defined earlier. Then we get the button states, and set the gamepad buttons accordingly. Then we take the analog inputs, and map it to suitable values. And finally set the axis according to the values we received. After uploading the code open Bluetooth menu on your Smartphone or PC and you will see a new device pops up. click on that to connect it and you are ready to play.
Leave your feedback...