nanoFramework.Iot.Device.Mpu6886
1.2.656
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Mpu6886 --version 1.2.656
NuGet\Install-Package nanoFramework.Iot.Device.Mpu6886 -Version 1.2.656
<PackageReference Include="nanoFramework.Iot.Device.Mpu6886" Version="1.2.656" />
paket add nanoFramework.Iot.Device.Mpu6886 --version 1.2.656
#r "nuget: nanoFramework.Iot.Device.Mpu6886, 1.2.656"
// Install nanoFramework.Iot.Device.Mpu6886 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Mpu6886&version=1.2.656 // Install nanoFramework.Iot.Device.Mpu6886 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Mpu6886&version=1.2.656
Mpu6886 - accelerometer and gyroscope
The MPU-6886 is a 6-axis motion tracking sensor that combines a 3-axis gyroscope and a 3-axis accelerometer including the following features:
- gyroscope programmable FSR of ±250 dps, ±500 dps, ±1000 dps, and ±2000 dps
- accelerometer with programmable FSR of ±2g, ±4g, ±8g, and ±16g
Documentation
- Datasheet, register descriptions start at page 32.
- This sensor is used in for example the M5StickC Plus development kit, initialization code can be found here.
Usage
Create the Mpu6886
class and pass the I2C device. By default the I2C address for this sensor is 0x68
.
// I2C pins need to be configured, for example for pin 22 & 21 for
// the M5StickC Plus. These pins might be different for other boards.
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
I2cConnectionSettings settings = new(1, Mpu6886AccelerometerGyroscope.DefaultI2cAddress);
using (Mpu6886AccelerometerGyroscope ag = new(I2cDevice.Create(settings)))
{
Debug.WriteLine("Start calibration ...");
var offset = ag.Calibrate(1000);
Debug.WriteLine($"Calibration done, calculated offsets {offset.X} {offset.Y} {offset.Y}");
Debug.WriteLine($"Internal temperature: {ag.GetInternalTemperature().DegreesCelsius} C");
while (true)
{
var acc = ag.GetAccelerometer();
var gyr = ag.GetGyroscope();
Debug.WriteLine($"Accelerometer data x:{acc.X} y:{acc.Y} z:{acc.Z}");
Debug.WriteLine($"Gyroscope data x:{gyr.X} y:{gyr.Y} z:{gyr.Z}\n");
Thread.Sleep(100);
}
}
Sample output
Start calibration ...
Calibration done, calculated offsets 49.189 -86.21099999 -86.21099999
Internal temperature: 64.21664626 C
Accelerometer data x:-0.041503906 y:0 z:1.056884765
Gyroscope data x:4.94384765 y:-8.60595703 z:-15.68603515
Accelerometer data x:-0.040771484 y:-0.0051269531 z:1.062988281
Gyroscope data x:4.94384765 y:-7.56835937 z:-15.014648437
Accelerometer data x:-0.046630859 y:-0.0068359375 z:1.055175781
Gyroscope data x:3.60107421 y:-7.62939453 z:-15.1977539
Accelerometer data x:-0.049560546 y:-0 z:1.061279296
Gyroscope data x:4.39453125 y:-7.32421875 z:-14.28222656
See samples for a complete sample application.
Calibration
The gyroscope can be calibrated using the Calibrate
function. With the iterations
parameter
you can specify how many values should be read from the sensor to calculate an average (1000 iterations seems
to be a good number). During the calibration you want to keep the sensor still and in a fixed position (e.g. lying
flat on a table). The Calibrate
function will write the values to the corresponding compensation registers
of the sensor, values are corrected when retrieved automatically.
The return value of the Calibrate
method gives a vector containing the 3 (for the X,Y and Z axes) calculated
compensation values.
var offset = ag.Calibrate(1000);
Debug.WriteLine($"Calibration done, calculated offsets {offset.X} {offset.Y} {offset.Y}");
It is possible to write directly to the compensation registers using the SetGyroscopeOffset
function. You might
want to do this when you create your own custom calibration method, or you retrieve existing calibration data from
a persisted data store or memory location.
⚠ When the devices reboots, the offset registers are cleared. So if you don't persist the calibration data yourself you will have to run the calibration method every time the device boots.
Sleep mode
The sensor can be put in sleep mode by calling the Sleep
function. After that the WakeUp
function should be called.
Setting scales
Both for the gyroscope and accelerometer you can set the desired scales using the AccelerometerScale
and GyroscopeScale
properties.
// Set the scale of the accelerometer to 2G
ag.AccelerometerScale = AccelerometerScale.Scale2G;
Setting enabled axes
By default all gyroscope and accelerometer axes are enabled. If desired you can specify explicitly which axes should be enabled. In that case, all other axes will be disabled. When an axis is disabled, data can still be read for that axis but the values will not change anymore.
// Enable only the X axis of the gyroscope and accelerometer
ag.EnabledAxes = EnabledAxis.GyroscopeX | EnabledAxis.AccelerometerX;
Features not implemented
The following features are enabled in the MPU6886 but not yet implemented in this driver:
- registers
0x05
to0x0b
: low noise to low power offset - registers
0x0d
to0x0F
: self test - register
0x1a
: FIFO mode, DLPF (digital low pass filter) - register
0x1d
bit 0 to 3: DLPF - register
0x1e
bit 4 to 6: averaging filter for low power mode - registers
0x20
to0x22
: threshold for wake-on motion - register
0x36
: fsync interrupt status - register
0x37
: INT/DRDY pin config - register
0x39
and0x3a
: FIFO watermark interrupt - register
0x60
and0x61
: FIFO watermark interrupt - register
0x68
: signal path reset - register
0x69
: acc. intelligence control
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Buffers.Binary.BinaryPrimitives (>= 1.2.628)
- nanoFramework.System.Device.I2c (>= 1.1.16)
- nanoFramework.System.Device.Model (>= 1.2.628)
- nanoFramework.System.Math (>= 1.5.43)
- nanoFramework.System.Numerics (>= 1.2.628)
- UnitsNet.nanoFramework.Temperature (>= 5.59.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on nanoFramework.Iot.Device.Mpu6886:
Package | Downloads |
---|---|
nanoFramework.M5Core2
This package includes the nanoFramework.M5Core2 assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickC
This package includes the nanoFramework.M5StickC assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5Core
This package includes the nanoFramework.M5Core assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickCPlus
This package includes the nanoFramework.M5StickCPlus assembly for .NET nanoFramework C# projects. |
|
nanoFramework.AtomMatrix
This package includes the nanoFramework.AtomMatrix assembly for .NET nanoFramework C# projects. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on nanoFramework.Iot.Device.Mpu6886:
Repository | Stars |
---|---|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
|
nanoframework/nanoFramework.M5Stack
:package: Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
Version | Downloads | Last updated |
---|---|---|
1.2.704 | 64 | 12/18/2024 |
1.2.696 | 253 | 12/16/2024 |
1.2.673 | 865 | 10/23/2024 |
1.2.656 | 1,010 | 10/3/2024 |
1.2.639 | 834 | 9/6/2024 |
1.2.631 | 387 | 8/28/2024 |
1.2.613 | 670 | 8/9/2024 |
1.2.601 | 298 | 7/26/2024 |
1.2.590 | 557 | 7/17/2024 |
1.2.573 | 872 | 6/19/2024 |
1.2.570 | 117 | 6/14/2024 |
1.2.536 | 1,276 | 4/15/2024 |
1.2.514 | 887 | 3/22/2024 |
1.2.494 | 561 | 2/28/2024 |
1.2.478 | 479 | 1/26/2024 |
1.2.462 | 670 | 1/5/2024 |
1.2.458 | 232 | 12/20/2023 |
1.2.436 | 884 | 11/10/2023 |
1.2.416 | 596 | 11/8/2023 |
1.2.403 | 730 | 10/6/2023 |
1.2.396 | 490 | 9/27/2023 |
1.2.384 | 504 | 9/6/2023 |
1.2.378 | 785 | 8/16/2023 |
1.2.369 | 672 | 8/2/2023 |
1.2.363 | 484 | 7/28/2023 |
1.2.357 | 519 | 7/19/2023 |
1.2.354 | 492 | 7/14/2023 |
1.2.345 | 833 | 6/21/2023 |
1.2.341 | 530 | 6/14/2023 |
1.2.337 | 528 | 6/7/2023 |
1.2.335 | 187 | 6/2/2023 |
1.2.329 | 781 | 5/26/2023 |
1.2.313 | 952 | 5/12/2023 |
1.2.302 | 644 | 5/10/2023 |
1.2.297 | 657 | 5/3/2023 |
1.2.273 | 2,902 | 3/17/2023 |
1.2.267 | 1,597 | 3/10/2023 |
1.2.263 | 1,309 | 3/8/2023 |
1.2.259 | 1,363 | 2/27/2023 |
1.2.256 | 1,081 | 2/24/2023 |
1.2.253 | 1,099 | 2/22/2023 |
1.2.222 | 2,950 | 1/9/2023 |
1.2.217 | 2,234 | 1/6/2023 |
1.2.212 | 2,228 | 1/5/2023 |
1.2.208 | 353 | 1/3/2023 |
1.2.203 | 1,683 | 12/28/2022 |
1.2.159 | 1,882 | 11/14/2022 |
1.2.153 | 4,342 | 11/5/2022 |
1.2.141 | 5,818 | 10/25/2022 |
1.2.128 | 516 | 10/22/2022 |
1.2.87 | 16,479 | 9/15/2022 |
1.2.63 | 5,407 | 9/3/2022 |
1.2.47 | 2,286 | 8/15/2022 |
1.2.40 | 2,485 | 8/6/2022 |
1.2.38 | 2,186 | 8/5/2022 |
1.2.28 | 7,002 | 8/1/2022 |
1.2.13 | 5,354 | 7/24/2022 |
1.2.10 | 2,184 | 7/23/2022 |
1.1.142.3202 | 5,505 | 7/7/2022 |
1.1.133.52556 | 7,247 | 6/30/2022 |
1.1.121.35854 | 6,016 | 6/26/2022 |
1.1.116.8772 | 3,862 | 6/24/2022 |
1.1.113.2032 | 460 | 6/23/2022 |
1.1.102.51394 | 3,693 | 6/15/2022 |
1.1.99.36719 | 2,101 | 6/14/2022 |
1.1.97.17326 | 2,496 | 6/13/2022 |
1.1.92.53000 | 2,279 | 6/8/2022 |
1.1.72.29765 | 10,278 | 5/31/2022 |
1.1.64.21380 | 6,015 | 5/26/2022 |
1.1.54.28879 | 5,317 | 5/23/2022 |
1.1.40 | 7,371 | 5/5/2022 |
1.1.3 | 24,627 | 4/15/2022 |
1.1.1 | 476 | 4/14/2022 |
1.0.303 | 2,315 | 4/12/2022 |
1.0.302 | 8,125 | 3/31/2022 |
1.0.300 | 502 | 3/31/2022 |
1.0.288-preview.114 | 174 | 3/25/2022 |
1.0.288-preview.113 | 132 | 3/25/2022 |
1.0.288-preview.106 | 155 | 3/23/2022 |
1.0.288-preview.104 | 126 | 3/22/2022 |
1.0.288-preview.103 | 129 | 3/21/2022 |
1.0.288-preview.100 | 144 | 3/19/2022 |
1.0.288-preview.99 | 150 | 3/18/2022 |
1.0.288-preview.98 | 134 | 3/18/2022 |
1.0.288-preview.95 | 172 | 3/15/2022 |
1.0.288-preview.93 | 139 | 3/15/2022 |
1.0.288-preview.86 | 196 | 3/8/2022 |
1.0.288-preview.77 | 175 | 2/27/2022 |
1.0.288-preview.75 | 137 | 2/26/2022 |
1.0.288-preview.65 | 162 | 2/18/2022 |
1.0.288-preview.63 | 147 | 2/16/2022 |
1.0.288-preview.61 | 149 | 2/12/2022 |
1.0.288-preview.58 | 139 | 2/10/2022 |
1.0.288-preview.53 | 139 | 2/9/2022 |
1.0.288-preview.50 | 162 | 2/5/2022 |
1.0.288-preview.48 | 163 | 2/4/2022 |
1.0.288-preview.41 | 165 | 1/31/2022 |
1.0.288-preview.29 | 215 | 1/28/2022 |
1.0.288-preview.22 | 202 | 1/27/2022 |
1.0.288-preview.20 | 156 | 1/27/2022 |
1.0.288-preview.18 | 163 | 1/27/2022 |
1.0.288-preview.5 | 166 | 1/24/2022 |
1.0.272 | 603 | 1/10/2022 |
1.0.260 | 1,137 | 12/10/2021 |
1.0.259 | 344 | 12/9/2021 |
1.0.258 | 343 | 12/7/2021 |
1.0.224 | 488 | 10/22/2021 |
1.0.218 | 437 | 10/18/2021 |
1.0.191 | 364 | 9/29/2021 |
1.0.172 | 370 | 9/20/2021 |