-
Notifications
You must be signed in to change notification settings - Fork 53
Added i2c-gpio example #54
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,35 @@ | ||
""" | ||
This example demonstrates how to instantiate the | ||
Adafruit BNO055 Sensor using this library and just | ||
the I2C bus number. | ||
This example will only work on a Raspberry Pi | ||
and does require the i2c-gpio kernel module to be | ||
installed and enabled. Most Raspberry Pis will | ||
already have it installed, however most do not | ||
have it enabled. You will have to manually enable it | ||
""" | ||
|
||
import time | ||
from adafruit_extended_bus import ExtendedI2C as I2C | ||
import adafruit_bno055 | ||
|
||
# To enable i2c-gpio, add the line `dtoverlay=i2c-gpio` to /boot/config.txt | ||
# Then reboot the pi | ||
|
||
# Create library object using our Extended Bus I2C port | ||
# Use `ls /dev/i2c*` to find out what i2c devices are connected | ||
i2c = I2C(1) # Device is /dev/i2c-1 | ||
sensor = adafruit_bno055.BNO055_I2C(i2c) | ||
|
||
while True: | ||
print("Temperature: {} degrees C".format(sensor.temperature)) | ||
print("Accelerometer (m/s^2): {}".format(sensor.acceleration)) | ||
print("Magnetometer (microteslas): {}".format(sensor.magnetic)) | ||
print("Gyroscope (rad/sec): {}".format(sensor.gyro)) | ||
print("Euler angle: {}".format(sensor.euler)) | ||
print("Quaternion: {}".format(sensor.quaternion)) | ||
print("Linear acceleration (m/s^2): {}".format(sensor.linear_acceleration)) | ||
print("Gravity (m/s^2): {}".format(sensor.gravity)) | ||
print() | ||
|
||
time.sleep(1) |
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.