# Protocol

### Communication Protocol

Level: TTL level
Baud rate: 4800, 9600 (default), 19200 38400, 57600, 115200, 230400, 460800, 921600, stop bit and parity

### Time Output

 0x55 0x50 YY MM DD hh mm ss msL msH SUM
YY’╝ÜYear, 20YY Year
MM’╝ÜMonth
DD’╝ÜDay
hh’╝Ühour
mm’╝Üminute
ss’╝ÜSecond
ms’╝ÜMillisecond
Millisecond calculate formula’╝Ü
ms=((msH<<8)|msL)
Sum=0x55+0x51+YY+MM+DD+hh+mm+ss+ms+TL

### Acceleration Output

 0x55 0x51 AxL AxH AyL AyH AzL AzH TL TH SUM
Calculate formula’╝Ü
ax=((AxH<<8)|AxL)/32768*16g(g is Gravity acceleration, 9.8m/s2)
ay=((AyH<<8)|AyL)/32768*16g(g is Gravity acceleration, 9.8m/s2)
az=((AzH<<8)|AzL)/32768*16g(g is Gravity acceleration, 9.8m/s2)
Temperature calculated formula’╝Ü
T=((TH<<8)|TL)/100 Ōäā
Checksum’╝Ü
Sum=0x55+0x51+AxH+AxL+AyH+AyL+AzH+AzL+TH+TL
Note’╝Ü
1. 1.
The data is sent in hexadecimal, not ASCII code.
Each data is transmitted in turn of low byte and high byte, and the two are combined into a signed short type data.
For example, X-axis acceleration data Ax, where AxL is low byte and AxH is high byte. The conversion method is as follows:
Assuming that Data is actual data, DataH is its high byte, and DataL is its low byte, then: Data = (short) (DataH << 8 | DataL).
It must be noted that DataH needs to be coerced into a signed short data and then shifted, and the data type of Data is also a signed short type, so that it can represent negative numbers.

### Angular Velocity Output

 0x55 0x52 wxL wxH wyL wyH wzL wzH TL TH SUM
Calculated formula’╝Ü
wx=((wxH<<8)|wxL)/32768*2000(┬░/s)
wy=((wyH<<8)|wyL)/32768*2000(┬░/s)
wz=((wzH<<8)|wzL)/32768*2000(┬░/s)
Temperature calculated formula’╝Ü
T=((TH<<8)|TL) /100 Ōäā
Checksum’╝Ü
Sum=0x55+0x52+wxH+wxL+wyH+wyL+wzH+wzL+TH+TL

### Angle Output

 0x55 0x53 RollL RollH PitchL PitchH YawL YawH VL VH SUM
Calculated formula’╝Ü
Roll(X axis)Roll=((RollH<<8)|RollL)/32768*180(┬░)
Pitch(Y axis)Pitch=((PitchH<<8)|PitchL)/32768*180(┬░)
Yaw(Z axis)Yaw=((YawH<<8)|YawL)/32768*180(┬░)
Version calculated formula’╝Ü
Version=(VH<<8)|VL
Checksum’╝Ü
Sum=0x55+0x53+RollH+RollL+PitchH+PitchL+YawH+YawL+VH+VL
Note’╝Ü
1. 1.
The coordinate system used for attitude angle settlement is the northeast sky coordinate system. Place the module in the positive direction, as the figure shown in Chapter 3.3, direction right is the X-axis, the direction forward is the Y-axis, and direction upward is the Z-axis. Euler angle represents the rotation order of the coordinate system when the attitude is defined as Z-Y-X, that is, first turn around the Z-axis, then turn around the Y-axis, and then turn around the X-axis.
2. 2.
Although the range of the roll angle is ┬▒ 180 degrees, in fact, since the coordinate rotation sequence is Z-Y-X, when expressing the attitude, the range of the pitch angle (Y-axis) is only ┬▒ 90 degrees, and it will change to less than 90 after exceeding 90 degrees Degrees while making the X-axis angle greater than 180 degrees. For detailed principles, please Google Euler angle and posture-related information.
3. 3.
Since the three axes are coupled, they will show independent changes only at small angles, and the attitude angles will change at large angles. For example, when the Y-axis is close to 90 degrees, even if the attitude only rotates around the Y-axis, the angle of the axis will also change greatly, which is an inherent problem with Euler angles indicating attitude.

### Magnetic Output

 0x55 0x54 HxL HxH HyL HyH HzL HzH TL TH SUM
Calculated formula’╝Ü
Magnetic(x axis)Hx=(( HxH<<8)| HxL)
Magnetic(y axis)Hy=(( HyH <<8)| HyL)
Magnetic(z axis)Hz =(( HzH<<8)| HzL)
Temperature calculated formula’╝Ü
T=((TH<<8)|TL) /100Ōäā
Checksum’╝Ü
Sum=0x55+0x53+HxH+HxL+HyH+HyL+HzH+HzL+TH+TL

### Quaternion

 0x55 0x59 Q0L Q0H Q1L Q1H Q2L Q2H Q3L Q3H SUM
