How to build ESP light sensor

You need to tell us what the error was. All the HA mind readers were killed in the great pogrom of 2020.

Here’s the error log…it’s just the install part so I was not sure it’s relevant.

ā€œInstall esp32-bluetooth-proxy-9670cc.yamlā€ <= this was the title following is the outputted log (Error at end of log)

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/esp32-bluetooth-proxy-9670cc.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-bluetooth-proxy-9670cc (board: esp32dev; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.40405.230623 (4.4.5) 
 - tool-cmake @ 3.16.9 
 - tool-ninja @ 1.10.2 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.4
|-- Improv @ 1.2.3
Linking .pioenvs/esp32-bluetooth-proxy-9670cc/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection17send_sensor_stateEPNS_6sensor6SensorEf+0x8): undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0x8): undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0xc): undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_state(esphome::sensor::Sensor*, float)':
/data/build/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.cpp:463: undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_info(esphome::sensor::Sensor*)':
/data/build/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.cpp:476: undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/build/esp32-bluetooth-proxy-9670cc/src/esphome/components/api/api_connection.cpp:478: undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0x54): undefined reference to `vtable for esphome::i2c::IDFI2CBus'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0x58): undefined reference to `vtable for esphome::i2c::IDFI2CBus'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0xd8): undefined reference to `vtable for esphome::bh1750::BH1750Sensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0xdc): undefined reference to `vtable for esphome::bh1750::BH1750Sensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0x138): undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0x13c): undefined reference to `esphome::sensor::Sensor::set_state_class(esphome::sensor::StateClass)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o:(.literal._Z5setupv+0x144): undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o: in function `std::_Vector_base<std::function<void ()>, std::allocator<std::function<void ()> > >::_Vector_impl::_Vector_impl()':
/data/cache/platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_vector.h:96: undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/main.o: in function `setup()':
/data/build/esp32-bluetooth-proxy-9670cc/src/main.cpp:242: undefined reference to `esphome::sensor::Sensor::set_state_class(esphome::sensor::StateClass)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/build/esp32-bluetooth-proxy-9670cc/src/main.cpp:244: undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/core/controller.o:(.literal._ZN7esphome10Controller16setup_controllerEb+0x8): undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-9670cc/src/esphome/core/controller.o: in function `esphome::Controller::setup_controller(bool)':
/data/build/esp32-bluetooth-proxy-9670cc/src/esphome/core/controller.cpp:29: undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32-bluetooth-proxy-9670cc/firmware.elf] Error 1
========================= [FAILED] Took 165.67 seconds =========================

It did not work.

That’s your bluetooth proxy. I don’t know anything about that.

I think I will just order a dedicated ESP32 for this project then to keep this as simple as possible…Tom do you have any that your recommend for a beginner like me? Reliability would be most important I don’t mind spending a few extra bucks for higher quality.

There are many recommendations in this topic:

Hi Tom<

I managed not to get it all installed and the entity is showing up in home assistant. However, I am not getting it to return any values and I think I have the wires wrong. The chip looks very similar to the one you are using but has slightly different pinout markings.

It’s the SCL and DAT I am most concerned with although there are also 2 GNDs and I am not sure they are interchangable. Here’s a picture of the chip I am using

Yes they are.

DAT (SDA) goes to D21
SCL goes to D22

Thank you very much Tom! That’s actually how I had it, just required a reboot and ESP update then it’s now working! I wanted to say that you so much for your patience on this one and hopefully my mistakes will help others to learn too this is a great learning project and will be a spring board for me as I learn to apply ESPHOME to other sensors!
image

Hello, can they help me too?
I have the same sensor, and my ESP is WROOM-32D.

I’m using arduino IDE to code my esp, but I can’t get the BH1750 sense to work, it doesn’t pick up the data correctly to display on the serial monitor, and when I use the sensor library it doesn’t work either, even though I’ve followed the esp. assembly correctly.

Can they help-me with the code?