Skip to content

Commit e83f57f

Browse files
Merge pull request #17 from jposada202020/correcting_returning_units_gyro
Correcting returning units gyro
2 parents 2a25e0c + bfe5e3a commit e83f57f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

adafruit_mpu6050.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
1717
**Hardware:**
1818
19-
* Adafruit `MPU-6050 6-DoF Accel and Gyro Sensor
20-
<https://www.adafruit.com/product/3886>`_
19+
* `Adafruit MPU-6050 6-DoF Accel and Gyro Sensor
20+
<https://www.adafruit.com/product/3886>`_ (Product ID: 3886)
2121
2222
**Software and Dependencies:**
2323
2424
* Adafruit CircuitPython firmware for the supported boards:
2525
https://circuitpython.org/downloads
26+
2627
* Adafruit's Bus Device library:
2728
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
29+
2830
* Adafruit's Register library:
2931
https://github.com/adafruit/Adafruit_CircuitPython_Register
3032
"""
@@ -34,6 +36,7 @@
3436
__version__ = "0.0.0-auto.0"
3537
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MPU6050.git"
3638

39+
from math import radians
3740
from time import sleep
3841
from adafruit_register.i2c_struct import UnaryStruct, ROUnaryStruct
3942
from adafruit_register.i2c_struct_array import StructArray
@@ -274,9 +277,9 @@ def gyro(self):
274277
gyro_scale = 16.4
275278

276279
# setup range dependant scaling
277-
gyro_x = raw_x / gyro_scale
278-
gyro_y = raw_y / gyro_scale
279-
gyro_z = raw_z / gyro_scale
280+
gyro_x = radians(raw_x / gyro_scale)
281+
gyro_y = radians(raw_y / gyro_scale)
282+
gyro_z = radians(raw_z / gyro_scale)
280283

281284
return (gyro_x, gyro_y, gyro_z)
282285

examples/mpu6050_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
while True:
1212
print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (mpu.acceleration))
13-
print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s" % (mpu.gyro))
13+
print("Gyro X:%.2f, Y: %.2f, Z: %.2f rad/s" % (mpu.gyro))
1414
print("Temperature: %.2f C" % mpu.temperature)
1515
print("")
1616
time.sleep(1)

0 commit comments

Comments
 (0)