Is there any way to use a time of flight sensor like the VL53L1X via an ESPHome-flashed NodeMCU? I know HA now has native support for this sensor, but that requires a physical connection between the sensor and the HA server. I have an application where this type of sensor would be great, but it’s remote from the server (plus my server isn’t an RPi anyway, so no easy way to connect i2c) so I need to be able to send the data over wifi in some way.
Could the generic i2c sensor platform be used in ESPHome and then the the data be parsed at the HA end? Or would a custom platform have to be written?
From what I can see any howto on this chipset uses an arduino library from the likes of polulu or sparkfun. I would think that you would need to include that library ie as a custom component.
So the D1 Mini with ESPHome does have i2c support. You specify the pins in the YAML. Unfortunately, I can’t get the D1 Mini to flash once I set up the YAMl.
During flashing this is all I get:
Documents on i2c for ESPHome:
Time of flight sensor:
The spec sheet on the TOF sensor shows that the address is: 0x52 so I have that set in my ESPHome YAML.
There is someone that posted they got it working with their own code on the first issue so I may give that a shot. Unfortunately I am very new to all the DIY items and this is only my second Arduino project so I very well could be doing something wrong.
Thanks for the response! I thought I was sure, as the D1 Mini never would connect to wifi, but after trying the code that was posted in the feature request GITHub, I believe your right. His code has a message that clearly shows “Failed to boot VL53L0X”
I also forgot to mention that I went to the dev branch of ESPHome as it looks like that is where the changes were put in place (If I am reading the GITHub info correctly)
And confirmation that you are right, flashing seems to have went without an issue, boot appears to be the issue:
Using ‘COM4’ as serial port.
Connecting…
Detecting chip type… ESP826 %)Writing at 0x00044000… (100 %)Wrote 414992 bytes (284231 compressed) at 0x00000000 in 6.3 seconds (effective 523.0 kbit/s)…
Hash of data verified.
Leaving…
Hard Resetting…
Done! Flashing is complete!
Showing logs:
[18:53:58][I][logger:156]: Log initialized
[18:53:58][C][ota:364]: There have been 8 suspected unsuccessful boot attempts.
[18:53:58][I][app:028]: Running through setup()…
[18:53:58][W][i2c:070]: Received NACK on transmit of address 0x29
[18:53:58][W][i2c:070]: Received NACK on transmit of address 0x29
… forever and forever
Ultimately I want to replace my very flaky ultrasonic sensor in my water softener tank with this. Its right next to my washer and dryer and when in use, readings go all over.
By the way once you get i2c working the scan should show up something like this, which tells you what addresses it finds other i2c devices on. This is on an esp32, but I imagine it shows scan results on esp8266 as well
[02:18:00][C][i2c:028]: I2C Bus:
[02:18:00][C][i2c:029]: SDA Pin: GPIO5
[02:18:00][C][i2c:030]: SCL Pin: GPIO4
[02:18:00][C][i2c:031]: Frequency: 50000 Hz
[02:18:00][I][i2c:033]: Scanning i2c bus for active devices...
[02:18:00][I][i2c:040]: Found i2c device at address 0x3C
You are 100% correct. That was the issue. All is working, thank you very much for the assistance!
[21:21:15][I][i2c:033]: Scanning i2c bus for active devices…
[21:21:15][I][i2c:040]: Found i2c device at address 0x29
[21:22:25][D][sensor:092]: ‘VL53L0x Distance’: Sending state 0.24100 m with 2 decimals of accuracy
[21:22:35][D][vl53l0x:242]: ‘VL53L0x Distance’ - Got distance 0.231 m
[21:22:35][D][sensor:092]: ‘VL53L0x Distance’: Sending state 0.23100 m with 2 decimals of accuracy
[21:22:45][D][vl53l0x:242]: ‘VL53L0x Distance’ - Got distance 0.306 m
[21:22:45][D][sensor:092]: ‘VL53L0x Distance’: Sending state 0.30600 m with 2 decimals of accuracy
[21:22:55][D][vl53l0x:242]: ‘VL53L0x Distance’ - Got distance 0.220 m
[21:22:55][D][sensor:092]: ‘VL53L0x Distance’: Sending state 0.22000 m with 2 decimals of accuracy
Now to see if I can document this better somewhere to assist others! Again, very much appreciated!
Yes, very much agreed! Its the only reason I had decided to give these DIY sensors a shot. ESPHome has and will make so many things much easier to integrate into HA.
Did not even know esphome-configs.io existed. Will definitely look into adding this info there. Thanks again for the help. I have seen you around, and I am sure your previous posts have definitely help me out as well!
as nickrout pointed out, you must use D1 and D2 as those are the SCL and SDA pins (GPIO5 and GPIO4) on the D1 Mini. I did confirm that this works on the production ESPHome and no need to be using the dev version.
At this moment with current code, no. It’s just possibility which must be programmed “from scratch”(means it’s not just about “movement_direction: enable” option in ESPhome config file).
If the movement direction works though I think we could use the counter component …
This should get us to the next step and a couple automations later we could be there unless I’m misunderstanding something. (Quite possible)
Displaying the info in lovelace may take some more work… haven’t thought about that yet.
Hi.
I use a nodemcu & Arduino IDE to get values from 2 differents VL53L0X sensors with only one I²C Bus (using the Xshut pin and the “vl53l0x_dual” script example by Adafruit). It works great.
I tried to use ESPHome & its awesome integration in hassio to get those 2 sensors values, but was able to get only one value (sensor1), using this code :