 In the previous video, we saw how to get started with the creation of the project using STM32Q by D for the acquisition of the accelerometer. In this third section of the up-note video, we are going to add the pre-trained Keras model to process the accelerometer data using STM32Q.AI. We are back to our high-level diagram of the application. In the previous video, we focused on the initialization phase with the configuration of the peripherals, like I2C and UART, and the accelerometer acquisition. In this video, we will be focusing on the last step, how to add the pre-trained neural network model using STM32Q.AI, and how to output the inference results. Before getting started with the STM32Q by D project, if you go on the wiki page, you can find the pre-trained Keras model. You may want to download this file now, we will use it later in the video. You can also find a Python notebook that can be used to train your own model, and also a ready-to-use dataset of three-axis acceleration data for various human activities. Now we are back into STM32Q by D, and we need to add STM32Q.AI to our project. To do so, we are going to open the IOC file. In the Pinout and Configuration tab, we are going to click on Software Pack, select Components, click on Artificial Intelligence, and enable the core, then click OK. Now we are going to add the Keras model to the XQBI configuration. So we click on Software Pack, XQBI, here on the bottom we are going to click Add Network, make sure that the model is selected as Keras, then we are going to select the model. I already downloaded it here in Download, select the model. Optionally you can click on Analyze to view the model memory footprint, occupation, and complexity, otherwise you can simply click Project, Generate Code. Now we are going to open the main .c. In the generated project we can see the XQBI folder here, and inside the app folder we can find the Network.c file that contains the topology of our model, and the Network Data.c that contains the model parameters. Let's close and go back with the main .c. Now we can start copying the code from the wiki page that is needed to interact with the AI model as we did in the previous video. We are going to start by copying the include header files here. Then we go back to the wiki page and we are going to add all the variables needed to pass the data. Then we can go back to the wiki page and copy the definition of the functions that we are going to use. Here we paste the function definition. Now we are going to copy the implementation of the AI init function. Make sure to copy all the functions here. Go back to QBiD and we are going to add this function in the user code begin. Here we go back to the wiki page and we copy also the AI run function. Paste this function and go back to the wiki page. We are going to add also the argmax function. This function is used to return the index of the highest scored output. Copy paste. Now we are going to call the previously implemented AI init function inside the main after the mems init. Our main after the mems init. We are going to call the AI init. Then we are going to update the main while loop. First we are going to define this variable, write index here. And then we are going to comment the printf used in the previous video and we are going to add all the code needed to take the sensor data, pass it to the AI run and then do the printf of the inference output. Here I am going to comment this and paste our code. In the code that we just copied we are using the %f in the printf and that's not supported by default. So in order to fix this we are going to go project properties and after cc++ speed settings to settings we are going to enable the use float with the printf, apply and close and now these issues should be solved. Now we can build and run the project. First we are going to build the project. Done, we should get zero error and zero warning. Now we can run the project. I already have the board connected to my PC. You can simply click run. Now we have the board programmed with our latest firmware. In progress, shut down so the board is programmed correctly. Now we can open TerraTerm as we did in the previous video. In this case we are going to check the inference output. In the serial port settings we are going to adjust the board rate. You should also see the board live in the top right of the screen. So when the board is at rest the serial output display should be stationary. If you move the board up and down slowly it's going to say walking and if you shake the board quickly the serial output should be running. And then back to stationary if I stop shaking the board. Okay, we are at the end of this video up note and I just want to underline some useful resources that you can use to dive in more specifics. Here you can find some useful links. The first one is the wiki page associated with the application note. In the wiki page you can find more details and a Python script to train your own model. The second one is the STM32 cube function pack for ultralow power IoT node with artificial intelligence applications based on audio and motion sensing. Finally at www.st.com slash STM32 cube AI you can find more resources to experiment AI using STM32. Thank you for watching.