m-rtijn / mpu6050

A Python module for accessing the MPU-6050 digital accelerometer and gyroscope on a Raspberry Pi.
MIT License
295 stars 143 forks source link

TypeError: 'module' object is not callable #33

Open MarCixn opened 3 years ago

MarCixn commented 3 years ago

python3 sensor.py

Traceback (most recent call last): File "sensor.py", line 3, in mpu = mpu6050(0x68) TypeError: 'module' object is not callable

my code:

from mpu6050 import mpu6050
import time
mpu = mpu6050(0x68)

while True:
    print("Temp : "+str(mpu.get_temp()))
    print()

    accel_data = mpu.get_accel_data()
    print("Acc X : "+str(accel_data['x']))
    print("Acc Y : "+str(accel_data['y']))
    print("Acc Z : "+str(accel_data['z']))
    print()

    gyro_data = mpu.get_gyro_data()
    print("Gyro X : "+str(gyro_data['x']))
    print("Gyro Y : "+str(gyro_data['y']))
    print("Gyro Z : "+str(gyro_data['z']))
    print()
    print("-------------------------------")
    time.sleep(1)
l-shannan commented 3 years ago

I am using the same code and get the same error when trying to run in python3.

if i try to run in python i get

Traceback (most recent call last): File "6050.py", line 3, in mpu = mpu6050(0x68) File "/home/pi/.local/lib/python2.7/site-packages/mpu6050/mpu6050.py", line 60, in init self.bus.write_byte_data(self.address, self.PWR_MGMT_1, 0x00) IOError: [Errno 121] Remote I/O error