Skip to main content

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

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:

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

BMI160_i2c-0.4.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

BMI160_i2c-0.4-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file BMI160_i2c-0.4.tar.gz.

File metadata

  • Download URL: BMI160_i2c-0.4.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for BMI160_i2c-0.4.tar.gz
Algorithm Hash digest
SHA256 b1d81f0cb74d1911d204596a6a7370d7ce38b4d289d069f1c6a09660333d8fc5
MD5 417bf62fb85b6df2c8188e88dc1deb6c
BLAKE2b-256 ee44cb1c70eb2fef5cc89eac178d65b6aa28c8c40101410e77c30f4671548b97

See more details on using hashes here.

Provenance

File details

Details for the file BMI160_i2c-0.4-py3-none-any.whl.

File metadata

  • Download URL: BMI160_i2c-0.4-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for BMI160_i2c-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3b71941c95c605ac04ea3b181dc5fc607bdca405c85be32a7b0a829ecd51a19e
MD5 bc5f22488a56a9529a1099ae71972ce5
BLAKE2b-256 f92743db754335dede7edc4a80e089c3786ed111e0b3137a2ad014d9e4f82a08

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page