DIY Air Mouse With Media Controls

by Misfit Maker in Circuits > Gadgets

11114 Views, 71 Favorites, 0 Comments

DIY Air Mouse With Media Controls

Fully Customizable DIY Air Mouse with Media Controls | Code & Templates in Description!
Screenshot (718).png

With a tight budget and a passion for DIY, I set out to create something useful using only the components I had on hand. After a quick scavenger hunt through my inventory, I stumbled upon a gyroscope sensor, an ESP32-C3, and touch sensors from my previous builds—and just like that, inspiration struck! Why not create an air mouse with media controls? Armed with these components and a spark of creativity, I set out to build a motion-controlled Bluetooth HID device that lets you wave your way through menus like a tech wizard while enjoying seamless media controls.

But wait, there’s more! This little gadget isn’t just for TVs, computers, and Android devices—it can also drive RC cars, control robotic arms, and boss around other smart devices with smooth, motion-based input. And since I didn't have a 3D printer, I went full-on DIY and crafted the case out of foam board. But hey, if you’ve got a 3D printer, I’ve got you covered with STL and CAD files so you can print your own custom case!

You can also watch the full DIY video tutorial attached here to follow along step by step.

🔧 What’s Inside?

✅ Motion-controlled air mouse

✅ Media playback controls

✅ Fully customizable keys

✅ 3D printable enclosure files included

✅ Full code & templates included


So, what are you waiting for? Let’s build this awesome air mouse! 🚀

Supplies

Materials required for the build


