Source: https://mokxi.com/accelerometer-simulator

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.

Start building free or see the MPU6050 part

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

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.

MPU6050 with Arduino I2C, explained The servo simulator The LCD simulator

## Questions

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.

Online circuit simulator Breadboard simulator ESP32 simulator Op-amp simulator Logic gate simulator LED circuit simulator Servo simulator LCD simulator OLED simulator NeoPixel simulator 7 segment display simulator LED matrix simulator Stepper motor simulator Motor driver simulator Ultrasonic sensor simulator Rectifier simulator Digital circuit simulator Potentiometer simulator PWM simulator Relay simulator Shift register simulator DHT11 simulator RFID simulator RGB LED simulator Buzzer simulator MOSFET simulator Circuit simulator for kids Flip-flop simulator Multiplexer simulator Full adder simulator I2C simulator UART simulator Thermistor simulator PIR sensor simulator Oscilloscope simulator Multimeter simulator DC motor simulator Traffic light simulator Diode simulator Capacitor simulator Series and parallel circuit simulator Wheatstone bridge simulator Voltage regulator simulator Soil moisture sensor simulator Zener diode simulator Solar panel simulator AC circuit simulator Thevenin simulator Decoder simulator Encoder simulator PID simulator Robot arm simulator Load cell simulator IR sensor simulator LM35 simulator HC-05 Bluetooth simulator nRF24L01 simulator

## Tip a sensor

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

Start building free Open the editor
