Read from MPU9250

After calibrating the MPU9250 chip, let’s print the data read by the MPU9250 chip.

TIPS

A block to output the data read by the MPU9250 chip.

  • First Parameter: Choose accelerometer, gyroscope or magnetometer.

  • Second Parameter: Choose x, y or z.

For example, if you select accelerometer and x, the acceleration value of X Sense HAT on the x-axis will be returned.

_images/tip38.png

The Print function can print data such as variables and text for easy debugging.

_images/tip39.png

After clicking on the bug icon in the bottom left corner, the data printed by the print function will appear in the Debug Monitor.

_images/tip40.png

EXAMPLE

_images/example8.png

Accelerometer and Gyroscope

The following diagram shows the coordinate system for the Acelerometer and Gyroscope.

_images/tip41.png

Note

Note the positive direction on each axis.

Accelerometer

Through the Accelerometer, we can read the acceleration values of the X Sense HAT on the different axes in g.

Place the X Sense HAT horizontally. At this time, the X Sense HAT will be subjected to a vertical downward acceleration of gravity, which is g (g=9.80665 N/kg).

_images/tip42.jpg

When we print the acceleration value on the z-axis, the Debug Monitor will display a value around -1. Since the acceleration value is on the negative half axis of the z-axis, the unit is negative.

_images/tip62.png

Rotate the X Sense HAT clockwise around the y-axis. At this time, the gravitational acceleration received by the X Sense HAT can be decomposed into an acceleration on the x-axis and an acceleration on the z-axis, we can print these 2 accelerations on the Debug Monitor.

_images/tip63.png

Gyroscope

Through the Gyroscope, we can read the angular velocity values ​​of X Sense HAT on different coordinate axes, the unit size is degrees/second.

The judgment of the unit symbol follows the right-hand spiral rule. Hold the axis with your right hand and the thumb points in the direction of the positive semi-axis.

At this time, the direction pointed by the four fingers is the positive direction of the angular velocity value.

_images/tip64.jpg

Print the angular velocity value on the y-axis.

_images/tip65.png

Rotate the X Sense HAT clockwise around the y-axis. Because the angle of the X Sense HAT changes, the angular velocity value of the y-axis is generated and will be printed on Debug Monitor. According to the right-hand screw rule, its unit is positive.

_images/tip44.jpg

Magnetometer

The following diagram shows the coordinate system for the Magnetometer.

_images/tip56.jpg

Note

Note the positive direction on each axis.

Through the magnetometer, we can read the magnetic field strength of X Sense HAT on different coordinate axes, the unit size is 15μT.

We can put a magnet on the positive x-axis of the X Sense HAT.

_images/tip66.jpg

Then print the value of the magnetic field strength on the positive semi-axis of the x-axis (in positive unit).

_images/tip67.png