Simulator

An MPU6050 accelerometer simulator you tip by hand

Mokxi is a free online accelerometer simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno reads an MPU-6050 over I2C with nothing but the Wire library and prints its raw acceleration, temperature and rotation twice a second. Tip the board on the canvas and gravity moves from one axis to the next.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: MPU-6050 readings over I2Clive0.000 s 0.00x
Click to open it in the editor
Drag the sensor board to tip it, or click anything else to open it in the editor.

What you can do here

In the circuit above, or in the editor it opens.

  • Read the MPU-6050’s raw registers with Wire
  • Tip the board in pitch and roll and watch X, Y and Z share gravity
  • Turn the readings into an angle, as the tilt meter project does
  • Watch the gyroscope move only while the board is moving
  • Try an ADXL345 or an analog ADXL335 instead
  • Build a balancing robot on the same sensor

What the running circuit shows

An accelerometer at rest measures gravity.

The MPU-6050 wakes up asleep, so the sketch first writes 0 to its power register, 0x6B. After that, fourteen bytes starting at register 0x3B hold three accelerations, the temperature and three rotation rates, each a 16-bit number sent high byte first. On the default ±2 g range, 1 g is 16384 counts.

In the engine the board starts flat and the serial monitor reads AcX = 0, AcY = 0 and AcZ = 16384: all of gravity on Z. Tip it 30 degrees in pitch and X takes half of it, AcX = -8192, while Z falls to 14189, which is 16384 times the cosine of 30 degrees. Roll it 90 degrees as well and Z drops to 0 while Y takes the 14189. The temperature reads 25.0 °C, the part’s setting.

How the sensor is modeled

The register map, the ranges and the sleep bit.

The MPU-6050 part answers at I2C address 0x68, or 0x69 with AD0 pulled high, powers up asleep, and returns its readings from the registers the datasheet names, scaled by the range a sketch picks for the accelerometer and the gyroscope. WHO_AM_I reads 0x68 whichever address it is on, as on the real chip. The gyroscope reads how fast the board is being turned, so it sits at 0 at rest and moves only while you drag.

What it leaves out: a real MPU-6050 has offsets and noise to calibrate away, which is half the work of a real project, and here a flat board reads exactly 0 on X and Y. There is no yaw to drag on a flat canvas, so the Z gyro always reads 0, and there is no magnetometer on this chip to find north.

How it works

Three steps from a blank tab to a running circuit.

  1. Open the editor

    It runs in your browser tab. Nothing to install, and you need no account to start.

    Your first project
  2. Wire it and write the code

    Drag parts onto a breadboard, run each wire from pin to pin, and write the sketch beside it.

    Wiring
  3. Press Run

    Your sketch compiles in the tab and runs on a model of the chip, with the Serial Monitor beside it.

    Run and serial
Reviews

What makers say about Mokxi.

“The AI checker helps check and correct my circuits, and it has way more components than Tinkercad. As a student I really appreciate the tool.”

ChloeEngineering student

“I’d been looking for a real online electronic simulator that was intuitive and complete when I found Mokxi. I was able to quickly import a Fritzing file and my Arduino sketch and start testing. Mokxi has all of the makings for the best online Arduino simulator I have been able to find!”

JayModel builderFeatured in his DioramaOS post

“I’m using Mokxi to develop and simulate an STM32-based four-wheel-drive robot car before building the actual hardware. It allows me to experiment with DC motor control, PWM, RPM measurement using photointerrupters, and different acceleration, braking, and reversing strategies, helping me understand and refine the system before implementing it in real life.”

NusretRobot car builder, Hamburg

Share your story

FAQ

Questions, answered.

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

How do I get an angle from an MPU6050?

At rest, the angle is the arctangent of two acceleration axes: pitch from X against Z. Tipped 30 degrees, X reads -8192 and Z 14189, and the arctangent of 8192 over 14189 is 30 degrees. The tilt meter project works it out on the Uno.

Does it need an MPU6050 library?

Not this sketch: it uses only Wire, so every register it reads is in view, and the same sketch runs on a real Uno with a GY-521 board.

Which accelerometers can I simulate?

The MPU-6050 on its GY-521 board, the ADXL345 on I2C and the analog ADXL335, among the sensors in the parts bin.

More simulators

Each one opens on a circuit that is already running.

Tip a sensor

Open the circuit, tip the board and press Run. Nothing to install, and no account needed.