HWT31 Protocol

HWT31 Protocol

Instructions for use:

Enter commands that need to modify or read data

Read format

  • Data is sent in hexadecimal, not ASCII.

  • Each data is transmitted in sequence by low byte and high byte, and the two are combined into a signed short type of data. For example, for data DATA1, DATA1L is the low byte and DATA1H is the high byte. The conversion method is as follows: Suppose DATA1 is the actual data, DATA1H is its high-byte part, DATA1L is its low-byte part,

Then: DATA1=(short)((short)DATA1H<<8|DATA1L). It must be noted here that DATA1H needs to be coerced into a signed short type of data before shifting, and the data type of DATA1 is also a signed short type, so that negative numbers can be represented.

Protocol header

Data content

Data lower 8 bits

Data high 8 bits

Data lower 8 bits

Data high 8 bits

Data lower 8 bits

Data high 8 bits

Data lower 8 bits

Data high 8 bits

SUMCRC

0x55

TYPE【1】

DATA1L[7:0]

DATA1H[15:8]

DATA2L[7:0]

DATA2H[15:8]

DATA3L[7:0]

DATA3H[15:8]

DATA4L[7:0]

DATA4H[15:8]

SUMCRC【2】

【1】TYPE(data content):

TYPE

Remark

0x51

Acceleration

0x53

Angle

【2】SUMCRC(Data and Checksum):

SUMCRC=0x55+TYPE+DATA1L+DATA1H+DATA2L+DATA2H+DATA3L+DATA3H+DATA4L+DATA4H

SUMCRC is a char type, taking the lower 8 bits of the checksum

Acceleration output

0x55

0x51

AxL

AxH

AyL

AyH

AzL

AzH

TL

TH

SUM

Name

Description

Remark

AxL

Acceleration X low 8 bits

Acceleration X=((AxH<<8)|AxL)/32768*16g (g is the acceleration of gravity, preferably 9.8m/s2)

AxH

Acceleration X high 8 bits

AyL

Acceleration Y low 8 bits

Acceleration Y=((AyH<<8)|AyL)/32768*16g (g is the acceleration of gravity, preferably 9.8m/s2)

AyH

Acceleration Y high 8 bits

AzL

Acceleration Z low 8 bits

Acceleration Z=((AzH<<8)|AzL)/32768*16g (g is the acceleration of gravity, preferably 9.8m/s2)

AzH

Acceleration Z high 8 bits

TL

8-bit lower temperature

Temperature calculation formula: temperature=((TH<<8)|TL) /100 ℃

TH

8-bit high temperature

SUM

Checksum

SUM=0x55+0x51+AxL+AxH+AyL+AyH+AzL+AzH+TL+TH

Angle output

0x55

0x53

RollL

RollH

PitchL

PitchH

0x00

0x00

TL

TH

SUM

Name

Description

Remark

RollL

Roll angle X lower 8 bits

roll angle X=((RollH<<8)|RollL)/32768*180(°)

RollH

Roll angle X high 8 bits

PitchL

Pitch angle Y low 8 bits

Pitch angle Y=((PitchH<<8)|PitchL)/32768*180(°)

PitchH

Pitch angle Y high 8 bits

0x00

meaningless

meaningless

0x00

meaningless

VL

The lower 8 bits of the version number

Version number calculation formula: Version number=(VH<<8)|VL

VH

Version number high 8 bits

SUM

Checksum

SUM=0x55+0x53+RollL+RollH+PitchL+PitchH+VL+VH

Write format

  • The following data, all use Hex code hexadecimal

protocol header

protocol header

register

Data lower 8 bits

Data high 8 bits

0xFF

0xAA

ADDR

DATAL[7:0]

DATAH[15:8]

  • The data is sent in hexadecimal not ASCII.

  • Each data is transmitted in sequence by low byte and high byte, and the two are combined into a signed short type of data. For example, data DATA, where DATAL is the low byte and DATAH is the high byte. The conversion method is as follows: assuming that DATA is the actual data, DATAH is the high byte part, DATAL is the low byte part,

Then: DATA=(short)((short)DATAH<<8|DATAL). It must be noted here that DATAH needs to be coerced into a signed short type of data before shifting, and the data type of DATA is also a signed short type, so that negative numbers can be represented.

CALSW(Calibration mode)

Register Name: CALSW

Register Address: 1 (0x01)

Read and write direction: W

Default: 0x0000

Bit

NAME

FUNCTION

15:1

0:0

CAL

To set the calibration mode:

1(0x01): Addition calibration

Example: FF AA 01 01 00 (plus calibration)

BAUD(Serial port baud rate)

Register Name: BAUD

Register Address: 4 (0x04)

Read and write direction: W

Default: 0x0000

Bit

NAME

FUNCTION

15:1

0:0

BAUD

Set the serial port baud rate:

0(0x00): 115200bps

1(0x01): 9600bps

Example:FF AA 04 00 00(Set the serial port baud rate115200)

DELAYT(Alarm signal delay)

Register Name: DELAYT

Register Address: 89 (0x59)

Read and write direction: W

Default: 0x0000

Bit

NAME

FUNCTION

15:0

DELAYT[15:0]

Unit: ms

After the angle alarm occurs, the port will generate a corresponding alarm signal. When the alarm disappears, the alarm signal will continue to delay DELAYT[15:0] before disappearing.

Example:FF AA 59 E8 03(Set the alarm signal delay1000ms)

XMIN~XMAX(X-axis angle alarm threshold)

Register Name: XMIN~XMAX

Register address: 90~91 (0x5A~0x5B)

Read and write direction: W

Default: 0x0000

Bit

NAME

FUNCTION

15:0

XMIN[15:0]

Set the X-axis angle alarm minimum value

X-axis angle alarm minimum value=XMIN[15:0]*90/32768(°)

15:0

XMAX[15:0]

Set the X-axis angle alarm maximum value

X-axis angle alarm maximum value=XMAX[15:0]*90/32768(°)

Example:

FF AA 5A 72 FC (set -2.5 degrees), 0xFC72=-910, -910*90/32768=-2.5

FF AA 5B 8E 03 (set 2.5 degrees), 0x038E=910, 910*90/32768=2.5

The X axis will not alarm between -2.5°~2.5°, once it exceeds this range, an alarm will occur

YMIN~YMAX(Y-axis angle alarm threshold)

Register Name: YMIN~YMAX

Register address: 94~95 (0x5E~0x5F)

Read and write direction: W

Default: 0x0000

Bit

NAME

FUNCTION

15:0

YMIN[15:0]

Set the Y-axis angle alarm minimum value

Y-axis angle alarm minimum value=YMIN[15:0]*90/32768(°)

15:0

YMAX[15:0]

Set the Y-axis angle alarm maximum value

Y-axis angle alarm maximum value=YMAX[15:0]*90/32768(°)

Example: FF AA 5E 72 FC (set -5 degrees), 0xFC72=-910, -910*90/32768=-2.5

FF AA 5F 8E 03 (set 5 degrees), 0x038E=910, 910*90/32768=2.5

The Y axis will not alarm between -2.5°~2.5°, once it exceeds this range, an alarm will occur

Last updated