VL53L0X Reading suddenly becomes -1mm

Hi, Kyle,
I am using VL53L0X as water level sensor, It works fine when configured and readings were accurate enough but I found that after some time the sensor reading changes suddenly to -1mm and then it remains constant irrespective of water level. Here is mycodo log which shows sudden change in the reading but there is no error as such.
I was facing this issue in the past but i thought it was solved after up gradation.
After complete shutdown (Power Off and On) it starts working
Please help.
2023-01-31 10:48:47,295 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 133.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 18, 47, 289753)}}
2023-01-31 10:49:02,325 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 131.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 19, 2, 318764)}}
2023-01-31 10:49:17,318 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 130.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 19, 17, 312018)}}
2023-01-31 10:49:32,264 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 19, 32, 258154)}}
2023-01-31 10:49:47,261 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 131.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 19, 47, 255098)}}
2023-01-31 10:50:02,282 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 131.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 20, 2, 276416)}}
2023-01-31 10:50:17,268 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 20, 17, 262242)}}
2023-01-31 10:50:32,261 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 20, 32, 255246)}}
2023-01-31 10:50:47,269 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 20, 47, 263398)}}
2023-01-31 10:51:02,283 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 131.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 21, 2, 277431)}}
2023-01-31 10:51:17,274 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 21, 17, 268785)}}
2023-01-31 10:51:32,288 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: 132.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 21, 32, 278112)}}
2023-01-31 10:51:59,758 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 21, 59, 752193)}}
2023-01-31 10:52:14,120 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 22, 14, 114583)}}
2023-01-31 10:52:29,705 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 22, 29, 699148)}}
2023-01-31 10:52:44,082 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 22, 44, 76589)}}
2023-01-31 10:52:59,664 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 22, 59, 658367)}}
2023-01-31 10:53:14,283 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 23, 14, 277845)}}
2023-01-31 10:53:29,623 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 23, 29, 617086)}}
2023-01-31 10:53:44,088 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 23, 44, 82969)}}
2023-01-31 10:53:59,767 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 23, 59, 761296)}}
2023-01-31 10:54:14,117 - DEBUG - mycodo.controllers.controller_input_56141261 - Adding measurements to InfluxDB with ID 56141261-0c0a-47d2-a3e4-4f1c13eb42aa: {0: {‘measurement’: ‘length’, ‘unit’: ‘mm’, ‘value’: -1.0, ‘timestamp_utc’: datetime.datetime(2023, 1, 31, 5, 24, 14, 111565)}}

Vl53L0X.txt (6.2 KB)

I believe that is a bad connection. At least that is my experience.

I did notice when I tested that device from a bare metal Mycodo install that there is a dependency that seemed to be required in the driver.:
(‘pip-pypi’, ‘smbus2’, ‘smbus2==0.4.1’)

See this document near the end:

None of the registers should return a value like that according to the User Manual, UM2039.

Thank you for your quick response. I will check what is wrong with my connection. Will update the outcome.

Regards

Since I have posted this problem my sensor is working without any error. :rofl: :rofl: