Open Serrallonga25 opened 1 month ago
@Serrallonga25 Not sure why you would see a change because the update I made does not change units and I still have correct number on my sensor in mm. Note: units of distance sensor are mm. Can you share your esphome yaml and any sensor setup changes in ha - then I might be able to suggest something
Maybe the sensor is broken?
I use it in a diesel tank to measure the liters I have left
#https://github.com/mrtoy-me/esphome-my-components/tree/main/components/vl53l1x
external_components:
#- source: components
source:
type: git
url: https://github.com/mrtoy-me/esphome-my-components
ref: main
components: [vl53l1x]
#example configure I2C
i2c:
- id: bus_a
sda: GPIO14
scl: GPIO15
scan: true
#I commented on this part after the update
#vl53l1x:
# distance_mode: long
# update_interval: 10s
sensor:
- platform: vl53l1x
i2c_id: bus_a
distance_mode: long
update_interval: 10s
distance:
name: "VL53L1X Time Of Flight Distance Sensor"
id: caldera_mag_nivell_m_optic
entity_category: 'diagnostic'
#Add filter to convert to mm after update
filters:
- lambda: |-
ESP_LOGE("VL53L1X Time Of Flight Distance Sensor", "%f", x);
return x * 10;
range_status:
name: Range Status
entity_category: 'diagnostic'
[12:39:19][I][i2c.arduino:096]: Results from i2c bus scan:
[12:39:19][I][i2c.arduino:102]: Found i2c device at address 0x29
[12:39:19][C][gpio.output:010]: GPIO Binary Output:
[12:39:19][C][gpio.output:011]: Pin: GPIO4
[12:39:20][C][light:103]: Light 'Llum Camara Magatzem'
[12:39:20][C][wifi_info:014]: WifiInfo Mac Address 'Nivell Gasoil Mac Wifi Address'
[12:39:20][C][vl53l1x.sensor:333]: VL53L1X:
[12:39:20][D][vl53l1x.sensor:374]: Setup successful - all versions
[12:39:20][I][vl53l1x.sensor:378]: Found sensor: VL53L1X
[12:39:20][C][vl53l1x.sensor:392]: Distance Mode: LONG
[12:39:20][D][vl53l1x.sensor:395]: Timing Budget: 500ms
[12:39:20][D][vl53l1x.sensor:396]: Intermediate Period: 500ms
[12:39:20][C][vl53l1x.sensor:398]: Address: 0x29
[12:39:20][C][vl53l1x.sensor:399]: Update Interval: 10.0s
[12:39:20][C][vl53l1x.sensor:402]: Distance Sensor: 'VL53L1X Time Of Flight Distance Sensor'
[12:39:20][C][vl53l1x.sensor:402]: Device Class: 'distance'
[12:39:20][C][vl53l1x.sensor:402]: State Class: 'measurement'
[12:39:20][C][vl53l1x.sensor:402]: Unit of Measurement: 'mm'
[12:39:20][C][vl53l1x.sensor:402]: Accuracy Decimals: 0
[12:39:20][C][vl53l1x.sensor:405]: Range Status Sensor: 'Range Status'
[12:39:20][C][vl53l1x.sensor:405]: State Class: 'measurement'
[12:39:20][C][vl53l1x.sensor:405]: Unit of Measurement: ''
[12:39:20][C][vl53l1x.sensor:405]: Accuracy Decimals: 0
[12:39:26][E][VL53L1X Time Of Flight Distance Sensor:180]: 97.000000
[12:39:26][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 970.00000 mm with 0 decimals of accuracy
If it measures correctly for you, the sensor may be failing, as I have noticed that it gets stuck after a while and says it has failed.
But it seems strange to me that it truncates a digit in the result.
few questions So what is the correct distance in mm
What is purpose of filters:
So sensor is giving 97mm and you are multiplying by 10 to make it 970mm, so I am guessing you were expecting 970mm is that right. I check the sensor by aiming it at a flat surface at a few different distances.
Is your range stays always 0 if not that is a problem with the conditions the sensor is measuring in
I am interested that it get stuck and fails - can you give me any logs of a fail. There a quite a few error msg depending on cause of fail
Also are you using IDF or arduino and what esp are you using
I have downloaded the old version from 2 months ago and I also get the truncated result but it gives me a different value
[12:55:01][C][i2c.arduino:071]: I2C Bus:
[12:55:01][C][i2c.arduino:072]: SDA Pin: GPIO14
[12:55:01][C][i2c.arduino:073]: SCL Pin: GPIO15
[12:55:01][C][i2c.arduino:074]: Frequency: 50000 Hz
[12:55:01][C][i2c.arduino:086]: Recovery: bus successfully recovered
[12:55:01][I][i2c.arduino:096]: Results from i2c bus scan:
[12:55:01][I][i2c.arduino:102]: Found i2c device at address 0x29
[12:55:01][C][gpio.output:010]: GPIO Binary Output:
[12:55:01][C][gpio.output:011]: Pin: GPIO4
[12:55:01][C][light:103]: Light 'Llum Camara Magatzem'
[12:55:02][C][wifi_info:014]: WifiInfo Mac Address 'Nivell Gasoil Mac Wifi Address'
[12:55:02][C][vl53l1x.sensor:338]: VL53L1X:
[12:55:02][D][vl53l1x.sensor:354]: Setup successful
[12:55:02][I][vl53l1x.sensor:358]: Found sensor: VL53L1X
[12:55:02][C][vl53l1x.sensor:372]: Distance Mode: LONG
[12:55:02][D][vl53l1x.sensor:375]: Timing Budget: 500ms
[12:55:02][D][vl53l1x.sensor:376]: Intermediate Period: 500ms
[12:55:02][C][vl53l1x.sensor:377]: Address: 0x29
[12:55:02][C][vl53l1x.sensor:378]: Update Interval: 10.0s
[12:55:02][C][vl53l1x.sensor:379]: Distance Sensor: 'VL53L1X Time Of Flight Distance Sensor'
[12:55:02][C][vl53l1x.sensor:379]: Device Class: 'distance'
[12:55:02][C][vl53l1x.sensor:379]: State Class: 'measurement'
[12:55:02][C][vl53l1x.sensor:379]: Unit of Measurement: 'mm'
[12:55:02][C][vl53l1x.sensor:379]: Accuracy Decimals: 0
[12:55:02][C][vl53l1x.sensor:380]: Range Status Sensor: 'Range Status'
[12:55:02][C][vl53l1x.sensor:380]: State Class: 'measurement'
[12:55:02][C][vl53l1x.sensor:380]: Unit of Measurement: ''
[12:55:02][C][vl53l1x.sensor:380]: Accuracy Decimals: 0
[12:55:03][E][VL53L1X Time Of Flight Distance Sensor:180]: 80.000000
[12:55:03][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 800.00000 mm with 0 decimals of accuracy
IDF o Arduino Are you referring to the platform configuration?
esphome: name: $hostname platform: ESP32 board: esp32dev
Framework type - but by logs it is arduino.
The difference between 97 and 80 with old code is not the code, it is accuracy of sensor, so that's ok. So your sensor is reading 79mm (or 80mm)
The correct measurement is 780mm, not 78mm
[14:15:59][I][i2c.arduino:096]: Results from i2c bus scan:
[14:15:59][I][i2c.arduino:102]: Found i2c device at address 0x29
[14:15:59][C][gpio.output:010]: GPIO Binary Output:
[14:15:59][C][gpio.output:011]: Pin: GPIO4
[14:15:59][C][light:103]: Light 'Llum Camara Magatzem'
[14:15:59][C][wifi_info:014]: WifiInfo Mac Address 'Nivell Gasoil Mac Wifi Address'
[14:15:59][C][vl53l1x.sensor:333]: VL53L1X:
[14:15:59][E][vl53l1x.sensor:343]: Data ready communication error
[14:15:59][E][component:082]: Component vl53l1x.sensor is marked FAILED
[14:06:37][W][component:237]: Component vl53l1x.sensor took a long time for an operation (54 ms).
[14:06:37][W][component:238]: Components should block for at most 30 ms.
[14:07:22][W][vl53l1x.sensor:487]: Error reading Interrupt Polarity
[14:07:22][W][component:157]: Component vl53l1x.sensor set Warning flag: unspecified
[14:07:22][E][component:119]: Component vl53l1x.sensor was marked as failed.
[14:07:22][E][component:164]: Component vl53l1x.sensor set Error flag: unspecified
I don't know what happened, but in some update eshome broke or maybe the sensor broke.
I'll try another board that I have to see if it's the esp32cam that has always been a bit of a fool.
Now it measures correctly
I think I wasted your time, sorry, all I did was clean the sensor casing.
But since it coincided with the update, I got confused
[14:24:53][I][i2c.arduino:096]: Results from i2c bus scan:
[14:24:53][I][i2c.arduino:102]: Found i2c device at address 0x29
[14:24:53][C][gpio.output:010]: GPIO Binary Output:
[14:24:53][C][gpio.output:011]: Pin: GPIO4
[14:24:53][C][light:103]: Light 'Llum Camara Magatzem'
[14:24:53][C][wifi_info:014]: WifiInfo Mac Address 'Nivell Gasoil Mac Wifi Address'
[14:24:53][C][vl53l1x.sensor:333]: VL53L1X:
[14:24:53][D][vl53l1x.sensor:374]: Setup successful - all versions
[14:24:53][I][vl53l1x.sensor:378]: Found sensor: VL53L1X
[14:24:53][C][vl53l1x.sensor:392]: Distance Mode: LONG
[14:24:53][D][vl53l1x.sensor:395]: Timing Budget: 500ms
[14:24:53][D][vl53l1x.sensor:396]: Intermediate Period: 500ms
[14:24:53][C][vl53l1x.sensor:398]: Address: 0x29
[14:24:53][C][vl53l1x.sensor:399]: Update Interval: 60.0s
[14:24:53][C][vl53l1x.sensor:402]: Distance Sensor: 'VL53L1X Time Of Flight Distance Sensor'
[14:24:53][C][vl53l1x.sensor:402]: Device Class: 'distance'
[14:24:53][C][vl53l1x.sensor:402]: State Class: 'measurement'
[14:24:53][C][vl53l1x.sensor:402]: Unit of Measurement: 'mm'
[14:24:53][C][vl53l1x.sensor:402]: Accuracy Decimals: 0
[14:24:53][C][vl53l1x.sensor:405]: Range Status Sensor: 'Range Status'
[14:24:53][C][vl53l1x.sensor:405]: State Class: 'measurement'
[14:24:53][C][vl53l1x.sensor:405]: Unit of Measurement: ''
[14:24:53][C][vl53l1x.sensor:405]: Accuracy Decimals: 0
[14:25:35][E][VL53L1X Time Of Flight Distance Sensor:180]: 781.000000
[14:25:35][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 7810.00000 mm with 0 decimals of accuracy
Output without filter:
[14:30:48][E][VL53L1X Time Of Flight Distance Sensor:180]: 776.000000
[14:30:48][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 776.00000 mm with 0 decimals of accuracy
Let's see if the blocks disappear too. Thanks and sorry again
Good morning, now it takes the correct measurement but it continues to block
[00:38:55][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 763.00000 mm with 0 decimals of accuracy
[00:38:55][D][sensor:094]: 'Range Status': Sending state 0.00000 with 0 decimals of accuracy
[00:39:55][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 769.00000 mm with 0 decimals of accuracy
[00:39:55][D][sensor:094]: 'Range Status': Sending state 0.00000 with 0 decimals of accuracy
[00:40:37][W][vl53l1x.sensor:495]: Error reading Data Ready
[00:40:37][W][component:157]: Component vl53l1x.sensor set Warning flag: unspecified
[00:40:37][E][component:119]: Component vl53l1x.sensor was marked as failed.
[00:40:37][E][component:164]: Component vl53l1x.sensor set Error flag: unspecified
The issue seems to be that there is an error reading a register ( for data ready) which creates a warning but then the it fails. You were getting a similar issue before you cleaned the sensor. I have not seem that issue on my sensor, let me have a look at the code and see if I can make a change that might help not cause the sensor to fail. The blocking issue is not really an issue, but a symptom of reads or writes taking longer than they should. Busy tonight but I will get back to you in the next day or so and let you know what I have changed. Thanks for all the info on how your sensor is performing with my component
@Serrallonga25 I have made a new branch in VL54L1X called "allow-some-fails-warnings" - I have given it a quick try and it seems to be working for me with no warnings or errors. If you want to try this version, I have stopped it failing immediately there is a data ready error or any warnings - you will see the error or warning message but it will not fail immediately. If the errors or warnings persistent for a few iterations without a valid reading then it will fail. Also if there is an update and there is not a new value from the sensor then you get NaN (not a number). Look forward to your feedback.
Thanks @mrtoy-me , I'll try it and let you know.
Hi @mrtoy-me , I've had it working without any problems for 3 days now, it seems to be resolved.
I only get the following warning from time to time (but it happens to me on other sensors)
[14:42:44][W][component:237]: Component vl53l1x.sensor took a long time for an operation (52 ms).
[14:42:44][W][component:238]: Components should block for at most 30 ms.
Thanks
It seems like he was waiting for me to say there was no problem.
[15:42:44][W][component:237]: Component vl53l1x.sensor took a long time for an operation (51 ms).
[15:42:44][W][component:238]: Components should block for at most 30 ms.
[15:43:44][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 726.00000 mm with 0 decimals of accuracy
[15:43:44][D][sensor:094]: 'VL53L1X kalman': Sending state 721.21735 mm with 0 decimals of accuracy
[15:43:44][D][sensor:094]: 'Diposit 1000L': Sending state 259.97620 L with 0 decimals of accuracy
[15:43:44][D][sensor:094]: 'Range Status': Sending state 0.00000 with 0 decimals of accuracy
[15:44:20][W][vl53l1x.sensor:524]: Error reading Data Ready
[15:44:20][W][component:157]: Component vl53l1x.sensor set Warning flag: unspecified
[15:44:21][E][vl53l1x.sensor:418]: Multiple consecutive attempts to read sensor without clearing warning
[15:44:21][E][component:119]: Component vl53l1x.sensor was marked as failed.
[15:44:21][E][component:164]: Component vl53l1x.sensor set Error flag: unspecified
Thanks so much for doing the testing and providing the error codes. Was the component failing after a day or two prior to the recent update removing the vl53l0x hub setup ?
Maybe it had failed before but I hadn't detected it or because I wasn't looking at it so closely I hadn't noticed.
But what surprises me is that you tell me that it doesn't fail for you.
It could be the fault of my sensor from AliExpress and it doesn't have enough quality.
At the moment it is working again after restarting.
Thanks
I have got it to fail not sure if it is same cause as you yet - so I am doing more testing and will make some changes when finished - will let you know
Thanks
Today I found the error again and had to restart.
[01:53:14][D][sensor:094]: 'VL53L1X Time Of Flight Distance Sensor': Sending state 725.00000 mm with 0 decimals of accuracy
[01:53:14][D][sensor:094]: 'Diposit 1000L Quantile': Sending state 257.53421 L with 0 decimals of accuracy
[01:53:14][D][sensor:094]: 'VL53L1X kalman': Sending state 725.88647 mm with 0 decimals of accuracy
[01:53:14][D][sensor:094]: 'Diposit 1000L': Sending state 253.58014 L with 0 decimals of accuracy
[01:53:14][D][sensor:094]: 'Range Status': Sending state 0.00000 with 0 decimals of accuracy
[01:53:14][W][component:237]: Component vl53l1x.sensor took a long time for an operation (56 ms).
[01:53:14][W][component:238]: Components should block for at most 30 ms.
[01:54:09][W][vl53l1x.sensor:515]: Error reading Interrupt Polarity
[01:54:09][W][component:157]: Component vl53l1x.sensor set Warning flag: unspecified
[01:54:10][E][vl53l1x.sensor:418]: Multiple consecutive attempts to read sensor without clearing warning
[01:54:10][E][component:119]: Component vl53l1x.sensor was marked as failed.
[01:54:10][E][component:164]: Component vl53l1x.sensor set Error flag: unspecified
Have not forgotten - I have been making incremental changes and testing along the way but it takes a few days to test each time to see if it fails - I am not on my usual test system and I am getting some fails after a while so still working on it. Will let you know when I have something.
Thank you for your effort
@Serrallonga25 OK so I have changed quite a few things internally but what seems to have fixed the issue with the sensor stopping after a few days is running at a higher i2c frequency (default arduino is 50khz) - I have had a sensor running for nearly 5 days now at i2c frequency: 200khz also I have set timeout: 1ms which removes the component taking too long warnings.
i2c:
- id: bus_a
sda: xx
scl: yy
frequency: 200kHz
scan: true
timeout: 1ms
So try above with the updated component and let me know how it goes. I will keep testing and cleanup the code when I am have done some more testing.
Hi @mrtoy-me,
But after the update vl53l1x I get an incorrect result.
It gives me 67,000mm instead of 670mm
Could it be my fault or some bad configuration?
Thanks for your work.