After receiving the X-NUCLEO-IKS01A3 kit, I have been searching and downloading materials, reading relevant manuals and analyzing codes. I used the STM32F401RE development board and tested it under the Keil V5.28 platform. After several days of repeated tests, the STTS751 temperature sensor finally passed the test. In order to make the test more intuitive, I also added LCD5110 as a display. The following is a detailed description of the test process.
1. Hardware Connection
Before starting the test, the first thing to consider is how to connect the wires. At first, I followed my habit and looked up the wiring definitions on the sensor board in the downloaded materials so that I could connect it to the development board with Dupont wires. Later, I learned that the pins of both boards followed the Arduino UNO R3 specification, so I just had to plug them in directly. No wonder there is a notch on the sensor board, which is just for operating the buttons on the development board and observing the LED lights. When I first got the sensor board, I wondered why it was made into such an irregular shape.
After plugging in the sensor board, the notch is facing the button and LED light on the development board:
2. Software and Development Platform
After the hardware connection is solved, the next step is the software and development platform. After downloading, decompressing and checking multiple software packages, I found that the STM32CubeExpansion_MEMS_V6.20 software package is the latest version.
In the projects subfolder of this software package, there are four types of STM32 development board materials, including the STM32F401RE-Nucleo development board. This is undoubtedly good news for a beginner like me, and it can help me avoid many detours.
After clicking in, there are two subfolders: Applictions and Examples. My English is poor, so I took screenshots of these two folders and marked them in Chinese for easy use.
I saw from the " ST_Open_MEMS Tutorial" that I first had to accept the software license agreement online and obtain the development board key before I could unlock it (as shown in the figure below). I looked everywhere for the interface to accept the license online. I finally found one, but it didn't work after I clicked it. Then I saw that I needed a " Sensor Fusion GUI " software to assist with debugging, but I couldn't download it after searching for a long time. Finally, I decided to add an LCD5110 display to display the test process.
3. Add LCD5110 display
This addition was not a difficult task for me. After selecting the pins to drive the LCD , I connected the LCD with Dupont wires , and then transplanted the corresponding code.
I put all the LCD driver, display files and font files in the mydrive folder. I just need to copy this folder, set the search path, and write the following code in the main program:
LCD_init(); // Initialize LCD5110
display_main();
The following picture shows the LCD display that is ready to be added :
The following are test photos:
The following image shows what is displayed on the initial screen:
4. STTS751 temperature sensor test
For the first use, I naturally opened the "Example" folder first, selected the " IKS01A3 " subfolder, and then opened the STTS751 engineering example. In order to display the current temperature on the LCD screen, in the main loop of the main() function, I followed the clues to find the MX_MEMS_Process() function, and then found the Send_Temperature() function to get the variable name of the temperature. I figured out that the system uses the out_value.sign variable to indicate the positive and negative of the temperature value ( 0 is a positive number, and greater than 0 is a negative number), then the out_value.int variable represents the integer part of the temperature value, and the out_value.dec variable represents the decimal part. At this point, it is easy to display on the LCD screen. The following is the display code:
if (out_value.sign > 0)
LCD_write_ASCII(0,5,(uint8_t *)"TEMP:-");
else
LCD_write_ASCII(0,5,(uint8_t *)"TEMP:+");
LCD_write_ASCII(54,5,(uint8_t *)".");
LCD_write_value(36,5,3,0,0,(int)out_value.out_int);
LCD_write_value(59,5,2,0,1,(int)out_value.out_dec);
This is the testing process:
The following figure is the real-time temperature displayed dynamically:
The following figure is the comparison between the screen display and the serial communication data: