Thanks Tom!
I think I got this correct, I presume the numbering follows left to right (yellow=V CC GND=Brown) as shown in my pictures?
Thanks Tom!
This is a really good project for learning ESPHome and working with an ESP prototype board. You can use any ESP board. My board of choice is the Wemos D1 Mini. They are cheap and I buy them usually from AliExpress five at a time.
If you would rather take a shortcut, Screek Workshop | eBay Stores has one for under $11, and it has ESPHome already installed.
So when I add these relevant parts to my config.yaml file, I get these errors from the Developer Tools configuration checker
Configuration warnings
Platform error ‘sensor’ from integration ‘bh1750’ - Integration ‘bh1750’ not found. Integration error: i2c - Integration ‘i2c’ not found.
Am I doing something wrong or do I just need to reboot for the configuration to load and turn on the ESP32?
OPPS…hope I did not burn something out as I had plugged it in…got them reversed to the right position thank you for correcting me!
Please don’t post pictures of text. Post the actual text and format it for the forum: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16
We need you entire sensor:
section at least.
Sensor should be ok with reverse polarity.
Sorry about the picture of text was trying to make sure I did not put any sensitive information in the post but I looked through my config file and it has nothing sensitive so here is my whole config if that helps?
default_config:
frontend:
themes: !include_dir_merge_named themes
extra_module_url:
- /local/card-mod.js
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
input_number:
dual_thermostat_target:
name: Dual Thermostat Target Temperature
min: 50 # Adjust the min and max values as needed
max: 90
step: 1
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
sensor:
platform: template
sensors:
family_room_average:
friendly_name: “Family Room Average”
unit_of_measurement: “°F”
value_template: >-
{{
(states(‘sensor.nest_ac_heat_temperature’) | float +
states(‘sensor.family_dot_new_temperature’) | float) / 2 | round(2)
}}
bedroom_average:
friendly_name: “Bedroom Average”
unit_of_measurement: “°F”
value_template: >-
{{
(states(‘sensor.primary_bedroom_dot_temperature’) | float +
states(‘sensor.leak_sensor_temperature’) | float) / 2 | round(2)
}}
housewide_temperature:
friendly_name: “Housewide Temperature”
unit_of_measurement: “°F”
value_template: >-
{{
(states(‘sensor.family_room_average’) | float * 0.75 +
states(‘sensor.bedroom_average’) | float * 0.25) | round(2)
}}
nest_ac_heat_temperature:
friendly_name: “Nest-House Temperature”
unit_of_measurement: “°F”
value_template: “{{ states(‘climate.nest_ac_heat’) | float }}”
mini_split_bedroom_temperature:
friendly_name: “Mini Split-BedRm Temperature”
unit_of_measurement: “°F”
value_template: “{{ states(‘climate.30786325850206_climate’) | float }}”
platform: weatheralerts
state: FL
zone: 160
county: 115
platform: noaa_tides
station_id: 8725889
unit_system: english
platform: bh1750
name: “BH1750 Illuminance”
address: 0x23
update_interval: 60s
homeassistant:
packages: !include_dir_named packages
input_select:
dual_thermostat_mode:
name: Dual Thermostat Mode
options:
- Heat
- Cool
- Off
initial: Heat # Set the initial mode as desired
icon: mdi:thermostat
input_boolean:
bathroom_toilet_switch:
name: Bathroom Toilet Switch
initial: off
cloud:
PS…I got a warning about formatting it for forum but not sure how to do that?
I told you how:
However, It appears you are adding this to your configuration.yaml file. That is not where the config goes. It goes in its own file in the config/esphome
folder. Each ESPHome device gets its own file there. Please have a read of this:
Thanks Tom,
Very helpful I will read up. I am learning a lot! one of my longer-term goals is to use this knowledge to hook up a sensor through ESPhome that uses radar to determine water levels to make a tide gauge for my dock that reads the tide level and digging in here is a really good start.
I installed ESPHome add on as described and since I already had my ESP working as a bluetooth proxy it picked it up already with some entries in the config file for that esp32. I then modified it’s yaml configuration file by adding in what I tried adding before and used the verify function of ESP to make sure it was not going to cause problems (it said there were problems with some of my ISC settings so I stripped those out since I had them as the original defaults anyway so they were technically redundant. I saved the yaml and verified it’s in the correct configuration file within ESPHome as previously described. When I ran the “install” it worked, but did generate an error at the end although the yaml was added when I checked manually by the file editor. Inside HA, I could not find any entities created with the new configuration but perhaps that’s not the anticipated behavior? And perhaps I need to use this ESP as dedicated to this light sensor OR am I correct that I can use it this way both as a bluetooth proxy AND as an ambient light sensor? Once I get one running, my goal will be to get several ESPs anyway to sense light levels in various rooms. Also note in the code posted below I removed the key not sure that’s something that should be public but it’s there as it should be. Here’s the config code wrapped, my additions were at the very end.
substitutions:
name: esp32-bluetooth-proxy-9670cc
friendly_name: Bluetooth Proxy 9670cc
packages:
esphome.bluetooth-proxy: github://esphome/firmware/bluetooth-proxy/esp32-generic.yaml@main
esphome:
name: ${name}
name_add_mac_suffix: false
friendly_name: ${friendly_name}
api:
encryption:
key: [actualkeyhidden]
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
i2c:
sensor:
- platform: bh1750
name: "BH1750 Illuminance"
address: 0x23
update_interval: 60s
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!
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?