How to run a ToF sensor with a Nucleo board in Arduino IDE
This article is for people who are used to develop their applications using the Arduino IDE but who are not familiar yet with how to use ST products in the Arduino world. This concept combines the best performance hardware with an easy Arduino IDE for fast prototyping. The goal of this article is to show how to get started using the Arduino IDE and ST’s most popular STM32 board with ST’s most popular Time-of-Flight sensor. In this article the X-NUCLEO-53L1A1 and a NUCLEO-F401RE will be used as an example. Please check out the article here to see all other ST Time-of-Flight sensor libraries available.
Install Arduino IDE
First, one needs to install the Arduino IDE if it is not done, there are many videos on the subject. A good example is here.
Install STM32 board libraries in IDE
Once the Arduino IDE is installed, please watch a STM32duino video, by Carlo PARATA, to learn how to install the STM32 board libraries in the IDE.
Figure 1 TheSTM32duino/VL53L1X contains only the VL53L1X device Arduino Library. This library is required to be installed to allow to use the examples included in the next library. The STM32duino/X-NUCLEO-53L1A1 contains the library supporting the expansion board (X-NUCLEO-53L1A1) and the examples.
3.2 Add library
Once the two zip files are downloaded, click on Sketch/Include Library/Add ZIP Library and browse to the directory where the two ZIP files have been downloaded to install the two libraries. Figure 2
3.3 Load example sketch
Once both libraries are installed, click on File/Examples/STM32duino X-NUCLEO-53L1A1/STM32duino/X-NUCLEO-53L1A1_HelloWord_Interrupt to load the example sketch into the IDE (fig 3) Figure 3
3.4 Select the Nucleo board
Select the right Nucleo board F401RE target (fig 4) Figure 4
3.5 Select the right COM port (fig 5)
Figure 5
3.6 Compile and flash the Arduino board (fig 6)
Figure 6
3.7 Open the serial monitor (fig 7)
Figure 7
3.8 Result
The ranging result should be displayed on a serial terminal as shown in figure 8 Figure 8