Foam Board Version :

  1. 2.5 mm Foam Board
  2. Super Glue
  3. Masking Tape
  4. Carbon Fiber Vinyl Sheet
  5. Silver Spray Paint
  6. Mini Slide Switch [ Length: 8.5 to 8.6 mm, Width: 3.7 to 3.8mm, Pin Length: 3mm, Pitch: 2.54 (0.1").]( Pololu-mini slide switch / SS-SPDT-Mini-100 / ....)
  7. Copper Tape
  8. XIAO ESP32 C3
  9. MPU 6050
  10. MPR121 Capacitive Touch Sensor
  11. 3mm Led
  12. 3.7V lithium ion battery [Size : 20x20x5.5 (in mm)]
  13. Miscellaneous (Wires, soldering items, craft knife, emery paper etc.)

3D Printed Version :

  1. 3D printer and filament
  2. Carbon Fiber Vinyl Sheet
  3. Mini Slide Switch [ Length: 8.5 to 8.6 mm, Width: 3.7 to 3.8mm, Pin Length: 3mm, Pitch: 2.54 (0.1").]( Pololu-mini slide switch / SS-SPDT-Mini-100 / ....)
  4. Copper Tape
  5. XIAO ESP32 C3
  6. MPU 6050
  7. MPR121 Capacitive Touch Sensor
  8. 3mm Led
  9. 3.7V lithium ion battery [Size range : 20x20x5.5(in mm)to 25x20x6.5(in mm)]
  10. Miscellaneous (Wires, soldering items, craft knife, emery paper etc.)

Cutting the Templates

Screenshot (679).png
Screenshot (680).png

Using the given template as reference, trace its outline onto a 2.5mm foam board and carefully cut out the corresponding pieces. Afterward, we'll use super glue to assemble the parts as shown in the images.

Downloads

Touch Points for Media Keys

Screenshot (681).png
Screenshot (682).png
Screenshot (689).png

Next, we'll cut pieces of copper tape to serve as the touch points for the media keys and place them into their designated slots, as demonstrated in the images.

Wiring Up the Circuit

Misfit Media Mouse.png
Screenshot (683).png
Screenshot (684).png
Screenshot (685).png
Screenshot (686).png
Screenshot (687).png
Screenshot (688).png
Screenshot (691).png

The circuit for this build is quite straightforward. At its core, we have an MPU6050 gyroscope sensor to detect the device's orientation and an MPR121 capacitive touch sensor to function as the input keys. The Xiao ESP32-C3 microcontroller serves as the brain of the device, coordinating all the inputs and outputs.

Since both the MPU6050 and MPR121 communicate over the I2C protocol, connecting them to the microcontroller is as simple as wiring them to the SDA and SCL pins.

For the MPR121 touch inputs, I assigned the following functions:

  1. Touch 0 – Triggers cursor movement
  2. Touch 1 – Left Click
  3. Touch 2 – Right Click
  4. Touch 3 – Rewind
  5. Touch 4 – Fast Forward
  6. Touch 5 – Volume Up
  7. Touch 6 – Next Track
  8. Touch 7 – Play/Pause
  9. Touch 8 – Previous Track
  10. Touch 9 – Volume Down
  11. Touch 10 – Mute
  12. Touch 11 – Tilt-based dynamic horizontal/vertical scrolling

However, the order of the touch inputs isn’t fixed, as they can always be customized in the code. Since we’ve utilized only a few microcontroller pins, there’s plenty of room to integrate additional physical buttons to add more keys.

To power the device, I’m using a small 3.7V lithium-ion battery (Size: 20x20x5.5 mm), which provides sufficient power for extended use.

Now, with the provided circuit diagram as a reference, carefully solder all the connections to complete the assembly.

Attaching the Top and Bottom Side Covers

Screenshot (692).png
Screenshot (693).png
Screenshot (694).png
Screenshot (695).png

Next, we'll attach the top and bottom side covers to complete the enclosure. Ideally, these could have been fixed right from the step 1—but, well, I may have skipped that step! No worries, though—better late than never. Now, I’m securing them in place using super glue to give the device a sturdy finish. We’ll also use emery paper to smooth out the edges for a clean finish.

The Unnecessary LED Diffuser Experiment

Screenshot (696).png
Screenshot (697).png
Screenshot (698).png
Screenshot (699).png
Screenshot (700).png
Screenshot (701).png
Screenshot (702).png
Screenshot (703).png
Screenshot (704).png

At first, I didn’t plan on adding a dedicated LED to indicate the BLE connection status of the device. So, to check whether the device was powered on, I had this (questionable) idea of creating an LED diffuser using a 5mm LED—why I thought of that, I still don’t know! The idea was to channel the light from the MPU6050 sensor’s built-in LED instead to indicate the power ON status.

However, I’d recommend skipping this step altogether, as I’ve now included a dedicated LED to indicate both power and BLE connection status—solving the problem the right way!

Merging the Case

Screenshot (705).png
Screenshot (706).png
Screenshot (707).png
Screenshot (708).png
Screenshot (709).png
Screenshot (711).png

With the circuit complete and the case fully built, it’s finally time to bring everything together! To attach the top and bottom parts of the case, I opted for super glue. But to be honest, I wasn’t entirely happy with this method—it doesn’t allow for easy future inspection or troubleshooting if something goes wrong.

Sure, using tape could have been an option, but let’s face it—it wouldn’t look great, right? So, I took a middle-ground approach: I applied small, localized drops of super glue instead of spreading it all over. This way, if I ever need to open the case in the future, I can simply snip off these adhesive points without much hassle.

Once the assembly was complete, I gave the device a sleek finish by wrapping the top and bottom face in a carbon fiber wrap, trimming off the excess with a craft knife for a polished look.

Adding the Key Labels

Screenshot (712).png
Screenshot (713).png
Screenshot (714).png

With the vinyl wrap in place, it’s time to add the keys markings. I carefully cut out the key shapes from the tape, creating stencils for the design. Next, I applied a coat of silver spray paint over the masked areas. Once the paint was completely dry, I peeled off the masking tape to reveal the neatly imprinted key markings on the wrap.

And that’s it—the hardware is officially complete! Now, all that’s left to do is upload the code and bring this device to life. 🚀

The Code

Screenshot 2025-02-09 110907.png
Screenshot 2025-02-09 110948.png
Screenshot 2025-02-09 111009.png
Screenshot 2025-02-09 111032.png
Screenshot 2025-02-09 111046.png
Screenshot 2025-02-09 111209.png

We will be using the Arduino IDE to upload the code.

Before proceeding, make sure the ESP32 board package is installed in the Arduino IDE. To do this, go to Tools → Board → Board Manager, search for "ESP32", and install the package from Espressif Systems.

If you don’t see ESP32 in the Board Manager, add the following URL to the Additional Board Manager URLs section under File → Preferences:

🔗 https://dl.espressif.com/dl/package_esp32_index.json

Here are the libraries used in our project:

  1. Wire (Version 2.0.0) – This is a core library for I²C communication and is included by default.
  2. MPU6050 (Version 1.4.1) – Library for interfacing with the MPU6050 IMU sensor.
  3. Adafruit MPR121 (Version 1.1.3) – Library for handling the MPR121 capacitive touch sensor.
  4. Adafruit BusIO (Version 1.17.0) – Required dependency for Adafruit sensor libraries.
  5. SPI (Version 2.0.0) – Another core library, used for SPI communication, comes pre-installed.
  6. ESP32-BLE-CompositeHID (Version 0.3.0) library enables BLE HID functionality for the ESP32. To use it, you need to download the library as a ZIP file and install it manually in the Arduino IDE, as it is not available through the library search in the IDE. Click for Link:Mystfit/ESP32-BLE-CompositeHID
  7. NimBLE-Arduino (Version 2.2.1) – A lightweight BLE stack for ESP32.
  8. Callback (Version 1.1) – Used for handling function callbacks in the project.

I had trouble selecting the right library for this build, as there are a few libraries available for BLE devices. It was a bit of a tedious task to find the one that worked best. At first, I went with blackketter/ESP32-BLE-Combo, and it worked great during the initial pairing. However, after a reconnection, the media keys mysteriously stopped responding, even though the mouse keys were still fine. I initially thought the problem lay in my code, but after some troubleshooting, I decided to try a new library. That’s when I discovered Mystfit/ESP32-BLE-CompositeHID. And just like that, the issue was resolved—everything worked seamlessly, with no problems reconnecting and all the keys functioning as they should!

All you need to do now is install the necessary libraries, then download the code attached below and upload it to your device.

3D Print Files

mouse%20cad_converted (1).gif

I've also included the STL and CAD files for the device case, so those of you with a 3D printer can print the model. I've added a 0.2 mm clearance for the snap fit to ensure everything fits properly.

Your Device Is Ready to Connect

Fully Customizable DIY Air Mouse with Media Controls | Code & Templates in Description!
Screenshot (717).png
Screenshot (719).png

And just like that, you’ve built a fully functional DIY air mouse with media controls—using only a handful of components and a spark of creativity! Whether you're swiping through menus with a flick of your wrist, seamlessly managing media playback, or even exploring robotics and RC applications, this motion-controlled device opens up a world of exciting possibilities.

This project was more than just building a useful gadget—it was an exciting journey into DIY problem-solving and innovation. From designing the enclosure to troubleshooting BLE libraries, each challenge was an opportunity to learn and improve. And the best part? You can customize it to suit your needs! Since we’ve only used a few pins of our microcontroller, there’s room to add extra physical buttons if you want more functionality. To make things even simpler, I’ve included 3D print files so you can easily bring your own version to life.

If this project inspired you, don’t forget to subscribe to my channel for more exciting DIY builds. Let’s keep pushing boundaries, experimenting, and turning ideas into reality. Happy making! 🔧✨

Thank you for reading!