{"id":4287,"date":"2020-01-08T20:00:37","date_gmt":"2020-01-08T19:00:37","guid":{"rendered":"https:\/\/msalamon.pl\/?p=4287"},"modified":"2025-12-27T18:27:42","modified_gmt":"2025-12-27T17:27:42","slug":"low-cost-laser-distance-measurement-with-the-vl53l0x-tof-sensor","status":"publish","type":"post","link":"https:\/\/msalamon.pl\/en\/low-cost-laser-distance-measurement-with-the-vl53l0x-tof-sensor\/","title":{"rendered":"Low-Cost Laser Distance Measurement with the VL53L0X ToF Sensor"},"content":{"rendered":"\n<p>Anyone who has spent even a moment dealing with robotics knows that distance measurement plays an incredibly important role in this field. Practically everywhere we deal with devices that move, some kind of obstacle detection is advisable. This is often implemented by measuring distance.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Such measurement can be done in many ways. The methods differ in operating speed, accuracy, and the maximum measurable distance that can be achieved.<\/p>\n\n\n\n<p>Among these solutions, ultrasonic sensors are incredibly popular. For just a few zlotys you can buy an <a href=\"https:\/\/sklep.msalamon.pl\/produkt\/hc-sr04-dalmierz-ultradzwiekowy\/?utm_source=blog&amp;utm_medium=article&amp;utm_campaign=vl053l0x&amp;utm_content=Text\">HC-SR04<\/a>, which performs perfectly not only in hobby electronics. One of its drawbacks is size. It won\u2019t be suitable for a small robot, and it\u2019s also hard to hide.<\/p>\n\n\n\n<p>Small laser sensors come to the rescue. Today I took a closer look at an ST sensor labeled <a href=\"https:\/\/sklep.msalamon.pl\/?s=VL53L0X&amp;post_type=product&amp;utm_source=blog&amp;utm_medium=article&amp;utm_campaign=vl053l0x&amp;utm_content=Text\">VL53L0X<\/a>.<\/p>\n\n\n\n<p><a href=\"http:\/\/msalamon.pl\/obsluga-przerwaniowa-czujnika-laserowego-vl53l0x\/\">You can find the second part with interrupt handling here<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Micro ToF sensor VL53L0X<\/h1>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/sklep.msalamon.pl\/?s=vl053&amp;post_type=product&amp;utm_source=blog&amp;utm_medium=banner&amp;utm_campaign=vl053l0x&amp;utm_content=vl53l0x\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"400\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner.png\" alt=\"\" class=\"wp-image-1372\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner.png 1200w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-300x100.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-1024x341.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-768x256.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-24x8.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-36x12.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/VL53L0X-baner-160x53.png 160w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>This is a <a href=\"https:\/\/sklep.msalamon.pl\/?s=VL53L0X&amp;post_type=product&amp;utm_source=blog&amp;utm_medium=article&amp;utm_campaign=vl053l0x&amp;utm_content=Text\">ToF<\/a> (Time-of-Flight) sensor, meaning that distance is measured by timing the flight of, in this case, a laser beam. The sensor checks how long it takes for light to reach the object, bounce off it, and return to the receiving sensor. Ultrasonic sensors work in a similar way.<\/p>\n\n\n\n<p>ST boasts that this is the <strong>smallest laser sensor in the world<\/strong>, and the dimensions are indeed impressive. The whole little chip measures only 4.4 x 2.4 x 1 mm, so it\u2019s just slightly larger than a resistor in a 1206 package.&nbsp;<\/p>\n\n\n\n<p>The laser used in the sensor, with a wavelength of 940 nm, is designed to meet standards for use around the \u201cnaked\u201d eye. Being around it should not pose any risk.<\/p>\n\n\n\n<p>Interestingly, such lasers are sometimes used to aid autofocus in digital cameras. Some older smartphones boasted laser autofocus\u2014I even had one. Now I don\u2019t recall any newer handsets having a laser. Maybe it wasn\u2019t that great.<\/p>\n\n\n\n<p>The sensor communicates with the host via the I\u00b2C interface. In addition to the standard bus pins, there\u2019s also an interrupt output and an input for turning the sensor off.<\/p>\n\n\n\n<p>ST includes a complete library with the sensor, which they proudly call an API. It contains probably everything you can do with the chip. This is quite a good move, because the chip is very complex for a simple sensor. It contains dozens of registers you can talk to. For beginners, this can cause quite a headache.<\/p>\n\n\n\n<p>However, simply using the library can also lead to a migraine. The library is written in a generic way, so it takes up a lot of code. It\u2019s no secret that lots of code means lots of Flash memory. I\u2019ll check how much it actually is.<\/p>\n\n\n\n<p>Additionally, it\u2019s very hard to find sensible descriptions of how to use this sensor. You have to dig through the inhumanly written API documentation and examples for Nucleo boards and shields with these sensors.<\/p>\n\n\n\n<p>The Getting Started guides I mostly found boil down to taking the same Nucleo as in the examples, flashing a prebuilt binary, and enjoying the results. No no no, ST\u2026<\/p>\n\n\n\n<p>Enough of my whining. Let\u2019s move on to how to run this bulky API on any microcontroller.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What do you need?<\/h2>\n\n\n\n<p>You will of course need a microcontroller. Specifically, an STM32. Today I took the <a href=\"https:\/\/sklep.msalamon.pl\/produkt\/stm32f401ccu6-dev-board\/?utm_source=blog&amp;utm_medium=article&amp;utm_campaign=vl053l0x&amp;utm_content=Text\">STM32F401CCU6<\/a> from the new items in my store. I wrote more broadly about these boards in <a href=\"http:\/\/msalamon.pl\/pogromca-bluepill-nadchodzi-nowe-czyli-blackpill-z-stm32f4\/\">one of the previous articles<\/a>.<\/p>\n\n\n\n<p>As development tools, I used STM32CubeIDE version 1.1.0, which has the integrated STM32CubeMX 5.4.0. The HAL libraries I use are F4 v1.24.2.<\/p>\n\n\n\n<p>Besides the board and the IDE, you also need the aforementioned API. <a href=\"http:\/\/msalamon.pl\/download\/1347\/\">You can find it here<\/a>.<\/p>\n\n\n\n<p>And finally, a <a href=\"http:\/\/msalamon.pl\/download\/1349\/\">package with an add-on for Cube<\/a> for the Nucleo shield with our sensor will come in handy. I\u2019ll explain in a moment why both the API and the Cube extension are needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project in Cube<\/h2>\n\n\n\n<p>Choose the F401CEU6 CPU, unless you have a different one. First, the clock. For tests I like to use the highest possible frequencies. I set 84 MHz HCLK using the external 25 MHz crystal found on the board. To use it, in the RCC tab you need to select <strong>High Speed Clock (HSE)<\/strong> as <strong>Crystal\/Ceramic Resonator<\/strong>. Then in <strong>Clock Configuration<\/strong> from the top menu, enter the number <strong>84 in the HCLK field and press Enter<\/strong>. Cube will calculate everything for you \ud83d\ude42<\/p>\n\n\n\n<p>For communication you\u2019ll need I\u00b2C, so configure one of the available interfaces. I chose <strong>I2C1 on pins PB8 and PB9<\/strong>. The sensor supports 400 kHz, and you should stick to that. For comparison, leave me 100 kHz \ud83d\ude42<\/p>\n\n\n\n<p>I will send the measurement results via UART. Initially I wanted to use USB, but that\u2019s a bit more hassle. I\u2019ll cover USB another time \ud83d\ude42 <strong>I took USART2 as usual<\/strong>, like on every Nucleo, and connected to the PC through a converter. I set it to 115200 8n1. No surprises.<\/p>\n\n\n\n<p>Remember that the ToF sensor has two more pins \u2014 the interrupt called <strong>GPIO1 on the board and XSHUT<\/strong> for turning the sensor off. <strong>I connected both to the microcontroller<\/strong>. While I will definitely use the interrupt, XSHUT may not be needed right now.<\/p>\n\n\n\n<p><strong>When would XSHUT be needed<\/strong>? The first thing that comes to mind is saving energy. That\u2019s true, but another situation where you can use it is connecting multiple sensors to one bus. Unfortunately, VL53L0X sensors don\u2019t have a configurable I\u00b2C address, so you have to get creative this way. XSHUT allows switching between sensors without reinitializing them.<\/p>\n\n\n\n<p>This is how the \u201cschematic\u201d from Cube looks.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic.png\"><img loading=\"lazy\" decoding=\"async\" width=\"586\" height=\"610\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic.png\" alt=\"\" class=\"wp-image-1368\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic.png 586w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic-288x300.png 288w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic-24x24.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic-36x36.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_schematic-77x80.png 77w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Launching the VL53L0X API<\/h2>\n\n\n\n<p>I won\u2019t hide that it was hard for me to find on ST\u2019s pages how to use the API. Texts pointing to documentation describing the use of the API led to a pointless 2-page document that only showed the API directory structure. Who needs that? In the end I pieced together several different tips from the Internet, read some of the massive documentation, and it worked \ud83d\ude42 Here\u2019s what I did.<\/p>\n\n\n\n<p>Unpack the packages with the API and the Nucleo add-on. The first thing to do is copy the API into your project. It\u2019s the entire contents of <strong>..\\VL53L0X_1.0.2\\Api\\<\/strong><\/p>\n\n\n\n<p>I put it into the <strong>Drivers<\/strong> directory in the project.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api.png\"><img loading=\"lazy\" decoding=\"async\" width=\"256\" height=\"344\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api.png\" alt=\"\" class=\"wp-image-1351\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api.png 256w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api-223x300.png 223w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api-18x24.png 18w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api-27x36.png 27w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_api-60x80.png 60w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Now you need to add the header and source file paths to the project. Do this by going to <strong>Project &gt; Properties &gt; C\/C++ General &gt; Paths and Symbols<\/strong>. In the <strong>Includes<\/strong> tab, <strong>add the inc folders from the API<\/strong>, and in the <strong>Source Location<\/strong> tab, add the <strong>src folders<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes.png\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"550\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes.png\" alt=\"\" class=\"wp-image-1354\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes.png 825w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-300x200.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-768x512.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-360x240.png 360w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-24x16.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-36x24.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes-120x80.png 120w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/a><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"550\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2.png\" alt=\"\" class=\"wp-image-1355\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2.png 825w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-300x200.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-768x512.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-360x240.png 360w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-24x16.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-36x24.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_includes2-120x80.png 120w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/a><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors.png\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"237\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors.png\" alt=\"\" class=\"wp-image-1356\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors.png 741w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors-300x96.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors-24x8.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors-36x12.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_api_errors-160x51.png 160w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p> The header you need to include in main.c is <strong>vl53l0x_api.c<\/strong>. Unfortunately, attempting to compile with the API added will throw a few errors.The compiler tells us it\u2019s missing the file\u2026 windows.h?! It turns out that within the API there are files corresponding to the platform on which we want to use it. When downloading the API from ST\u2019s website, it\u2019s configured by default to work on Windows and includes such examples. In my opinion this is a bit strange, but OK. We need to make sure that the platform is configured as our microcontroller.&nbsp;<\/p>\n\n\n\n<p>For this we will use the Cube extension package for our sensor. As it happens, it\u2019s written using HAL, so no matter which Nucleo the examples were written for, porting will be simple.<\/p>\n\n\n\n<p>First, <strong>remove the file vl53l0x_i2c_win_serial_comms.c<\/strong> which is tied to Windows.<\/p>\n\n\n\n<p>Second, unpack <strong>X-CUBE-53L0A1<\/strong> <strong>and from the folder<\/strong> <strong>..\\X-CUBE-53L0A1\\STM32CubeExpansion_VL53L0X_V1.2.0\\Drivers\\BSP\\X-NUCLEO-53L0A1<\/strong> <strong>copy the files vl53l0x_platform.h and vl53l0x_platform.c<\/strong> to the appropriate places in the project. <strong>Overwrite them.<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"178\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-300x178.png\" alt=\"\" class=\"wp-image-1357\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-300x178.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-1024x608.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-768x456.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-1536x913.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-24x14.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-36x21.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform-135x80.png 135w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_add_platform.png 1636w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>We\u2019re close \ud83d\ude42 Now similarly <strong>copy the pair vl53l0x_platform_log. h and .c&nbsp;<\/strong><strong>this time from the path ..\\X-CUBE-53L0A1\\STM32CubeExpansion_VL53L0X_V1.2.0\\Drivers\\BSP\\Components\\vl53l0x.<\/strong><\/p>\n\n\n\n<p>These files are responsible for logging the API operation on the platform. By default they are disabled, and the ones from the API were written for Windows. I have not tested their operation.<\/p>\n\n\n\n<p>If you compile now, you will probably have one error left. <strong>The compiler cannot find stm32xxx_hal.h<\/strong> to include it in vl53l0x_platform.h and .c. The platform files were written some time ago when the HAL files were named slightly differently.<\/p>\n\n\n\n<p>It\u2019s enough to replace the line <strong>#include \u201cstm32xxx_hal.h\u201d in the files<\/strong> <strong>vl53l0x_platform.h and .c with the appropriate header for your microcontroller. In my case, for the F4 family it will be #include \u201cstm32f4xx_hal.h\u201d.<\/strong><\/p>\n\n\n\n<p>Now compilation went through without errors. We should also run a simple measurement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the API for a single measurement<\/h2>\n\n\n\n<p>If you haven\u2019t previously included the header vl53l0x_api.h in main.c, do it now. Then you will need a few variables for the sensor to work.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">VL53L0X_RangingMeasurementData_t RangingData;\nVL53L0X_Dev_t  vl53l0x_c; \/\/ center module\nVL53L0X_DEV    Dev = &amp;amp;vl53l0x_c;<\/pre>\n\n\n\n<p>The first is the structure with measurements. The second is the device structure. The third is a pointer to the structure from point no. 2.<\/p>\n\n\n\n<p>For initialization you need a few helper variables. I put them in user section no. 1.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  \/* USER CODE BEGIN 1 *\/\n\t\/\/\n\t\/\/ VL53L0X initialisation stuff\n\t\/\/\n    uint32_t refSpadCount;\n    uint8_t isApertureSpads;\n    uint8_t VhvSettings;\n    uint8_t PhaseCal;\n  \/* USER CODE END 1 *\/<\/pre>\n\n\n\n<p>and the sensor initialization<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  \/* USER CODE BEGIN 2 *\/\n  MessageLen = sprintf((char*)Message, \"msalamon.pl VL53L0X test\\n\\r\");\n  HAL_UART_Transmit(&amp;amp;huart2, Message, MessageLen, 100);\n\n  Dev-&amp;gt;I2cHandle = &amp;amp;hi2c1;\n  Dev-&amp;gt;I2cDevAddr = 0x52;\n\n  HAL_GPIO_WritePin(TOF_XSHUT_GPIO_Port, TOF_XSHUT_Pin, GPIO_PIN_RESET); \/\/ Disable XSHUT\n  HAL_Delay(20);\n  HAL_GPIO_WritePin(TOF_XSHUT_GPIO_Port, TOF_XSHUT_Pin, GPIO_PIN_SET); \/\/ Enable XSHUT\n  HAL_Delay(20);\n\n  \/\/\n  \/\/ VL53L0X init for Single Measurement\n  \/\/\n\n  VL53L0X_WaitDeviceBooted( Dev );\n  VL53L0X_DataInit( Dev );\n  VL53L0X_StaticInit( Dev );\n  VL53L0X_PerformRefCalibration(Dev, &amp;amp;VhvSettings, &amp;amp;PhaseCal);\n  VL53L0X_PerformRefSpadManagement(Dev, &amp;amp;refSpadCount, &amp;amp;isApertureSpads);\n  VL53L0X_SetDeviceMode(Dev, VL53L0X_DEVICEMODE_SINGLE_RANGING);\n\n  \/\/ Enable\/Disable Sigma and Signal check\n  VL53L0X_SetLimitCheckEnable(Dev, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, 1);\n  VL53L0X_SetLimitCheckEnable(Dev, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, 1);\n  VL53L0X_SetLimitCheckValue(Dev, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, (FixPoint1616_t)(0.1*65536));\n  VL53L0X_SetLimitCheckValue(Dev, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, (FixPoint1616_t)(60*65536));\n  VL53L0X_SetMeasurementTimingBudgetMicroSeconds(Dev, 33000);\n  VL53L0X_SetVcselPulsePeriod(Dev, VL53L0X_VCSEL_PERIOD_PRE_RANGE, 18);\n  VL53L0X_SetVcselPulsePeriod(Dev, VL53L0X_VCSEL_PERIOD_FINAL_RANGE, 14);\n  \/* USER CODE END 2 *\/<\/pre>\n\n\n\n<p>At the beginning I introduce myself \ud83d\ude09 Next it\u2019s important to initialize the fields in the Dev structure. You need to specify which I\u00b2C you\u2019re using by providing a reference to the HAL handle structure. You also provide the sensor address (which, in fact, cannot be changed).<\/p>\n\n\n\n<p>Then I toggle the XSHUT pin. It\u2019s a bit over the top, but I can.<\/p>\n\n\n\n<p>Finally, the sensor is initialized to operate in single-measurement mode. I took this from the examples for Windows \ud83d\ude42 They turned out to be useful after all. As you can see, we initialize some timing and range constants. These sensors are really quite elaborate, and I\u2019ll analyze this in more depth.<\/p>\n\n\n\n<p>After all this initialization, you can put the measurement in the main loop of the program.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\t  VL53L0X_PerformSingleRangingMeasurement(Dev, &amp;amp;RangingData);\n\n\t  if(RangingData.RangeStatus == 0)\n\t  {\n\t\t  MessageLen = sprintf((char*)Message, \"Measured distance: %i\\n\\r\", RangingData.RangeMilliMeter);\n\t\t  HAL_UART_Transmit(&amp;amp;huart2, Message, MessageLen, 100);\n\t  }\n<\/pre>\n\n\n\n<p>Unfortunately, <strong>this is a blocking measurement<\/strong> that doesn\u2019t use the interrupt pin. However, it works! The measurement is in millimeters.<\/p>\n\n\n\n<p>The value RangingData.RangeStatus contains information on whether the measurement succeeded. A nice thing to filter out bad readings.&nbsp;<\/p>\n\n\n\n<p><strong>You\u2019ll find the distance under RangingData.RangeMilliMeter.<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"192\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result-300x192.png\" alt=\"\" class=\"wp-image-1358\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result-300x192.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result-24x15.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result-36x23.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result-125x80.png 125w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_result.png 688w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Some measurements and numbers<\/h2>\n\n\n\n<p>I wouldn\u2019t be myself if I didn\u2019t peek at the analyzer, right? First, the entire measurement \u201ccycle\u201d. Fortunately, the interrupt pin is toggling all the time, so it\u2019s easier for me to capture the appropriate timing.<\/p>\n\n\n\n<p>100 kHz<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"138\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-1024x138.png\" alt=\"\" class=\"wp-image-1359\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-1024x138.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-300x40.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-768x103.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-1536x206.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k-160x22.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_100k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>400 kHz<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"140\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-1024x140.png\" alt=\"\" class=\"wp-image-1360\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-1024x140.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-300x41.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-768x105.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-1536x210.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k-160x22.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_400k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Between successive \u201cinterrupts\u201d there\u2019s 41 ms for 100 kHz and 36 ms for 400 kHz. According to the documentation, sampling and computing the distance takes ~31 ms, so adding I\u00b2C transmission time could fit. As you can see, quite a bit of data goes over the bus. The smaller bars are polling the sensor to check whether it\u2019s finished. That\u2019s obvious when we operate in polling mode. However, there are two wider bars. The first is the measurement start.<\/p>\n\n\n\n<p>100 kHz<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"140\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-1024x140.png\" alt=\"\" class=\"wp-image-1361\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-1024x140.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-300x41.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-768x105.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-1536x210.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k-160x22.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_100k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>400 kHz<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"140\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-1024x140.png\" alt=\"\" class=\"wp-image-1362\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-1024x140.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-300x41.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-768x105.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-1536x210.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k-160x22.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_perform_meas_400k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>3.14 ms for 100 kHz vs 0.84 ms for 400 kHz. That matches the theory \ud83d\ude42<br>All that remains is to check how long the MCU takes to collect the measurement.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"143\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-1024x143.png\" alt=\"\" class=\"wp-image-1363\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-1024x143.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-300x42.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-768x107.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-1536x214.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k-160x22.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_100k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>100 kHz400 kHz<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"146\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-1024x146.png\" alt=\"\" class=\"wp-image-1364\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-1024x146.png 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-300x43.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-768x110.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-1536x219.png 1536w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-36x5.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k-160x23.png 160w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/01\/vl53l0x_single_read_polling_read_data_400k.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>2.8 ms for 100 kHz vs 0.795 ms for 400 kHz.<\/p>\n\n\n\n<p>As you can see, there\u2019s quite a lot of data to collect from such a sensor. Ideally, you\u2019d bring in interrupt mode, and best together with DMA. For now, I don\u2019t know if the API supports this. I\u2019ve already spent some time wrestling with getting it to run.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code size<\/h2>\n\n\n\n<p>At the beginning I mentioned that this API is somewhat heavy. In the table I included bare code with configured peripherals without the API and code with the API. Both versions with optimization -O1 and without -O0. Here are the numbers.<\/p>\n\n\n\n<figure class=\"wp-block-table tablepress tablepress-id-15\"><table class=\"has-fixed-layout\"><thead><tr><td><\/td><th>-O0<\/th><th>-O1<\/th><\/tr><\/thead><tbody><tr><td>Bare code<\/td><td>8,73 KB<\/td><td>5,57 KB<\/td><\/tr><tr><td>with API<\/td><td>36 KB<\/td><td>22,52 KB<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>As you can see, this API weighs a bit\u2026 Is it worth it? I\u2019m not yet able to answer that. I\u2019ll try to do something with interrupts or DMA \ud83d\ude42<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/sklep.msalamon.pl\/kategoria-produktu\/dev-boardy\/stm32-nucleo\/?utm_source=blog&amp;utm_medium=banner&amp;utm_campaign=vl053l0x&amp;utm_content=nucleo\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"400\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner.jpg\" alt=\"\" class=\"wp-image-1593\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner.jpg 1200w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-300x100.jpg 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-1024x341.jpg 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-768x256.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/sklep.msalamon.pl\/?s=VL53L0X&amp;post_type=product&amp;utm_source=blog&amp;utm_medium=article&amp;utm_campaign=vl053l0x&amp;utm_content=Text\">VL53L0X<\/a> sensor is nice, small, but somewhat complicated. The API helps a lot, but it costs a lot of space on the microcontroller. I\u2019ll still check what possibilities there are for using this library with interrupts or DMA.<\/p>\n\n\n\n<p>There are also Arduino libraries written based on this API. I\u2019ve seen that they\u2019re a bit lighter. I might take a look at them as well.<\/p>\n\n\n\n<p><a href=\"http:\/\/msalamon.pl\/obsluga-przerwaniowa-czujnika-laserowego-vl53l0x\/\">You can find the second part with interrupt handling here<\/a><\/p>\n\n\n\n<p>You can find the full project along with the library, as usual, on my GitHub: <a href=\"https:\/\/github.com\/lamik\/VL53L0X_API_STM32_HAL\" target=\"_blank\" rel=\"noopener\">link<\/a><\/p>\n\n\n\n<p><span>If you\u2019ve noticed an error, disagree with something, would like to add something important, or simply feel like discussing this topic, write a comment. Remember that the discussion should be polite and in accordance with the rules of the Polish language.<\/span><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;4287&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;0&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Low-Cost Laser Distance Measurement with the VL53L0X ToF Sensor&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\"><\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Anyone who has spent even a moment dealing with robotics knows that distance measurement plays an incredibly important role in this field. Practically everywhere we deal with devices that move, some kind of obstacle detection is advisable. This is often implemented by measuring distance.<\/p>\n","protected":false},"author":1,"featured_media":3374,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[160],"tags":[176,174,177],"class_list":["post-4287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stm32","tag-programming","tag-stm32","tag-stm32cubemx"],"_links":{"self":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/comments?post=4287"}],"version-history":[{"count":3,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4287\/revisions"}],"predecessor-version":[{"id":4389,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4287\/revisions\/4389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/media\/3374"}],"wp:attachment":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/media?parent=4287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/categories?post=4287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/tags?post=4287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}