Calculated formula’╝Ü
Q0=((Q0H<<8)|Q0L)/32768
Q1=((Q1H<<8)|Q1L)/32768
Q2=((Q2H<<8)|Q2L)/32768
Q3=((Q3H<<8)|Q3L)/32768
Checksum’╝Ü
Sum=0x55+0x59+Q0L+Q0H+Q1L +Q1H +Q2L+Q2H+Q3L+Q3H

### Config Commands

Reminder:
1. 1.
Data format

 Address Symbol Meaning 0x00 SAVE Save 0x01 CALSW Calibration 0x02 RSW Return data content 0x03 RATE Return data Speed 0x04 BAUD Baud rate 0x05 AXOFFSET X axis Acceleration bias 0x06 AYOFFSET Y axis Acceleration bias 0x07 AZOFFSET Z axis Acceleration bias 0x08 GXOFFSET X axis angular velocity bias 0x09 GYOFFSET Y axis angular velocity bias 0x0a GZOFFSET Z axis angular velocity bias 0x0b HXOFFSET X axis Magnetic bias 0x0c HYOFFSET Y axis Magnetic bias 0x0d HZOFFSET Z axis Magnetic bias 0x30 MMYY Month , Year 0x31 HHDD Hour , Day 0x32 SSMM Second , Minute 0x33 MS Millisecond 0x34 AX X axis Acceleration 0x35 AY Y axis Acceleration 0x36 AZ Z axis Acceleration 0x37 GX X axis angular velocity 0x38 GY Y axis angular velocity 0x39 GZ Z axis angular velocity 0x3a HX X axis Magnetic 0x3b HY Y axis Magnetic 0x3c HZ Z axis Magnetic 0x3d Roll X axis Angle 0x3e Pitch Y axis Angle 0x3f Yaw Z axis Angle 0x40 TEMP Temperature 0x51 Q0 Quaternion Q0 0x52 Q1 Quaternion Q1 0x53 Q2 Quaternion Q2 0x54 Q3 Quaternion Q3

### Save Configuration

 0xFF 0xAA 0x00 SAVE 0x00
SAVE’╝ÜSave
0’╝ÜSave current configuration
1’╝Üset to default setting

### Calibrate

 0xFF 0xAA 0x01 CALSW 0x00
CALSW’╝ÜSet calibration mode
0’╝ÜExit calibration mode
1’╝ÜEnter Gyroscope and Accelerometer calibration mode
2’╝ÜEnter magnetic calibration mode

### Installation Direction

 0xFF 0xAA 0x23 DIRECTION 0x00
DIRECTION’╝Üset installation direction
0’╝Üset to horizontal installation
1’╝Üset to vertical installation

### Sleep/ Wake up

 0xFF 0xAA 0x22 0x01 0x00
After sending the command, the module enters the sleep (standby) state, and once again, the module enters the working state from the standby state.

### Algorithm Transition

 0xFF 0xAA 0x24 ALG 0x00
ALG’╝Ü6-axis/ 9-axis algorithm transition
0’╝Üswitch to 9-axis algorithm
1’╝Üswitch to 6-axis algorithm

### Gyroscope Automatic Calibration

 0xFF 0xAA 0x63 GYRO 0x00
GYRO’╝Ügyroscope automatic calibration
0’╝Üset to gyroscope automatic calibration
1’╝Üremoved to gyroscope automatic calibration

### Return Content

 0xFF 0xAA 0x02 RSWL RSWH
RSWL byte definition
 byte 7 6 5 4 3 2 1 0 Name 0x57 pack 0x56 pack 0x55 pack 0x54 pack 0x53 pack 0x52 pack 0x51 pack 0x50 pack default 0 0 0 1 1 1 1 0
RSWH byte definition
 byte 7 6 5 4 3 2 1 0 Name X X X X X 0x5A pack 0x59 pack 0x58 pack default 0 0 0 0 0 0 0 0
X is an undefined value.
0x50 pack’╝Ütime pack
0’╝ÜNot output 0X50 pack
1’╝ÜOutput 0X50 pack
0x51 pack’╝ÜAcceleration pack
0’╝ÜNot output 0x51 pack
1’╝ÜOutput 0x51 pack
0x52 pack’╝ÜAngular velocity pack
0’╝ÜNot output 0x52 packet
1’╝ÜOutput 0x52 pack
0x53 pack’╝ÜAngle Pack
0’╝ÜNot output 0x53 pack
1’╝ÜOutput 0x53 pack
0x54 pack’╝ÜMagnetic Pack
0’╝ÜNot output 0x54 pack
1’╝ÜOutput 0x54 pack
0x59 pack’╝ÜQuaternion Pack
0’╝ÜNot output 0x59 pack
1’╝ÜOutput 0x59 pack

### Return Rate

 0xFF 0xAA 0x03 RATE 0x00
