The M5Stack Capsule v1.1 standing upright, its colourful pin label facing forward and the USB-C port at the bottom
Back to projects
Internship project

3D CAD Mouse

I turned an M5Stack Capsule into a wireless 3D mouse for Onshape. You click its button and turn it in your hand, and the model on the screen turns with it, as if you were holding the part itself.

Built with
ESP32-S3PlatformIOOnshape

Internship project at M5Stack, November 2026. M5Stack Capsule v1.1, Bluetooth LE, C++.

Demo

I filmed this at my desk with one of my enclosures open in Onshape. With rotate on, the part turns and tips as I turn the Capsule, and holding the button lets me slide the part across the screen and zoom in on its buttons.

Try it

This is the case from the demo, the one I designed for my LoRA Messenger, and it is the same model I had open in Onshape. Drag it and it turns the way it does when I turn the Capsule, while the Capsule beside it shows what my hand and its button would be doing.

Loading the case

In this viewWith the Capsule

  • DragDrag with one fingerClick the button, then turn your hand
  • Right-drag or Shift-dragDrag with two fingersHold the button and point the Capsule
  • ScrollPinchHold the button and twist
  • Double clickDouble tapDouble click the button

The real Capsule measures how fast your hand turns, so the part turns through the same angle your hand did. Here your drag stands in for that.

How to use it

You hold the Capsule upright with its label facing you and the USB port at the bottom, and its one button does everything.

  • Click to rotateA click turns rotate on, and the light turns cyan. From then on the model follows your hand until you click again. Rotate starts 0.3 seconds after the click, which is how long it waits to rule out a double click.
  • Hold to pan and zoomHolding the button pauses rotate and pans instead, with the light amber. Pointing the Capsule left, right, up or down slides the model that way, and twisting it zooms. Rotate picks up again when you let go.
  • Double click to fitA double click fits the whole model on the screen, and rotate stays as it was.

The light breathes blue while it waits for a computer and blinks green every few seconds once it is connected. A high tick means rotate is on and a lower one means it is off, and the Capsule switches itself off after a long time unused.

How it works

The Capsule has a gyroscope and an accelerometer in its IMU, a button and Bluetooth, which is everything a 3D mouse needs. The hard part was getting Onshape to listen to it.

Passing as a SpaceMouse

Onshape only takes 3D mouse input through the driver from 3Dconnexion, the company that makes the SpaceMouse. So the Capsule introduces itself over Bluetooth as their SpaceMouse Wireless, with that model’s IDs and the same layout for its reports, and the driver does the rest. Nothing has to be installed inside Onshape. I built the Bluetooth side on the code from an air mouse I had made earlier, which already worked with both Windows and macOS.

Following your hand

A real SpaceMouse reports how far you push its cap, and the driver turns that into speed. The Capsule sends how fast your hand is turning instead, from its gyroscope, so the driver turns the model through the same angle your hand turned. It feels like holding the part rather than steering it.

The accelerometer only works out which way is down. That keeps the axes level however you grip the Capsule, so turning it about the vertical always spins the model about the screen’s vertical. I didn’t use it to move the model, because a position worked out from an accelerometer drifts away within a second, which is why panning comes from pointing the Capsule instead.

Stopping cleanly

Pressing the button freezes the output straight away, so the jolt of your thumb and your hand coming to a stop never reach the model. While your hand moves, the Capsule sends a report 62.5 times a second, like the real SpaceMouse. When it stops, it keeps sending zeros until three have gone through, because a lost last report would leave the model spinning, and then it goes quiet.

The motion maths and the button gestures sit in one library with no hardware code in it, so 19 unit tests check them on a computer before each flash.

Hardware

  • M5Stack Capsule v1.1is the whole thing, with nothing added. Its ESP32-S3 runs the firmware and the Bluetooth, its BMI270 IMU reads the gyroscope 200 times a second, and its RGB LED and buzzer give the feedback.
  • The buttonon top of the Capsule does all three gestures.
  • A 250 mAh batteryinside keeps it wireless, and it powers itself off when it hasn’t moved for a while.
Holding the Capsule in front of the monitor while the enclosure in Onshape turns with it
Turning the enclosure in the demo

Setting one up

  1. Install 3Dconnexion’s free driver, 3DxWare, on your computer. It includes the part that lets Onshape in the browser listen to a 3D mouse.

  2. Flash the firmware onto a Capsule v1.1 with M5Burner. It isn’t on M5Burner yet, so this step is coming soon.

  3. Open your computer’s Bluetooth settings and pair Capsule CAD Mouse. It chirps when it connects.

  4. Open a model in Onshape, click the button and turn the Capsule.

I have only tried it in Onshape so far. Other programs that take a SpaceMouse through 3DxWare should work the same way, but I haven’t tested them yet, and I haven’t measured how long the battery lasts.

More to explore

Other projects

Personal
OCR Reader with DrumNet, an OCR water meter solution

OCR Reader

A battery-powered water meter reader where a 693K-parameter DrumNet pipeline on an ESP32-S3 reads the drums and reports over LoRaWAN, built on a custom KiCad PCB inside a 3D-printed shell.

Personal
Project June rover

Project June

A 5G rover with three live camera feeds, GPS, a laser pointer and seven sensors, driven from a web console.

Internship
Pip, a cyan desk pet, on the M5Stack Tab5

Pip

A desk pet on an M5Stack Tab5 whose brain is the DeepSeek Harness on my server, so it can drive a browser, build its own apps and watch my other agents.