-
Notifications
You must be signed in to change notification settings - Fork 20
Create lsm6ds3.py #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7bb6866
Create lsm6ds3.py
3bc79ac
Fix misspelling
b1f9cb1
Create lsm6ds_lsm6ds3_simpletest.py
5ef5153
Fix bad error
aeffcc4
Update lsm6ds3.py
e9206e3
change copyright name for lsm6ds3 and change a few docs mentions to t…
FoamyGuy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
""" | ||
This module provides the `adafruit_lsm6ds.lsm6ds33` subclass of LSM6DS sensors | ||
=============================================================================== | ||
""" | ||
from . import LSM6DS | ||
|
||
|
||
class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes | ||
|
||
"""Driver for the LSM6DS3 6-axis accelerometer and gyroscope. | ||
|
||
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to. | ||
:param int address: The I2C device address. Defaults to :const:`0x6A` | ||
|
||
|
||
**Quickstart: Importing and using the device** | ||
|
||
Here is an example of using the :class:`LSM6DS33` class. | ||
First you will need to import the libraries to use the sensor | ||
|
||
.. code-block:: python | ||
|
||
import board | ||
from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 | ||
|
||
Once this is done you can define your `board.I2C` object and define your sensor object | ||
|
||
.. code-block:: python | ||
|
||
i2c = board.I2C() # uses board.SCL and board.SDA | ||
sensor = LSM6DS3(i2c) | ||
|
||
Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes | ||
|
||
.. code-block:: python | ||
|
||
acc_x, acc_y, acc_z = sensor.acceleration | ||
gyro_x, gyro_z, gyro_z = sensor.gyro | ||
|
||
""" | ||
|
||
CHIP_ID = 0x6A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries | ||
FoamyGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# SPDX-License-Identifier: MIT | ||
import time | ||
import board | ||
from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 | ||
|
||
i2c = board.I2C() # uses board.SCL and board.SDA | ||
sensor = LSM6DS3(i2c) | ||
|
||
while True: | ||
print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (sensor.acceleration)) | ||
print("Gyro X:%.2f, Y: %.2f, Z: %.2f radians/s" % (sensor.gyro)) | ||
print("") | ||
time.sleep(0.5) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.