Skip to content

Commit

Permalink
Allow selection of i2c bus for older (rev 1) Pi
Browse files Browse the repository at this point in the history
Extend __init__ method with default bus number and set in the init method.
  • Loading branch information
davidmam authored Nov 25, 2017
1 parent b0e43ed commit 31a409c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mpu6050/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 @@ -53,9 +53,9 @@ class mpu6050:
ACCEL_CONFIG = 0x1C
GYRO_CONFIG = 0x1B

def __init__(self, address):
def __init__(self, address, bus=1):
self.address = address

self.bus = smbus.SMBus(bus)
# 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

0 comments on commit 31a409c

Please sign in to comment.