Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions MPU6050.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MPU6050:
# Global Variables
GRAVITIY_MS2 = 9.80665
address = None
bus = smbus.SMBus(1)
bus = None

# Scale Modifiers
ACCEL_SCALE_MODIFIER_2G = 16384.0
Expand Down Expand Up @@ -65,9 +65,11 @@ class MPU6050:
ACCEL_CONFIG = 0x1C
GYRO_CONFIG = 0x1B

def __init__(self, address):
def __init__(self, address, bus_index = 1):
# Set address and bus index
self.address = address

self.bus = smbus.SMBus(bus_index)

# Wake up the MPU-6050 since it starts in sleep mode
self.bus.write_byte_data(self.address, self.PWR_MGMT_1, 0x00)

Expand Down Expand Up @@ -253,9 +255,9 @@ def get_gyro_data(self):

def get_all_data(self):
"""Reads and returns all the available data."""
temp = get_temp()
accel = get_accel_data()
gyro = get_gyro_data()
temp = self.get_temp()
accel = self.get_accel_data()
gyro = self.get_gyro_data()

return [accel, gyro, temp]

Expand Down