Arduino_SDK Quick Start

Arduino_SDK quick start

Routine Board

Arduino Mega-2560 Development Board

Where to download

Please check the below link to download

https://witpic-1253369323.cos.ap-guangzhou.myqcloud.com/wit-cloud/ep/uploadFile/ArduinoSDK%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F-1656070671017.zip

Routine Introduction

This routine introduces how to use serial port 1 of the MEGA-2560 platform to connect Witt intelligent JY61 sensor, and then directly print data through the serial port, 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

Device Wiring

First of all, prepare Witte smart JY61 sensor, MEGA-2560 development board and a serial port 3 in 1 module. Please check the below wiring:

  • Copy the file wit_c_sdk to the library folder of Arduino's libraries

paste path:arduino-1.8.15\libraries

After pasting successfully:

  • Use the Arduino software to download the program to the development board

path:wit_c_sdk_arduino\examples\wit_c_sdk_JY61

  • Selection of development boards, processors, and serial ports

  • Upload and burn program

Reason for uploaded item error:

The serial port selection is wrong, the serial port is not selected, or the serial port is occupied

The above prompts show that the program is successfully compiled and downloaded to the development board.

  • 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:

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.

Serial.begin(115200); //Initialize the print data serial port

WitInit(WIT_PROTOCOL_JY61, 0x50); //Initialize JY61

WitSerialWriteRegister(SensorUartSend); //Registers a callback function that writes out data

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

WitDelayMsRegister(Delayms); //Register millisecond delay function

AutoScanSensor(); //Automatically search for sensors

Receive sensor data

Get data

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

Setting the sensor

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

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

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 115200 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. Use other commands as needed.

Accelerometer calibration

Some common API function interfaces are defined in the file wit_c_sdk.c, which only needs to be called.

After sending a\r\n through the serial port assistant, after waiting for about 5 seconds, the angles of the X, Y, and Z axes will all be calibrated to a state of about 0 degrees.

More

Please reference to the sensor datasheet.

Last updated