This is a placeholder topic for “MPU-6050 Module 3 Axis Gyroscope + Accelerometer” comments.
A 3-axis gyroscope and 3-axis accelerometer housed on a development board ready for prototyping.
Read moreThis is a placeholder topic for “MPU-6050 Module 3 Axis Gyroscope + Accelerometer” comments.
A 3-axis gyroscope and 3-axis accelerometer housed on a development board ready for prototyping.
Read moreI think the first line of the MicroPython example should be
from imu import MPU6050
Hey @Jan282683, welcome to the forums!
Looks like that example code is a little outdated, I have passed this onto our team and this should be updated on the website soon. In the meantime feel free to use this update code instead
from imu import MPU6050
from time import sleep
from machine import Pin, I2C
import math
i2c = I2C(0, sda=Pin(8), scl=Pin(9), freq=400000)
imu = MPU6050(i2c)
while True:
ax=round(imu.accel.x,2)
ay=round(imu.accel.y,2)
az=round(imu.accel.z,2)
gx=round(imu.gyro.x)
gy=round(imu.gyro.y)
gz=round(imu.gyro.z)
tem=round(imu.temperature,2)
pitch = math.atan2(ax,az)
roll = math.atan2(ay,az)
print("Pitch",pitch,"/t","Roll",roll)
# Uncomment line below to show acceleration
# print("ax",ax,"\t","ay",ay,"\t","az",az)
# Uncomment line below to show acceleration
# print("gx",gx,"\t","gy",gy,"\t","gz",gz)
sleep(0.2)
Thanks for bring that to our attention!