Esphome VL53l1X issue ('TwoWire' has not been declared)

Hi All !
I’m trying to make this work using this github repo and I’m getting this error. I’m new to HA and esphome. I have a

I have this in the yaml file:

platform: ESP32
  board: esp32dev    
  includes:
    - VL53/
  libraries:
    - "VL53L1x"
    - "Wire"

i also created a folder ‘VL53’ at the config level where I have the tof_vl53l1x.h and the Wire.h files. adding Wire library does not fix it either. Any hints as to why this behaving like this would be great. thanks.

INFO Reading configuration /config/esphome/tt.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing tt (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 5.2.0)

Library Manager: Installing esphome/AsyncTCP-esphome @ 1.2.2
INFO Installing esphome/AsyncTCP-esphome @ 1.2.2
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 2.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 2.1.0
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies…
INFO Resolving dependencies…
Library Manager: Installing esphome/noise-c @ 0.1.4
INFO Installing esphome/noise-c @ 0.1.4
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies…
INFO Resolving dependencies…
Library Manager: Installing esphome/libsodium @ 1.10018.1
INFO Installing esphome/libsodium @ 1.10018.1
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

Unpacking [------------------------------------] 0%
Unpacking [##----------------------------------] 7%
Unpacking [#####-------------------------------] 14%
Unpacking [#######-----------------------------] 21%
Unpacking [##########--------------------------] 28%
Unpacking [############------------------------] 35%
Unpacking [###############---------------------] 42%
Unpacking [##################------------------] 50%
Unpacking [####################----------------] 57%
Unpacking [#######################-------------] 64%
Unpacking [#########################-----------] 71%
Unpacking [############################--------] 78%
Unpacking [##############################------] 85%
Unpacking [#################################—] 92%
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Dependency Graph
|-- AsyncTCP-esphome @ 1.2.2
|-- VL53L1X @ 1.3.1
|-- Wire @ 2.0.0
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 2.1.0
| |-- AsyncTCP-esphome @ 1.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
| |-- libsodium @ 1.10018.1
Compiling /data/tt/.pioenvs/tt/src/VL53L1X.cpp.o
Compiling /data/tt/.pioenvs/tt/src/esphome/components/api/api_connection.cpp.o
In file included from src/VL53L1X.cpp:6:
src/VL53L1X.h:1275:17: error: ‘TwoWire’ has not been declared
void setBus(TwoWire * bus) { this->bus = bus; }
^~~~~~~
src/VL53L1X.h:1276:5: error: ‘TwoWire’ does not name a type; did you mean ‘TwoWire_h’?
TwoWire * getBus() { return bus; }
^~~~~~~
TwoWire_h
src/VL53L1X.h:1361:5: error: ‘TwoWire’ does not name a type; did you mean ‘TwoWire_h’?
TwoWire * bus;
^~~~~~~
TwoWire_h
src/VL53L1X.h: In member function ‘void VL53L1X::setBus(int*)’:
src/VL53L1X.h:1275:40: error: ‘class VL53L1X’ has no member named ‘bus’
void setBus(TwoWire * bus) { this->bus = bus; }
^~~
src/VL53L1X.cpp: In constructor ‘VL53L1X::VL53L1X()’:
src/VL53L1X.cpp:12:5: error: class ‘VL53L1X’ does not have any field named ‘bus’
: bus(&Wire)
^~~
src/VL53L1X.cpp:12:10: error: ‘Wire’ was not declared in this scope
: bus(&Wire)
^~~~
src/VL53L1X.cpp:12:10: note: suggested alternative: ‘pipe’
: bus(&Wire)
^~~~
pipe
src/VL53L1X.cpp: In member function ‘void VL53L1X::writeReg(uint16_t, uint8_t)’:
src/VL53L1X.cpp:164:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘void VL53L1X::writeReg16Bit(uint16_t, uint16_t)’:
src/VL53L1X.cpp:174:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘void VL53L1X::writeReg32Bit(uint16_t, uint32_t)’:
src/VL53L1X.cpp:185:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘uint8_t VL53L1X::readReg(VL53L1X::regAddr)’:
src/VL53L1X.cpp:200:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘uint16_t VL53L1X::readReg16Bit(uint16_t)’:
src/VL53L1X.cpp:216:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘uint32_t VL53L1X::readReg32Bit(uint16_t)’:
src/VL53L1X.cpp:233:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
src/VL53L1X.cpp: In member function ‘void VL53L1X::readResults()’:
src/VL53L1X.cpp:669:3: error: ‘bus’ was not declared in this scope
bus->beginTransmission(address);
^~~
*** [/data/tt/.pioenvs/tt/src/VL53L1X.cpp.o] Error 1
========================== [FAILED] Took 6.59 seconds ==========================

The example YAML file from that repo doesn’t have Wire in it. Since you didn’t include the full YAML file, it’s hard to say if that’s required for some other reason. The first thing I’d try is removing Wire.

That repo hasn’t been updated in some time, so it’s also possible the drive for that sensor has an issue. You might try this repo, which is being maintained:

Lastly, please format your YAML and log stuff by using ``` in the line before and after the YAML and log stuff. This tells the forum to format it as code and makes it more readable. Without it thing are very hard to read, and most folks won’t help if they have to try and read unformatted YAML or logs.

Thanks for the quick answer.
I did add the wire.h to the yaml but no luck. And yes that’s a 4 years old project with no updates and no issue tracking.
I will try the other repo.
I will also make sure to format the code in the future.
Cheers !

Have a look here - maybe it will help you.

Why not try the sample yaml as written.

Hello, @Domoticus …pls, have you been successfull with your thoughts? Did you create any usefull yaml for VL53L1X? I am struggling with it just now… thank you for any reply…