DEV Community

Cover image for This ESP32 Reaction Wheel Cube Lands and Balances on One Edge
circuitrocks
circuitrocks

Posted on Originally published at blog.circuit.rocks

This ESP32 Reaction Wheel Cube Lands and Balances on One Edge

How does a five-inch black cube jump off a table, land on a single edge, and stay balanced there?

That is the effect The Tinkering Techie built, and the point is that your brain refuses to accept it. Toss a D6 on a table and you already know it will tumble and settle flat on a face. This cube goes up, stops rotating mid-flight, comes down on one edge, and holds. It lands on the same edge every time, which is the first clue that something inside is steering it.

So what is actually happening?

Inside the shell sits a self-balancing robot. A reaction wheel spins up to produce torque on the body without pushing against anything outside it, the same principle that lets satellites reorient in vacuum. Spin the flywheel one direction and the cube rotates the other. While airborne, the wheel corrects the cube's attitude so it arrives edge-down instead of face-down. The moment it touches the table, the controller switches jobs and starts making constant micro-corrections to hold the balance point. The only other moving part is a spring-loaded piston that a second motor winds back between launches.

What is on the board

The Tinkering Techie laid out a custom PCB around an ESP32, a dual-core chip running at 240 MHz. That headroom matters, because the balance loop and the motor commutation both want CPU time on the same part. An IMU supplies 6 axes of motion data (3 accelerometer, 3 gyro), and a BLDC motor drives the flywheel under SimpleFOC firmware. A lithium pack powers everything. Field-oriented control running at a few kHz is what turns raw tilt readings into a wheel that pushes back against a fall faster than you can see it happen.

Try a smaller version first

Balancing a cube on one edge is a single-axis problem, so you only need one wheel to replicate it. Skip the launcher, build the balancer: an ESP32, an MPU6050 on I2C, and a gimbal BLDC with a bolted-on brass flywheel. On a standard ESP32 dev board, SDA lands on GPIO21 and SCL on GPIO22, and most MPU6050 breakouts already carry their own 4.7k pull-ups, so adding a second pair is the usual gotcha that kills the bus. Get the IMU streaming clean angles before you ever energize the motor. Read the SimpleFOC setup guide at docs.simplefoc.com, then watch the cube in action on Hackster.


Originally published on blog.circuit.rocks.

esp32 #esp8266 #iot #wifi #circuitrocks

Top comments (0)