Как исправить проблемы с подключением MPU-9250 к ардуино? — Хабр Q&A

Как исправить проблемы с подключением MPU-9250 к ардуино? — Хабр Q&A Роботы

Board overview

The MPU-9250 Breakout as you will receive it

The board is designed to be smaller than some of our other offerings to fit in smaller projects. To achieve this, the PTHs are wrapped around the boarder of the PCB in three rows of three or four.

The top row (J1) is all one need to get most of the functionality of the IMU. These include the I2C and power interface. If space were really tight, one could take a saw and carefully remove all of the other PTHs.


The MPU-9250 Breakout has two solder jumpers, SJ1 and SJ2.

SJ1 comes pre-soldered to short VDD and VDDIO. This reduces the number of power supplies to one with out requiring an external jumper. If the core and IO need to be supplied with different voltages, remove the solder from SJ1.

SJ2 is a two way jumper that comes pre-soldered to connect AD0 to ground. This sets the I2C address to 0x68. It also leaves the PTH for AD0 disconnected and floating. If the solder is moved to connect the center pad with the pad on the left, then the AD0 PTH needs to be connected high or low to chose the I2C address.

Library and example code

Our version is mostly a conversion to make it follow the Arduino library format. You can use the Arduino IDE’s library manager by searching for “SparkFun MPU-9250” as detailed in this tutorial. Or you can manually install the library from the GitHub repository by downloading the *.zip linked below:

Magnetic declination

The AHRS needs to know where you are located to convert magnetic north to true north. I used the combination of two services to find the current declination of our offices; Google, and NOAA. This may or may not be ideal in your country.

Смотрите про коптеры:  Топ 5 лучших моторов для мини-коптеров | RCDetails Blog

Pth connections

The following table summarizes all of the plated through hole (PTH) connections on the breakout board in order found on the board stating in the upper-left corner and wrapping clockwise:

Pin LabelPin FunctionNotes
SCLI2C serial clock
SPI serial port clock
100 or 400 kHz I2C
Up to 1 MHz SPI (20 MHz in certain cases)
SDAI2C serial dataCan also be used for SPI serial data input (SDI)
VDD Power supply 2.4V to 3.6V
GNDGround reference 0V
AUXDAGround reference I2C master serial data, for connecting to external sensors
FSYNCGround referenceFrame synchronization digital input. Connect to GND if unused.
AUXCLGround referenceI2C Master serial clock, for connecting to external sensors
INTInterrupt signalInterrupt digital output (totem pole or open-drain)
CSChip selectChip select (SPI mode only)
Address selectionI2C Slave Address LSB (AD0):
Low: 0b1101000 ➫ 0x68
High: 0b1101001 ➫ 0x69
SPI serial data output (SDO)
VDDIOPower supply for I/O pins 1.71V up to VDD

Reducing size

As stated earlier, one of the design goals for this breakout was to make the board small. Some projects will require mounting holes, so we threw them on the right side of some v-score on this board. Since the board is only ⅔” wide and there isn’t enough mass to the left of the mounting holes, there isn’t much of a bending moment.

If you plan to use a breadboard, or secure the IMU securely to a project with something like epoxy, the mounting holes can be snapped off. As shown in the following image. The pliers I had on hand made super easy work of this. The edge of a table should work fine too.

Смотрите про коптеры:  Рейтинг роботов-пылесосов: лучшие модели в 2019 году

Board was held with pliers and easily broken by pressing the other side

Resources and going further

For more information about the MPU-9250 Breakout, check out the links below.

Many of the advanced features of the MPU-9250 are only accessable by agreeing to a pages of licensing terms and logging in as a developer to get access to Embedded MotionDriver 6.12. This approach isn’t super Arduino friendly. At power up 3062 bytes of undocumented hex needs to be loaded into the MPU-9250.

#define DMP_CODE_SIZE           (3062)

static const unsigned char dmp_memory[DMP_CODE_SIZE] = {
    /* bank # 0 */
    0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00,
    0x00, 0x00, 0x65, 0x00, 0x54, 0xff, 0xef, 0x00, 0x00, 0xfa, 0x80, 0x00, 0x0b, 0x12, 0x82,...

Code snippet of MPU-9250 Embedded MotionDriver firmware

That binary combined with the driver and any code that does something with the sensor data quickly maxes out smaller microcontrollers. Feel free to register and play around if you want to take this product further.

A customer of ours shared his great tutorial on Affordable 9-DoF Sensor Fusion. Check it out for more info on sensor fusion.

For more SparkFun sensor fun, check out these other great tutorials. (This was fun, right??)

Openlog artemis hookup guide

How to use and re-program the OpenLog Artemis, an open source datalogger. The OLA comes preprogrammed to automatically log data with the built-in ICM-20948 Inertial Measurement Unit (IMU) 9-Degrees-Of-Freedom (9-DOF) sensor. The OLA can also record serial data, analog voltages, or readings from external Qwiic-enabled I2C devices. Some of these Qwiic-enabled devices include GPS/GNSS modules, pressure, altitude, humidity, temperature, air quality, environment, distance, and weight sensors.

Or check out this blog post for ideas:

What you should see

The library left a lot of the math in the example sketch in part to make things like this easier to access. Here is an example of what the output of the demo sketch should look like:

MPU9250 I AM 71 I should be 71
MPU9250 is online...
x-axis self test: acceleration trim within : 2.4% of factory value
y-axis self test: acceleration trim within : 0.5% of factory value
z-axis self test: acceleration trim within : -0.0% of factory value
x-axis self test: gyration trim within : -0.3% of factory value
y-axis self test: gyration trim within : -1.0% of factory value
z-axis self test: gyration trim within : 0.5% of factory value
MPU9250 initialized for active data mode....
AK8963 I AM 48 I should be 48
AK8963 initialized for active data mode....
X-Axis sensitivity adjustment value 1.21
Y-Axis sensitivity adjustment value 1.22
Z-Axis sensitivity adjustment value 1.17
ax = -70.19 ay = -70.56 az = 931.03 mg
gx = 0.02 gy = 0.00 gz = 0.02 deg/s
mx = -189 my = 355 mz = 127 mG
q0 = 0.97 qx = -0.04 qy = 0.03 qz = 0.22
Yaw, Pitch, Roll: 16.45, 4.22, -4.14
rate = 140.15 Hz

Как исправить проблемы с подключением mpu-9250 к ардуино?

Первое, на что обращает внимание схема в примере – нужно добавить подтяжки к питанию на линии SCL и SDA, как в

Смотрите про коптеры:  Очередная Arduino машинка сборка простейшего варианта



Второе, что бы я сделал – это задействовал линию INT, чтобы Arduino получал события движения по протоколу Wake-on-Motion. Потому что процедура повторного сброса в даташите не описана.

Таким образом либо его надо сбрасывать, отключая от питания, либо, что скорее всего, подразумевается работа по протоколу Wake-on-Motion.

В Вашем случае происходит скорее всего следующее. При повторном включении запускается скетч, и он отрабатывает. А при подключении к монитору порта Arduino сбрасывается, но гироскоп-то об этом не знает, и просто игнорирует попытки Arduino повторно к нему подключиться.

Оцените статью
Добавить комментарий