A I2C driver library to use the BMI160 sensor (acclerometer/gyro) with python on a raspberrypi
Project description
BMI160-i2c
I2C library to use the Inertial Mesurment Unit BMI160.
This library was tested successfully on a Raspberry Pi 3 B
Installation
The package is available on pypi.org.
You can install this package using this command
python3 -m pip install BMI160-i2c
This library require smbus
Install smbus2 using the following command:
python3 -m pip install smbus2
Usage
Wire the breakout board with these lines : GND, 3V3, SAO (to GND), SDA, SCL
Make sure that the device is available at 0x68 or 0x69 i2c address by running this command:
i2cdetect -y 1
Example : A little python script to fetch all 6 values from the sensor :
from time import sleep
from BMI160_i2c import Driver
print('Trying to initialize the sensor...')
sensor = Driver(0x68) # change address if needed
print('Initialization done')
while True:
data = sensor.getMotion6()
# fetch all gyro and acclerometer values
print({
'gx': data[0],
'gy': data[1],
'gz': data[2],
'ax': data[3],
'ay': data[4],
'az': data[5]
})
sleep(0.1)
Documentation
There is so many method available to do whatever you want to do with a sensor of this kind.
Look at all the methods available here.
Credits & Related links
- hanyazou/BMI160-Arduino
- serioeseGmbH/BMI160
- IMU BMI160 Bosch product page
- BMI160 Datasheet
- smbus2 docs
Contributions
Feel free to open a issue or a pull request I will be happy to answer any questions or help you with this library.
You can also use these alternative methods to contact me:
-
Twitter: @_le_futuriste
-
Discord:
lefuturiste#5297 -
Discord server: https://discord.gg/9M4vVsX
Maintenance
- Increment the version used in
setup.py - Build the package:
python3 setup.py sdist bdist_wheel - Publish the package:
python3 -m twine upload dist/* - Enter
__token__for the username - Enter
pypi-{....}for the password - And tada!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file BMI160_i2c-0.5.tar.gz.
File metadata
- Download URL: BMI160_i2c-0.5.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48314f5d146f8b67759235554e0868181efd4371f70e4b678d10ffa4b0576e16
|
|
| MD5 |
12ec2324b154c780183ae3c46a3bcfcf
|
|
| BLAKE2b-256 |
84296c0dee7a8863344ec5141be6cb04b6a9f876d94062bb68e3a75804f161f7
|
File details
Details for the file BMI160_i2c-0.5-py3-none-any.whl.
File metadata
- Download URL: BMI160_i2c-0.5-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d9e84803f0259d6cd0f3419bb44e5081a4cdfdf5506c909af4b4e416619fed
|
|
| MD5 |
c3d9dab5c5018dc84a3fd697b15bea49
|
|
| BLAKE2b-256 |
818287bc39a20ba4791aa62655f42351255fb5a08c4cb4662c3dd18231a38f0e
|