Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tuupola/micropython-mpu6886
MicroPython I2C driver for MPU6886 6-axis motion tracking device
https://github.com/tuupola/micropython-mpu6886
micropython mpu6886
Last synced: 2 months ago
JSON representation
MicroPython I2C driver for MPU6886 6-axis motion tracking device
- Host: GitHub
- URL: https://github.com/tuupola/micropython-mpu6886
- Owner: tuupola
- License: mit
- Created: 2020-03-24T12:50:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-27T09:01:07.000Z (over 4 years ago)
- Last Synced: 2024-09-30T07:07:42.254Z (2 months ago)
- Topics: micropython, mpu6886
- Language: Python
- Size: 7.81 KB
- Stars: 20
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-micropython - micropython-mpu6886 - MicroPython I2C driver for MPU6886 6-axis motion tracking device. (Libraries / Sensors)
README
# [WIP] MicroPython MPU-6886 I2C driver
The MPU-6886 is a 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer.
## Usage
Simple test with never ending loop.
```python
import utime
from machine import I2C, Pin
from mpu6886 import MPU6886i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = MPU6886(i2c)print("MPU6886 id: " + hex(sensor.whoami))
while True:
print(sensor.acceleration)
print(sensor.gyro)
print(sensor.temperature)utime.sleep_ms(1000)
```By default the library returns 3-tuple of X, Y, Z axis values for acceleration and gyroscope. Default units are `m/s^2`, `rad/s` and `°C`. It is possible to also get acceleration values in `g` and gyro values `deg/s`. See the example below.
```python
import utime
from machine import I2C, Pin
from mpu6886 import MPU6886, SF_G, SF_DEG_Si2c = I2C(scl=Pin(22), sda=Pin(21))
sensor2 = MPU6886(i2c, accel_sf=SF_G, gyro_sf=SF_DEG_S)print("MPU6886 id: " + hex(sensor.whoami))
while True:
print(sensor.acceleration)
print(sensor.gyro)
print(sensor.temperature)utime.sleep_ms(1000)
```More realistic example usage with timer. If you get `OSError: 26` or `i2c driver install error` after soft reboot do a hard reboot.
```python
import micropython
from machine import I2C, Pin, Timer
from mpu6886 import MPU6886micropython.alloc_emergency_exception_buf(100)
i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = MPU6886(i2c)def read_sensor(timer):
print(sensor.acceleration)
print(sensor.gyro)
print(sensor.temperature)print("MPU6886 id: " + hex(sensor.whoami))
timer_0 = Timer(0)
timer_0.init(period=1000, mode=Timer.PERIODIC, callback=read_sensor)
```## Gyro Calibration
TODO
## License
The MIT License (MIT). Please see [License File](LICENSE.txt) for more information.