This Special Mouse Only Needs an ESP32 and IMU to Move the Cursor

By replacing the trackball or optical sensor with an IMU and ESP32-S3, Clem Mayer's mouse can be used on any surface — or none at all!

Evan Rust
6 months agoSensors / 3D Printing / Productivity / HW101

Optical sensors to IMUs

Mice have undergone a drastic evolution ever since they were first introduced to the world in the late 1960s. The jump from a physical trackball that spun internal rotary encoders to optical sensors that take hundreds or thousands of pictures per second led to much better precision and speed. It was this same spirit of innovation that inspired element14 Presents host Clem Mayer to build a mouse which would require zero outside interactions and let it be used anywhere — even mid-air.

The concept originally involved adding an MPU6050 6-axis accelerometer and gyroscope chip to a PCB along with an ESP32-S3. Then, the IMU's acceleration values could be used to determine the mouse's position on a 2D plane or within a 3D space in a later iteration.

PCB design and assembly

With the project now thoroughly planned out, Mayer's next task was to design the PCB that his mouse's internals would live on. At its core is an ESP32-S3 module with built-in Bluetooth Low-Energy/WiFi connectivity and a fast processor for deriving the current position from acceleration readings. Because the mouse contains an onboard LiPo battery for wireless operation, a USB-C connector and battery charge management circuit were both included to facilitate safe charging. Lastly, the MPU6050 IC communicates with the ESP32-S3 via the I2C bus and two external pushbutton switches act as the left and right-click inputs.

Once the board had been pasted and reflowed, Mayer attempted to get a reading from the MPU6050 but only received the value zero from it. After some research, he realized the chip's failure was due to his use of an ultrasonic PCB cleaning machine that damaged the delicate MEMS circuitry from repeated hits with high-intensity sound waves, thus necessitating a replacement.

The challenge of deriving positions

At first thought, getting the position from an IMU sounds easy, since the IMU measures the motion which can then be correlated with an updated position. However, the MPU6050 has an accelerometer which measures accelerations, not velocity, meaning that some very complex math is needed, namely, taking an integral of an integral several times per second. He did manage to find some working code, but this led to either no motion or very large, jittery movements across the screen causing an unusable experience.

A rethink

The troubles with determining positions within a 2D plane based solely on a single IMU caused Mayer to reflect on how he could pivot away from the concept to a different mouse style. With traditional optical mice and trackpads out of the question, he reached for his Thinkpad laptop and realized it has the red "nub"-style mouse in the center of the keyboard. And because the nub mouse relies on small adjustments to a relative position, it was perfect for the IMU since finding the Euler angles (roll, pitch, and yaw) is relatively simple. His new design looks like a large red dot that can be rolled mid-air to nudge the cursor across the screen.

Using the mouse

While at the laptop, a normal mouse works just fine, but when it came time for Mayer to finish his video, he found a very helpful application. Due to the fact that he uses a phone as his live preview monitor, the mouse allowed him to easily control the camera settings wirelessly over Bluetooth. To see more about how this project was designed and built, you can watch Mayer's video here on YouTube.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles