Below we show the detailed schematic we use for the Tilt Meter we are developing based on the MPU6050 IMU sensor.
![MPU 6050](https://toptechboy.com/wp-content/uploads/2023/09/mpu6050-1-1024x357.jpg)
This is the simple code for measuring acceleration in the x and y axis. We will develop this much further in future lessons, but this is just to verify things are hooked up correctly, and that we can measure accelleration.
1 2 3 4 5 6 7 8 9 10 11 12 | from imu import MPU6050 from machine import I2C,Pin import time i2c=I2C(0, sda=Pin(16), scl=Pin(17), freq=400000) mpu = MPU6050(i2c) while True: xAccel=round(mpu.accel.x,1) yAccel=round(mpu.accel.y,1) print('x: ',xAccel,' G ', 'y: ',yAccel,' G') time.sleep(.1) |