Reviving a Dead Mouse Into a Digital Measuring Tool
by Misfit Maker in Circuits > Gadgets
73 Views, 1 Favorites, 0 Comments
Reviving a Dead Mouse Into a Digital Measuring Tool
Hi, Guys..!
What do you do with a computer mouse that has stopped working?
Throw it away? Not this time!
I had been using this mouse for the last couple of years when it eventually stopped working. For a Trash to Treasure contest, I decided to give my old, non-functional mouse a second life by transforming it into a digital measuring tool.
The final device can measure length using the mouse's rotary encoder and measure angles using an MPU6050 accelerometer/gyroscope. An OLED display shows the measurements, while an ESP32-C3 handles all the processing.
And the best part? The main body of the device is the shell of the old dead mouse!
Let's give this dead mouse a second life.
Supplies
Materials
- Scrap/dead computer mouse
- Foam board
- Masking tape
- XIAO ESP32-C3
- MPU6050
- 0.96" OLED display
- Mini rocker switch
- TP4056 lithium battery charging module
- 3.7 V lithium-ion battery/cell
- Double-sided tape
- Super glue
Tools
- Soldering iron and solder
- Hacksaw blade
- Craft knife
- Rotary tool
- Emery paper
- Set square
- Pencil
Preparing the Mouse Body
My mouse had a few broken parts, so the first thing I did was repair them using super glue.
Once the mouse body was back together, it was time to modify its shape.
The first major modification was to cut away a portion of the bottom of the mouse so that it could stand upright.
Marking the Cut
Using a set square and pencil, carefully mark the portion that needs to be removed.
THIS STEP IS VERY IMPORTANT!
The cut surface will later become the reference surface of the measuring device when measuring angles.
Measure twice. Mark carefully. Cut once!
Make sure the line is perfectly square and straight before cutting. I strongly recommend checking it at least twice with the set square before touching the hacksaw.
Cutting
Using a hacksaw blade, carefully cut along the marked line.
Try to keep the cut as straight and flat as possible.
After cutting, the surface will probably not be perfectly flat. Don't worry—we can fix that in the next step.
Leveling the Surface
Use emery paper to gradually level the cut surface.
The goal is to make the surface as flat and level as possible, so that when the device is placed on a flat surface, the reference surface sits flush against it.
Take your time with this step. A properly leveled reference surface is important for accurate angle measurements.
Making the Display Opening
I marked the required opening on the mouse housing. Then used a rotary tool to remove the material, followed by a craft knife to clean up and refine the edges.
The idea is to create a neat opening where the OLED display can sit flush with the surface of the mouse.
Tip: Remove material gradually rather than making the opening too large on the first attempt. It is much easier to enlarge an opening than to make it smaller again!
Making the Foam Board Cover
Remember the chunk we removed from the mouse earlier?
Well, now we have a rather large opening at the bottom.
I decided to make a simple cover using foam board.
Making a Template
To reproduce the shape of the opening, I used masking tape.
Stick a small piece of masking tape over the opening and carefully cut around the contour using a craft knife.
Once the contour has been cut, carefully remove the tape.
This piece of tape now acts as our template.
Stick it onto the foam board and cut around the template. And there we have it—a simple custom-made cover for the bottom of our mouse!
Preparing the Electronics
Now comes the fun part—turning the mouse into an actual electronic measuring instrument.
Since the original mouse electronics were no longer required, I removed the ICs and other unnecessary components from the original mouse PCB.
I decided to reuse the PCB as a convenient structural platform for mounting some of the new electronics.
Mounting the OLED and MPU6050
The OLED display and MPU6050 were fixed to the PCB using double-sided tape.
However, I ran into a small problem.
I could not mount the MPU6050 completely flush with the PCB because of the other components and physical obstructions inside the mouse.
So instead, I cut a small piece of foam board and glued it perpendicular to the PCB.
The MPU6050 could then be mounted onto this foam-board support using double-sided tape.
Mounting the TP4056
The TP4056 charging module was then glued to the foam-board bottom cover that we made earlier.
Wiring Everything Together
Now it's time to connect all the electronics.
The main controller is the Seeed Studio XIAO ESP32-C3. It reads the mouse encoder for length measurement and the MPU6050 for angle measurement, while the OLED provides the user interface.
Connect the components according to the circuit diagram attached above.
Once everything is connected, carefully check all the connections before powering the circuit.
Pay particular attention to:
- Power and ground connections
- I²C connections to the OLED and MPU6050
- Encoder connections
- Switch connections
- Battery and TP4056 connections
Once you've checked everything, we're ready to program the device!
Programming the ESP32-C3
Now it's time to bring our recycled mouse to life!
Download the code attached below, Connect the XIAO ESP32-C3 to your computer and upload it to the ESP 32-C3.
Before uploading the program, make sure the required Arduino libraries are installed.
The code uses:
- Arduino.h
- Wire.h
- Adafruit_GFX.h
- Adafruit_SSD1306.h
Select the appropriate XIAO ESP32-C3 board in the Arduino IDE, connect the board through USB and upload the program.
Downloads
Calibrating the Length Measurement
This is a very important step.
Instead of calculating the measurement using the wheel diameter and encoder resolution, I calibrated the device using a known physical distance.
This makes the calibration compensate for several real-world factors, including:
- Actual wheel diameter
- Encoder resolution
- Wheel compression
- Small mechanical differences
- Other systematic errors
How to calibrate
Choose a known distance.
For example:
Known distance = 1000 mm
Place the measuring tool at the starting point and roll it exactly 1000 mm.
Record the encoder count.
For example, suppose the encoder records:
1847 counts
The calibration value is:
MM_PER_COUNT = 1000 / 1847
Therefore:
MM_PER_COUNT = 0.54142 mm/count
The code contains a single value that needs to be changed:
Replace the existing value with your calculated value and upload the program again.
The angle measurement works differently.
The MPU6050 uses gravity as its absolute reference. The software calculates the left/right tilt using the sensor's Y-axis.
This means that when the device is placed level, the absolute reference is:
0° = Level
The software also applies filtering to make the displayed angle more stable and prevent the numbers from constantly jumping due to tiny sensor fluctuations.
Relative angle
Sometimes you don't want to measure the angle relative to gravity.
For example, imagine you have an object that is already sitting at 25°, and you want to check whether another surface has the same angle.
Simply place the measuring tool on the reference surface and short-press the zero button.
The current angle becomes the temporary 0° reference.
You can then measure the difference between the reference surface and another surface.
Returning to absolute zero
If you want to return to the normal gravity-based measurement, long-press the same button.
The display will return to the absolute gravity reference.
Using the Device
The device has two measurement modes:
LENGTH MODE
Measures the distance travelled by rolling the mouse encoder.
Switch 1 operation:
- Short Press → Zero Length
- Long Press → Toggle CM / INCH
ANGLE MODE
Uses the MPU6050 to measure the inclination of the device.
Switch 1 operation:
- Short Press → Set Current Angle as Zero
- Long Press → Return to Absolute Gravity-Referenced Zero
Switching Between Modes
PRESS SWITCH 2 TO TOGGLE BETWEEN
LENGTH ↔ ANGLE
The Build Is Complete!
And that's it!
We've taken a dead computer mouse that was destined for the trash and turned it into a completely different tool—a digital length and angle measuring device.
What started as a broken mouse is now something that can actually be useful in the workshop.
With this build, we've given our dead mouse a second life.
Now let's see how long it survives this time!
Hope you enjoyed reading this Instructable, and maybe this gives you an idea to look at your own "dead" electronics a little differently.
Happy Making!
— Misfit Maker