Getting Errno 121 on Initialization of VL53L5CX Sensor
Hello,
I am developing a sensor board using the Raspberry Pi Zero 2W with the VL53L5CX IC by itself, not a breakout board. However, I am running into a problem when trying to read in the sensor data using a simple test script offered by Pimorini. I also have the VL53L5CX breakout board from Pimorini which I connect to the same pins and run the same script and it works just fine.
Here is the error:
Uploading firmware, please wait...
Exception ignored on calling ctypes callback function: <function VL53L5CX.__init__.<locals>._i2c_write at 0x7fac3ca0c0>
Traceback (most recent call last):
File "/home/pi/dronepi/env/lib/python3.11/site-packages/vl53l5cx_ctypes/__init__.py", line 125, in _i2c_write
self._i2c.i2c_rdwr(msg_w)
File "/home/pi/dronepi/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 121] Remote I/O error
Exception ignored on calling ctypes callback function: <function VL53L5CX.__init__.<locals>._i2c_write at 0x7fac3ca0c0>
Traceback (most recent call last):
File "/home/pi/dronepi/env/lib/python3.11/site-packages/vl53l5cx_ctypes/__init__.py", line 125, in _i2c_write
self._i2c.i2c_rdwr(msg_w)
File "/home/pi/dronepi/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 5] Input/output error
Exception ignored on calling ctypes callback function: <function VL53L5CX.__init__.<locals>._i2c_write at 0x7fac3ca0c0>
Traceback (most recent call last):
File "/home/pi/dronepi/env/lib/python3.11/site-packages/vl53l5cx_ctypes/__init__.py", line 125, in _i2c_write
self._i2c.i2c_rdwr(msg_w)
File "/home/pi/dronepi/env/lib/python3.11/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 5] Input/output error
The OSError: [Errno 5] then repeats every loop.
I encounter the exact same OSError: [Errno 121] remote I/O error when running the example script from a similar Python wrapper for the VL53L5CX STM driver: link. Where the self._i2c.i2c_rdwr(msg_w) fails.
-
I am pretty sure my schematic is correct, as I have made sure it is identical to both the typical application schematic in the STM VL53L5CX Datasheet as well as the open-sourced schematic by SparkFun
-

And the SDA and SCL lines are pulled up to 3.3V using 2.2k ohm resistors elsewhere in the schematic.
- I am 90% sure there is not a problem with the manufacturing of the sensor or the mounting of the sensor because I personally soldered 2 versions of the PCB using 2 different ToF sensors to double-check this and encounter the same error.
- I know the sensor is alive because I can detect it alive at address 0x29 and I know my I2C bus is working because I have 2 other I2C sensors on the same SDA/SCL lines that work just fine using I2C fast mode.
- I do not believe it to be an operating system problem because I encountered the exact same error using both Raspian OS and Ubuntu 22.04 on the Raspberry Pi. I also have a Pimorini VL53L5CX I use with the exact same code and it works perfectly.
- I have also tried adding a pause in the init function of the smbus as described in this post on stack overflow which did not do anything.
Considering these things I have tried, I have concluded that the error must be either software-related, or my wiring is wrong (and I cannot see how it is wrong, maybe someone can see some dumb mistake I made that I cannot).
Does anyone have an answer or an idea as to why this error would occur? I am unfamiliar with the low-level I2C communications programming so I find this particularly difficult to debug.
Any and all help would be greatly appreciated. Please let me know if there is any other information I can provide.
Sincerely,
Andrew
