Below we show the detailed schematic we use for the Tilt Meter we are developing based on the MPU6050 IMU sensor.

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 13 14 15 16 17 18 19 20 21 22 23 |
# ==================================================================== # DISCLAIMER: # This code is provided as-is for educational and experimental # purposes only. The author makes no representations or warranties of # any kind concerning the safety, suitability, or accuracy of this # code. Use at your own risk. The author assumes no liability for any # damages, system failures, security breaches, or network issues # resulting from the use or implementation of this script. # ==================================================================== 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') ts=.1 time.sleep(ts) |