RATE’╝Üreturn rate
0x01 :0.2Hz
0x02’╝Ü0.5Hz
0x03’╝Ü1Hz
0x04’╝Ü2Hz
0x05’╝Ü5Hz
0x06’╝Ü10Hz(default)
0x07’╝Ü20Hz
0x08’╝Ü50Hz
0x09’╝Ü100Hz
0x0a’╝Ü125Hz
0x0b’╝Ü200Hz
0x0c’╝ÜSingle
0x0d: Not output
After the setup is complete, need to click save, and re-power the module to take effect.

### Baud Rate

 0xFF 0xAA 0x04 BAUD 0x00
BAUD’╝Ü
0x01’╝Ü4800
0x02’╝Ü9600(default)
0x03’╝Ü19200
0x04’╝Ü38400
0x05’╝Ü57600
0x06’╝Ü115200
0x07’╝Ü230400
0x08’╝Ü460800
0x09’╝Ü921600

### Set X Axis Acceleration Bias

 0xFF 0xAA 0x05 AXOFFSETL AXOFFSETH
AXOFFSETL’╝ÜX axis Acceleration bias low byte
AXOFFSETH’╝ÜX axis Acceleration bias high byte
AXOFFSET= (AXOFFSETH <<8) | AXOFFSETL
Note’╝ÜAfter setting the acceleration bias, the output value of the acceleration is the sensor measured value minus the bias value.

### Set Y Axis Acceleration Bias

 0xFF 0xAA 0x06 AYOFFSETL AYOFFSETH
AYOFFSETL’╝ÜY axis Acceleration bias low byte
AYOFFSETH’╝ÜY axis Acceleration bias high byte
AYOFFSET= (AYOFFSETH <<8) | AYOFFSETL
Note’╝ÜAfter setting the acceleration bias, the output value of the acceleration is the sensor measured value minus the bias value.

### Set Z Axis Acceleration Bias

 0xFF 0xAA 0x07 AZOFFSETL AZOFFSETH
AZOFFSETL’╝ÜZ axis Acceleration bias low byte
AZOFFSETH’╝ÜZ axis Acceleration bias high byte
AZOFFSET= (AZOFFSETH <<8) | AZOFFSETL
Note’╝ÜAfter setting the acceleration bias, the output value of the acceleration is the sensor measured value minus the bias value.

### Set X Axis Angular Velocity Bias

 0xFF 0xAA 0x08 GXOFFSETL GXOFFSETH
GXOFFSETL’╝ÜSet X axis Angular velocity bias low byte
GXOFFSETH’╝ÜSet Y axis Angular velocity bias high byte
GXOFFSET= (GXOFFSETH <<8) | GXOFFSETL
Note’╝ÜAfter setting the angular velocity zero deviation, the output value of the angular velocity is the sensor measurement value minus the zero deviation value.

### Set Y Axis Angular Velocity Bias

 0xFF 0xAA 0x09 GYOFFSETL GYOFFSETH
GYOFFSETL’╝ÜSet X axis Angular velocity bias low byte
GYOFFSETH’╝ÜSet X axis Angular velocity bias high byte
GYOFFSET= (GYOFFSETH <<8) | GYOFFSETL
Note’╝ÜAfter setting the angular velocity zero deviation, the output value of the angular velocity is the sensor measurement value minus the zero deviation value.

### Set Z Axis Angular Velocity Bias

 0xFF 0xAA 0x0a GXOFFSETL GXOFFSETH
GZOFFSETL’╝ÜSet Z axis Angular velocity bias low byte
GZOFFSETH’╝ÜSet Z axis Angular velocity bias low byte
GZOFFSET= (GZOFFSETH <<8) | GZOFFSETL
Note’╝ÜAfter setting the angular velocity zero deviation, the output value of the angular velocity is the sensor measurement value minus the zero deviation value.

### Set X Axis Magnetic Bias

 0xFF 0xAA 0x0b HXOFFSETL HXOFFSETH
HXOFFSETL’╝ÜSet X axis magnetic bias low byte
HXOFFSETH’╝ÜSet X axis magnetic bias high byte
HXOFFSET= (HXOFFSETH <<8) | HXOFFSETL
Note’╝ÜAfter setting the magnetic field bias, the output value of the magnetic field is the sensor measured value minus the zero bias value.

### Set Y Axis Magnetic Bias

 0xFF 0xAA 0x0c HXOFFSETL HXOFFSETH
HXOFFSETL’╝ÜSet Y axis magnetic bias low byte
HXOFFSETH’╝ÜSet Y axis magnetic bias high byte
HXOFFSET= (HXOFFSETH <<8) | HXOFFSETL
Note’╝ÜAfter setting the magnetic field bias, the output value of the magnetic field is the sensor measured value minus the zero bias value.

### Set Z Axis Magnetic Bias

 0xFF 0xAA 0x0d HXOFFSETL HXOFFSETH
HXOFFSETL’╝ÜSet Y axis magnetic bias low byte
HXOFFSETH’╝ÜSet Z axis magnetic bias high byte
HXOFFSET= (HXOFFSETH <<8) | HXOFFSETL
Note’╝ÜAfter setting the magnetic field bias, the output value of the magnetic field is the sensor measured value minus the zero bias value.