© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
DevHeads IoT Integration ServerDIIS
DevHeads IoT Integration Server•16mo ago•
7 replies
Sterling

Issues with I2C Communication to VL53L0X Sensor Using STM32F103C8 Without ST Library

I am using the VL53L0X sensor with an STM32F103C8 microcontroller and want to communicate with the sensor directly over I2C without using ST's library. My goal is to minimize project size and better understand the low-level protocol.

I’ve initialized the I2C interface using CMSIS and am sending commands like setting the control register and reading measurement data, but I’m getting inconsistent responses.
See how I initialized the i2c:

// I2C initialization using CMSIS
I2C1->CR1 |= I2C_CR1_PE;  
I2C1->CR2 |= (36 << I2C_CR2_FREQ_Pos);
I2C1->CCR = 180;
I2C1->TRISE = 37;

// Sending and reading I2C data
I2C1->DR = (VL53L0X_ADDR << 1); 
while (!(I2C1->SR1 & I2C_SR1_TXE)) {}
I2C1->DR = REG_COMMAND;
while (!(I2C1->SR1 & I2C_SR1_RXNE)) {}
uint8_t response = I2C1->DR;
// I2C initialization using CMSIS
I2C1->CR1 |= I2C_CR1_PE;  
I2C1->CR2 |= (36 << I2C_CR2_FREQ_Pos);
I2C1->CCR = 180;
I2C1->TRISE = 37;

// Sending and reading I2C data
I2C1->DR = (VL53L0X_ADDR << 1); 
while (!(I2C1->SR1 & I2C_SR1_TXE)) {}
I2C1->DR = REG_COMMAND;
while (!(I2C1->SR1 & I2C_SR1_RXNE)) {}
uint8_t response = I2C1->DR;


Has anyone successfully worked with the VL53L0X directly over I2C without the library? Any tips on improving communication?

If the ST library is necessary, could someone explain how to integrate it with CMSIS? I prefer CMSIS due to size constraints and learning purposes, but I'm open to using the library if needed.

Any help would be appreciated!
DevHeads IoT Integration Server banner
DevHeads IoT Integration ServerJoin
The DevHeads IoT Integration Server accelerates technology engineering by helping pro devs learn, share and collaborate.
2,984Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Verifying I2C Communication on BeagleBone Black for VL53L0X and OLED Display
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🪲-firmware-and-baremetal
2y ago
Issues with MATCH ROM Command in DS18B20 Sensor Communication on STM32 Using UART
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🪲-firmware-and-baremetal
17mo ago
Establishing Communication Between ESP32 and R307 Fingerprint Sensor: Initialization Issues
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🪲-firmware-and-baremetal
17mo ago
Guidance on Interfacing VL53L0X Sensor and OLED Display with BeagleBone Black for Parking Assistance
DevHeads IoT Integration ServerDIISDevHeads IoT Integration Server / 🪲-firmware-and-baremetal
2y ago