15
15
--------------------
16
16
17
17
**Hardware:**
18
- * Adafruit's MPU6050 Breakout: https://adafruit.com/products/3886
18
+
19
+ * Adafruit `MPU-6050 6-DoF Accel and Gyro Sensor
20
+ <https://www.adafruit.com/product/3886>`_
19
21
20
22
**Software and Dependencies:**
21
23
22
24
* Adafruit CircuitPython firmware for the supported boards:
23
- https://github.com/adafruit/circuitpython/releases
24
-
25
- * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26
- * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
25
+ https://circuitpython.org/downloads
26
+ * Adafruit's Bus Device library:
27
+ https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
28
+ * Adafruit's Register library:
29
+ https://github.com/adafruit/Adafruit_CircuitPython_Register
27
30
"""
28
31
29
32
# imports
65
68
class Range : # pylint: disable=too-few-public-methods
66
69
"""Allowed values for `accelerometer_range`.
67
70
68
- - `` Range.RANGE_2_G` `
69
- - `` Range.RANGE_4_G` `
70
- - `` Range.RANGE_8_G` `
71
- - `` Range.RANGE_16_G` `
71
+ - :attr:` Range.RANGE_2_G`
72
+ - :attr:` Range.RANGE_4_G`
73
+ - :attr:` Range.RANGE_8_G`
74
+ - :attr:` Range.RANGE_16_G`
72
75
73
76
"""
74
77
@@ -81,10 +84,10 @@ class Range: # pylint: disable=too-few-public-methods
81
84
class GyroRange : # pylint: disable=too-few-public-methods
82
85
"""Allowed values for `gyro_range`.
83
86
84
- - `` GyroRange.RANGE_250_DPS` `
85
- - `` GyroRange.RANGE_500_DPS` `
86
- - `` GyroRange.RANGE_1000_DPS` `
87
- - `` GyroRange.RANGE_2000_DPS` `
87
+ - :attr:` GyroRange.RANGE_250_DPS`
88
+ - :attr:` GyroRange.RANGE_500_DPS`
89
+ - :attr:` GyroRange.RANGE_1000_DPS`
90
+ - :attr:` GyroRange.RANGE_2000_DPS`
88
91
89
92
"""
90
93
@@ -97,13 +100,13 @@ class GyroRange: # pylint: disable=too-few-public-methods
97
100
class Bandwidth : # pylint: disable=too-few-public-methods
98
101
"""Allowed values for `filter_bandwidth`.
99
102
100
- - `` Bandwidth.BAND_260_HZ` `
101
- - `` Bandwidth.BAND_184_HZ` `
102
- - `` Bandwidth.BAND_94_HZ` `
103
- - `` Bandwidth.BAND_44_HZ` `
104
- - `` Bandwidth.BAND_21_HZ` `
105
- - `` Bandwidth.BAND_10_HZ` `
106
- - `` Bandwidth.BAND_5_HZ` `
103
+ - :attr:` Bandwidth.BAND_260_HZ`
104
+ - :attr:` Bandwidth.BAND_184_HZ`
105
+ - :attr:` Bandwidth.BAND_94_HZ`
106
+ - :attr:` Bandwidth.BAND_44_HZ`
107
+ - :attr:` Bandwidth.BAND_21_HZ`
108
+ - :attr:` Bandwidth.BAND_10_HZ`
109
+ - :attr:` Bandwidth.BAND_5_HZ`
107
110
108
111
"""
109
112
@@ -119,10 +122,10 @@ class Bandwidth: # pylint: disable=too-few-public-methods
119
122
class Rate : # pylint: disable=too-few-public-methods
120
123
"""Allowed values for `cycle_rate`.
121
124
122
- - `` Rate.CYCLE_1_25_HZ` `
123
- - `` Rate.CYCLE_5_HZ` `
124
- - `` Rate.CYCLE_20_HZ` `
125
- - `` Rate.CYCLE_40_HZ` `
125
+ - :attr:` Rate.CYCLE_1_25_HZ`
126
+ - :attr:` Rate.CYCLE_5_HZ`
127
+ - :attr:` Rate.CYCLE_20_HZ`
128
+ - :attr:` Rate.CYCLE_40_HZ`
126
129
127
130
"""
128
131
@@ -135,8 +138,34 @@ class Rate: # pylint: disable=too-few-public-methods
135
138
class MPU6050 :
136
139
"""Driver for the MPU6050 6-DoF accelerometer and gyroscope.
137
140
138
- :param ~busio.I2C i2c_bus: The I2C bus the MPU6050 is connected to.
139
- :param address: The I2C slave address of the sensor
141
+ :param ~busio.I2C i2c_bus: The I2C bus the device is connected to
142
+ :param int address: The I2C device address. Defaults to :const:`0x68`
143
+
144
+ **Quickstart: Importing and using the device**
145
+
146
+ Here is an example of using the :class:`MPU6050` class.
147
+ First you will need to import the libraries to use the sensor
148
+
149
+ .. code-block:: python
150
+
151
+ import board
152
+ import adafruit_mpu6050
153
+
154
+ Once this is done you can define your `board.I2C` object and define your sensor object
155
+
156
+ .. code-block:: python
157
+
158
+ i2c = board.I2C() # uses board.SCL and board.SDA
159
+ mpu = adafruit_mpu6050.MPU6050(i2c)
160
+
161
+ Now you have access to the :attr:`acceleration`, :attr:`gyro`
162
+ and :attr:`temperature` attributes
163
+
164
+ .. code-block:: python
165
+
166
+ acc_x, acc_y, acc_z = sensor.acceleration
167
+ gyro_x, gyro_y, gyro_z = sensor.gyro
168
+ temperature = sensor.temperature
140
169
141
170
"""
142
171
@@ -194,14 +223,14 @@ def reset(self):
194
223
195
224
@property
196
225
def temperature (self ):
197
- """The current temperature in º C """
226
+ """The current temperature in º Celsius """
198
227
raw_temperature = self ._raw_temp_data
199
228
temp = (raw_temperature / 340.0 ) + 36.53
200
229
return temp
201
230
202
231
@property
203
232
def acceleration (self ):
204
- """Acceleration X, Y, and Z axis data in m/s^2"""
233
+ """Acceleration X, Y, and Z axis data in :math:` m/s^2` """
205
234
raw_data = self ._raw_accel_data
206
235
raw_x = raw_data [0 ][0 ]
207
236
raw_y = raw_data [1 ][0 ]
@@ -227,7 +256,7 @@ def acceleration(self):
227
256
228
257
@property
229
258
def gyro (self ):
230
- """Gyroscope X, Y, and Z axis data in º/s"""
259
+ """Gyroscope X, Y, and Z axis data in :math:` º/s` """
231
260
raw_data = self ._raw_gyro_data
232
261
raw_x = raw_data [0 ][0 ]
233
262
raw_y = raw_data [1 ][0 ]
@@ -253,7 +282,7 @@ def gyro(self):
253
282
254
283
@property
255
284
def cycle (self ):
256
- """Enable or disable perodic measurement at a rate set by `cycle_rate`.
285
+ """Enable or disable periodic measurement at a rate set by :meth: `cycle_rate`.
257
286
If the sensor was in sleep mode, it will be waken up to cycle"""
258
287
return self ._cycle
259
288
0 commit comments