ESP-32 Based BLE Mouse With Magnetic Mouse Pad
Introduction: ESP-32 Based BLE Mouse With Magnetic Mouse Pad
This instructable is about building an esp32 based BLE mouse, unlike using the traditional method to build a mouse using optical sensors, this mouse works based on magnets embedded in a custom 3d printed mouse pad.
Make sure to read until the end of the article to know how this mouse is built from scratch and also learn how to navigate the magnetic surface using just a single magnetic pole and with a bunch of hall effect sensors!
Supplies
These are the list of products that can help you do this project with ease
(Affiliate Link)
3d printer: https://amzn.to/3trVWKw
printer upgrades: https://amzn.to/3hbK3Ga
Orange filament: https://amzn.to/3DbhpxG
Esp32: https://amzn.to/2XwQBIf
hall effect sensor: https://amzn.to/3hHz0UL
Magnets: https://amzn.to/3nMO47l
Perfboard:https://amzn.to/3EyIV8M
18650 Cell holder:https://amzn.to/3lGFsMH
18650 Cell:https://amzn.to/2Zb9Vv0
Push buttons: https://amzn.to/3EvvC9g
SMD capacitor and resistor kit:https://amzn.to/3CqQmNz
Buttons : https://amzn.to/3lDTij1
cp2102 : https://amzn.to/3hPc4CX
Tp4056 : https://amzn.to/3nHskK6
Step 1: How an Optical Mouse Work?
First, let’s talk about how the traditional mouse works.
If you take a look at the bottom, you may have noticed a flashy red light blasting from the mouse. This is the light that the optical sensor inside the mouse use determines the motion. But how does it work?
Initially, when I thought about it, I thought it would be something like the IR sensor used in the line follower bot or maybe a little bit more complicated like a LED and array of and Light sensors within an IC and finally maybe some fancy algorithm to detect the motion.
But when I heard the working for the first time, I was mind blown by the technology that is used. So, Let me spoil it if you haven’t already heard about it.
more info
Step 2: Inside an Optical Mouse
If you break open the mouse you can see an IC with a small notch on the bottom and this is the casing for the camera, When you compare it to the actual camera this capture way too little detail. Because this was not meant to take pictures of people and cats, it was made to take pictures of patterns and tiny grooves on the surface where the mouse is used. Once it takes the picture it applies an algorithm called optical flow, which determines the direction of the mouse by comparing the frames of images it has taken in a continuous motion.
This really amazed me, because for the optical flow algorithm to detect which way the camera is moving the 2 consecutive frames has to be very close by. If they are far away the algorithm just doesn’t work that well. 832
Because of this reason, the mouse optical sensor has to capture almost 2000 to 6000 frames per second. Which is far faster than the smartphone camera. So, From now on you can consider yourself a high-speed camera operator when you are a mouse.
Step 3: Replacement for Optical Sensor - Failure
So, to start with the project. My initial idea was never to use magnets.
I just wanted to build a BLE Bluetooth mouse, But while designing the mouse, I soon ran into the problem of finding the Optical sensor. It was not cheap and the most familiar one to the Arduino community is now obsolete.
So my genius brain thought I could build an optical sensor using the ESP32 CAM. I would have been really happy even if I could at least get some decent frame rate, so I could change the lens of the ESP32 CAM and make a very slow/less responsive mouse. But after playing with ESP32 CAM for a while, I decided it was a very bad idea to start with ESP32 CAM.
The major reasons why ditched ESP32 CAM:
* ESP32 CAM was unreliable in capturing high frame rate photos, the max I could push was 24 with very low resolution.
* The second reason was the optical flow algorithm wouldn’t quite work well and crash the esp32 multiple times.
* Finally, most esp32 cam comes with the lens locked to the sensor with super glue.
Step 4: Magnets!!! 382