> For the complete documentation index, see [llms.txt](https://wit-motion.gitbook.io/witmotion-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wit-motion.gitbook.io/witmotion-sdk/wit-standard-protocol/sdk/stm32_sdk-quick-start.md).

# STM32\_SDK Quick Start

### STM32\_SDK quick start

**Applicable Model**

[WT61](https://drive.google.com/drive/folders/1IE55H98HD0SPtKN65sSdT2IOBx1EhrP-?usp=drive_link)

[WT61P](https://drive.google.com/drive/folders/1W_oyTDbwaKgARnx2zEQDH67utnibJ00Y?usp=drive_link)

[WT901](https://drive.google.com/drive/folders/1dWvJU2Ug7MpcwTPWoARw2KJI8oYbuVEW?usp=drive_link)

[WT901B](https://drive.google.com/drive/folders/1F2oTeQccvxNKxq6nW6isxhYecPMagr8M?usp=drive_link)

[WT931](https://drive.google.com/drive/folders/1V7vE1aCca5QXJfwsxnFihDbj0dZtanuF?usp=drive_link)

**Routine download**

**Link to below to download the sample**

<https://github.com/WITMOTION/WitStandardProtocol_JY901>

**Routine introduction**

This routine introduces how to use the serial port 2 of the STM32Core platform to connect to the normal protocol of Wit-motion serial port, and then directly print data through serial port 1, receive sensor data and communicate with the sensor;

Before viewing this routine, please read the relevant sensor manual to understand the protocol used by the sensor and the basic functions of the sensor

**Equipment wiring**

First prepare Witte smart standard sensor, here take JY901S as an example, STM32Core development board and a serial port 3-in-1 module. Wiring：

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2F1nFbK4bi8eQqMJ5mXX1A%2F0.png?alt=media" alt=""><figcaption></figcaption></figure>

Physical wiring diagram：

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FCp93pTUZtXv2YhRWE5Uk%2F1.png?alt=media" alt=""><figcaption></figcaption></figure>

Download the program to the development board, open the serial port debugging assistant at the same time, and power on again, the following information will be displayed：

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2F0m0VkqbaoMdAasTJRSlx%2F2.png?alt=media" alt=""><figcaption></figcaption></figure>

You can send corresponding instructions to configure the module through the prompt information.

**Initialization**

Modules with standard protocols only need to be connected to power and serial lines, and the data will be automatically returned.

For the introduction of API functions, please read the WIT\_C\_SDKAPI function documentation.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FCPAY5qc4CrTT6Vj2PSye%2F3.png?alt=media" alt=""><figcaption></figcaption></figure>

Usart1Init(115200);//Initialize the print data serial port

Usart2Init(9600);//Initialize the module data serial port

WitInit(WIT\_PROTOCOL\_NORMAL, 0x50);//Initialize the standard protocol, set the device address

WitSerialWriteRegister(SensorUartSend);//Register write callback function

WitRegisterCallBack(CopeSensorData);//Register to get the sensor data callback function

AutoScanSensor();//Automatically search for sensors

### Receive sensor data <a href="#w0clz" id="w0clz"></a>

### Get data <a href="#ipawc" id="ipawc"></a>

We will create an array to store the read data into the array, and read the corresponding data directly according to the index. If the module automatically lasts data, the status data update will read the data returned by the sensor, and the final effect is to read the data of the module's 3D acceleration, 3D angular velocity, 3D angle, and 3D magnetic field into the specified index array. Finally print it out.

The following is the print data when the data update is detected.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FdVwY3nJF6hiNmdTk5Qtv%2F4.png?alt=media" alt=""><figcaption></figcaption></figure>

### Set sensor <a href="#imeta" id="imeta"></a>

The parameters of the module can be set through the function CmdProcess(); Such as acceleration calibration, magnetic field calibration and modifying baud rate etc.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FX6jJY5lrO6PTLUE0SvLo%2F5.png?alt=media" alt=""><figcaption></figcaption></figure>

Open the serial port assistant, send the command b\r\n, and then observe the phenomenon.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FRw6mj7VGuVlprimwba39%2Fimage.png?alt=media&amp;token=8e9a84b0-b903-4fa4-952d-606109fde644" alt=""><figcaption></figcaption></figure>

After sending b\r\n, the module will search for the device again, and prompt what baud rate is found. The window displays information prompting that the 9600 baud rate search is successful, and compares the sending instructions described in the HELP prompt information. The baud rate indicates that the setting is correct. Please use other commands as needed.

**Acceleration Calibration**

Some commonly used API function interfaces are defined in the file wit\_c\_sdk.c, which only need to be called.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FVjvvxzO3h5B9hpYJ6Kdq%2F7.png?alt=media" alt=""><figcaption></figcaption></figure>

### Magnetic Field Calibration <a href="#phtdh" id="phtdh"></a>

The magnetic field calibration needs to be sent to start the calibration first, then rotate around the three axes of the sensor and then end the calibration. First call WitStartMagCali(); to start magnetic field calibration, then rotate the sensor on three axes, and then call WitStopMagCali(); to end the calibration.

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FL2UH1IWsRiqntKYCGhvf%2F8.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://4238809933-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7KeiQ2sbyWknusoV5r8U%2Fuploads%2FXnisgxaFw7v0gWWCTHqL%2F9.png?alt=media" alt=""><figcaption></figcaption></figure>

**More**

For other operations, please refer to the sensor manual
