VL53L1X time of flight sensor - works in Arduino but not esphome?

Hi all, am trying to make a level sensor for an oil tank using an ESP-07 (ESP-8266 based) and a VL53L1X time of flight ranging module. This is the sensor:

419vXaiCe-L.AC

I have managed to get the sensor working using Arduino IDE, but I want to get it working with ESPhome, so I can use it with Home Assistant.

substitutions:
   devicename: oil-tank-sensor
   friendly_devicename: oil-tank

esphome:
  name: $devicename
  platform: esp8266
  board: esp07

wifi:
  ssid: "SSID"
  password: "WifiPASSWORD"

captive_portal:

mqtt:
  broker: 192.168.1.163
  username: XXXX
  password: XXXX!
  discovery: true
  discovery_retain: true

# Enable logging
logger:
  level: DEBUG
  #level: INFO


i2c:
  sda: 04
  scl: 05
  scan: true
  id: bus_a
  
binary_sensor:
  - platform: status
    name: $friendly_devicename Status

sensor:
  - platform: vl53l1x
    name: "Oil Distance"
    timing_budget: 50ms
    update_interval: 0.1s
    distance_mode: long
    address: 0x29

  - platform: wifi_signal
    name: $friendly_devicename signal strength

switch:
  - platform: restart
    name: "Oil Sensor Restart"

When I validate, I get the following:

1

Am i right in thinking the VL53L1X is supported?

Any advice appreciated. Thanks,
G

I think it requires a custom component: GitHub - jardous/tof_vl53l1x: ESPHome custom sensor utilizing the VL53L1X Time of Flight distance module

1 Like

Thanks Hellis81, after some tinkering and setting up the custom component and custom sensor etc, it is working now. Thanks so much. :slightly_smiling_face:

One other thing I would like to do - as the chip and sensor will be powered from a 3.6v lithium battery, I am using the deep sleep function so that it is only powered up for 20sec every hour. To avoid having to power the sensor continually, I am using a 2N222 transistor as a switch to power on the sensor. To do this, I need to set pin GPIO15 high when it wakes from deep sleep.

In Arduino, I used this successfully:

pinMode(15,OUTPUT);
digitalWrite(15,HIGH); 

But what is the simplest way to do this in ESPhome?

Thanks,
Gareth

A switch, with ALWAYS_ON.
GPIO Switch — ESPHome

I think

Hi, thanks to Hellis81, this has been working great over the past 5 months. I had to use the custom component at GitHub - jardous/tof_vl53l1x: ESPHome custom sensor utilizing the VL53L1X Time of Flight distance module

However, something has happened recently (not sure if it was an update to HA, ESPHome or something else, but now the code won’t compile and install.

Here is my code:

substitutions:
   devicename: oiltank-sensor
   friendly_devicename: oiltank

esphome:
  name: $devicename
  platform: esp8266
  board: esp07
  includes: 
    - tof_vl53l1x.h
  libraries:
    - "VL53L1x"
    
switch:
  - platform: gpio
    pin: 15
    name: $friendly_devicename Sensor On
    restore_mode: always_on
    
  - platform: restart
    name: $friendly_devicename Restart
    
wifi:
  fast_connect: true
  ssid: "XXXX"
  password: "XXXXXX"
  
# No API when using battery
# api:

#captive_portal:

mqtt:
  broker: 192.168.1.163
  username: XXXX
  password: XXXXX
  discovery: true
  discovery_retain: true
        
# Enable logging
logger:
  level: DEBUG


i2c:
  sda: 04
  scl: 05
  scan: true
  id: bus_a
  
binary_sensor:
  - platform: status
    name: $friendly_devicename Status
    id: oiltank_Status

sensor:
  - platform: custom
    lambda: |-
      auto my_sensor = new MyCustomSensor();
      App.register_component(my_sensor);
      return {my_sensor};
    sensors:
      - name: $friendly_devicename Distance
        id: oiltank_distance
        accuracy_decimals: 0
        unit_of_measurement: "mm"

  - platform: wifi_signal
    name: $friendly_devicename signal strength

However, here is the log when I try to build:

Processing oiltank-sensor (board: esp07; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <VL53L1X> 1.3.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|-- <AsyncMqttClient-esphome> 0.8.6
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|-- <Wire> 1.0
|-- <ArduinoJson> 6.18.5
Compiling /data/oiltank-sensor/.pioenvs/oiltank-sensor/src/main.cpp.o
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:496:10: warning: missing terminating ' character
  496 |     <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="193980322" data-scoped-search-url="/jardous/tof_vl53l1x/search" data-owner-scoped-search-url="/users/jardous/search" data-unscoped-search-url="/search" action="/jardous/tof_vl53l1x/search" accept-charset="UTF-8" method="get">
      |          ^
src/tof_vl53l1x.h:496:10: error: missing terminating ' character
  496 |     <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="193980322" data-scoped-search-url="/jardous/tof_vl53l1x/search" data-owner-scoped-search-url="/users/jardous/search" data-unscoped-search-url="/search" action="/jardous/tof_vl53l1x/search" accept-charset="UTF-8" method="get">
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:553:75: error: extended character ↵ is not valid in an identifier
  553 |       <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                                           ^
src/tof_vl53l1x.h:558:56: error: extended character ↵ is not valid in an identifier
  558 |       <span class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                        ^
src/tof_vl53l1x.h:600:75: error: extended character ↵ is not valid in an identifier
  600 |       <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                                           ^
src/tof_vl53l1x.h:605:56: error: extended character ↵ is not valid in an identifier
  605 |       <span class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                        ^
src/tof_vl53l1x.h:638:75: error: extended character ↵ is not valid in an identifier
  638 |       <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                                           ^
src/tof_vl53l1x.h:643:56: error: extended character ↵ is not valid in an identifier
  643 |       <span class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                        ^
src/tof_vl53l1x.h:676:75: error: extended character ↵ is not valid in an identifier
  676 |       <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                                           ^
src/tof_vl53l1x.h:681:56: error: extended character ↵ is not valid in an identifier
  681 |       <span class="d-inline-block ml-1 v-align-middle">↵</span>
      |                                                        ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1056:25: warning: missing terminating " character
 1056 |             data-action="
      |                         ^
src/tof_vl53l1x.h:1056:25: error: missing terminating " character
src/tof_vl53l1x.h:1057:41: error: stray '#' in program
 1057 |               input-entered:ref-selector#inputEntered
      |                                         ^
src/tof_vl53l1x.h:1058:40: error: stray '#' in program
 1058 |               tab-selected:ref-selector#tabSelected
      |                                        ^
src/tof_vl53l1x.h:1059:38: error: stray '#' in program
 1059 |               focus-list:ref-selector#focusFirstListMember
      |                                      ^
src/tof_vl53l1x.h:1060:13: warning: missing terminating " character
 1060 |             "
      |             ^
src/tof_vl53l1x.h:1060:13: error: missing terminating " character
src/tof_vl53l1x.h:1079:80: warning: missing terminating ' character
 1079 |             <!-- TODO: this max-height is necessary or else the branch list won't scroll.  why? -->
      |                                                                                ^
src/tof_vl53l1x.h:1079:80: error: missing terminating ' character
 1079 |             <!-- TODO: this max-height is necessary or else the branch list won't scroll.  why? -->
      |                                                                                ^~~~~~~~~~~~~~~~~~~~
src/tof_vl53l1x.h:1108:25: warning: missing terminating " character
 1108 |             data-action="
      |                         ^
src/tof_vl53l1x.h:1108:25: error: missing terminating " character
src/tof_vl53l1x.h:1109:41: error: stray '#' in program
 1109 |               input-entered:ref-selector#inputEntered
      |                                         ^
src/tof_vl53l1x.h:1110:40: error: stray '#' in program
 1110 |               tab-selected:ref-selector#tabSelected
      |                                        ^
src/tof_vl53l1x.h:1111:38: error: stray '#' in program
 1111 |               focus-list:ref-selector#focusFirstListMember
      |                                      ^
src/tof_vl53l1x.h:1112:13: warning: missing terminating " character
 1112 |             "
      |             ^
src/tof_vl53l1x.h:1112:13: error: missing terminating " character
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1409:71: error: stray '#' in program
 1409 |           <td id="LC1" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&quot;</span>esphome.h<span class="pl-pds">&quot;</span></span></td>
      |                                                                       ^
src/tof_vl53l1x.h:1418:71: error: stray '#' in program
 1418 |           <td id="LC3" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>Wire.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                       ^
src/tof_vl53l1x.h:1422:71: error: stray '#' in program
 1422 |           <td id="LC4" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>VL53L1X.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                       ^
src/tof_vl53l1x.h:1615:12: warning: missing terminating ' character
 1615 |       <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get">
      |            ^
src/tof_vl53l1x.h:1615:12: error: missing terminating ' character
 1615 |       <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get">
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1681:9: error: extended character ’ is not valid in an identifier
 1681 |     You can’t perform that action at this time.
      |         ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:7:1: error: expected unqualified-id before '<' token
    7 | <!DOCTYPE html>
      | ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:277:25: error: 'up' does not name a type; did you mean 'u8'?
  277 |               Sign&nbsp;up
      |                         ^~
      |                         u8
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:739:25: error: expected unqualified-id before '<' token
  739 |       <div>{{ message }}</div>
      |                         ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1094:97: error: expected unqualified-id before '<' token
 1094 |     <span class="flex-1 css-truncate css-truncate-overflow {{ isFilteringClass }}">{{ refName }}</span>
      |                                                                                                 ^
src/tof_vl53l1x.h:1134:97: error: expected unqualified-id before '<' token
 1134 |     <span class="flex-1 css-truncate css-truncate-overflow {{ isFilteringClass }}">{{ refName }}</span>
      |                                                                                                 ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1225:61: error: expected unqualified-id before '<' token
 1225 |       <div class="Skeleton Skeleton--text col-5 ml-2">&nbsp;</div>
      |                                                             ^
src/tof_vl53l1x.h:1229:56: error: expected unqualified-id before '<' token
 1229 |       <div class="Skeleton Skeleton--text col-1">&nbsp;</div>
      |                                                        ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1409:152: error: expected unqualified-id before '<' token
 1409 |           <td id="LC1" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&quot;</span>esphome.h<span class="pl-pds">&quot;</span></span></td>
      |                                                                                                                                                        ^
src/tof_vl53l1x.h:1409:195: error: expected unqualified-id before '<' token
 1409 |           <td id="LC1" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&quot;</span>esphome.h<span class="pl-pds">&quot;</span></span></td>
      |                                                                                                                                                                                                   ^
src/tof_vl53l1x.h:1418:150: error: expected unqualified-id before '<' token
 1418 |           <td id="LC3" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>Wire.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                                                                                                      ^
src/tof_vl53l1x.h:1418:188: error: expected unqualified-id before '<' token
 1418 |           <td id="LC3" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>Wire.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                                                                                                                                            ^
src/tof_vl53l1x.h:1422:150: error: expected unqualified-id before '<' token
 1422 |           <td id="LC4" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>VL53L1X.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                                                                                                      ^
src/tof_vl53l1x.h:1422:191: error: expected unqualified-id before '<' token
 1422 |           <td id="LC4" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>VL53L1X.h<span class="pl-pds">&gt;</span></span></td>
      |                                                                                                                                                                                               ^
src/tof_vl53l1x.h:1431:90: error: expected unqualified-id before '<' token
 1431 |           <td id="LC6" class="blob-code blob-code-inner js-file-line">VL53L1X tof_sensor;</td>
      |                                                                                          ^
src/tof_vl53l1x.h:1573:74: error: expected unqualified-id before '<' token
 1573 |           <td id="LC40" class="blob-code blob-code-inner js-file-line">};</td>
      |                                                                          ^
In file included from src/main.cpp:49:
src/tof_vl53l1x.h:1646:16: error: expected unqualified-id before numeric constant
 1646 |         &copy; 2022 GitHub, Inc.
      |                ^~~~
*** [/data/oiltank-sensor/.pioenvs/oiltank-sensor/src/main.cpp.o] Error 1
========================== [FAILED] Took 6.31 seconds ==========================

I am not sure what is wrong here - any help appreciated!

Thank you!

This looks like an error due too an ESP-Home update.
I have no clue what to do. But this is the main reason why I never update an ESP-Home node unless I really have to

Seeing exactly the same problem here trying to compile to upload a new config to my D1 Mini Pro board. It happens as soon as I add the vl53l1x.h into the ESP yaml file that I am trying to flash to my board. Is it a problem with ESPHome no longer accepting the syntax used in the custom component perhaps?

#include "esphome.h"

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X tof_sensor;

class MyCustomSensor : public PollingComponent, public Sensor {
 public:
  // constructor
  MyCustomSensor() : PollingComponent(5000) {} // polling every 5s

  void setup() override {
    // This will be called by App.setup()
    Wire.begin();
    Wire.setClock(400000); // use 400 kHz I2C

    tof_sensor.setTimeout(500);
    tof_sensor.setAddress(0x29);
    if (!tof_sensor.init()) {
      ESP_LOGE("VL53L1X custom sensor", "Failed to detect and initialize sensor!");
      while (1);
    }

    tof_sensor.setDistanceMode(VL53L1X::Short);
    tof_sensor.setMeasurementTimingBudget(500000);

    tof_sensor.startContinuous(50);
  }

  void update() override {
    uint16_t mm = tof_sensor.read();
    
    if (!tof_sensor.timeoutOccurred()) {
      publish_state(mm);
    } else {
      ESP_LOGE("VL53L1X custom sensor", "Timeout during read().");
    }
  }
};

The log from trying to compile a very simple ESPHome config:

INFO Reading configuration /config/esphome/oiltank.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing oiltank (board: d1_mini_pro; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)

HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
Library Manager: Installing VL53L1x
Library Manager: Warning! More than one package has been found by VL53L1x requirements:

  • pololu/VL53L1X @ 1.3.1
  • mbed-1576028839/VL53L1X @ 0.0.0+sha.a71614c1b15b
  • mbed-jvfausto/VL53L1X @ 0.0.0+sha.621552ff1de9
  • mbed-st-expansion-sw-team/VL53L1X @ 0.0.0+sha.f16727052990
    Library Manager: Please specify detailed REQUIREMENTS using package owner and version (shown above) to avoid name conflicts

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: VL53L1X @ 1.3.1 has been installed!
Dependency Graph
|-- 1.2.3
|-- 1.0
|-- 1.3.1
|-- 2.1.0
| |-- 1.2.3
| |-- 1.0
| |-- 1.0
|-- 1.1.1
|-- 1.0
|-- 1.2
|-- 6.18.5
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/api_connection.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/api_frame_helper.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/api_server.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/list_entities.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/proto.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/api/user_services.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/esp8266/core.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/esp8266/gpio.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/esp8266/preferences.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/json/json_util.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/logger/logger.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/md5/md5.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/mdns/mdns_component.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/mdns/mdns_esp32_arduino.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/mdns/mdns_esp_idf.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/network/util.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/ota/ota_component.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/socket/socket.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/web_server/list_entities.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/web_server/web_server.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/web_server_base/web_server_base.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/wifi/wifi_component.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/application.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/color.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/component.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/component_iterator.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/controller.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/entity_base.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/helpers.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/log.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/scheduler.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/esphome/core/util.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/src/main.cpp.o
Generating LD script /data/oiltank/.pioenvs/oiltank/ld/local.eagle.app.v6.common.ld
Compiling /data/oiltank/.pioenvs/oiltank/lib975/ESPAsyncTCP-esphome/AsyncPrinter.cpp.o
Compiling /data/oiltank/.pioenvs/oiltank/lib975/ESPAsyncTCP-esphome/ESPAsyncTCP.cpp.o
In file included from src/main.cpp:26:
src/tof_vl53l1x.h:8:63: error: expected class-name before ‘{’ token
8 | class MyCustomSensor : public PollingComponent, public Sensor {
| ^
src/tof_vl53l1x.h: In member function ‘virtual void MyCustomSensor::update()’:
src/tof_vl53l1x.h:35:7: error: ‘publish_state’ was not declared in this scope
35 | publish_state(mm);
| ^~~~~~~~~~~~~
*** [/data/oiltank/.pioenvs/oiltank/src/main.cpp.o] Error 1
========================= [FAILED] Took 90.55 seconds =========================

I was hoping that the vl53l1x sensor would have been supported natively in ESPHome by now rather than having to use the custom component, but perhaps soon it will.

Hi Gareth, I’ve noticed that my code has started compiling correctly again, even though I haven’t updated ESPHone. I have updated Supervisor and Core to the latest versions however, so something withing these releases must has resolved the compile problem.