How to build ESP light sensor

Hi! I have never used ESP in any fashion. My end goal is that I want a good luminance/light/lux sensor. All the battery ones seem to only update every 30-60 seconds.

I found this light sensor that works with ESP home https://www.amazon.com/gp/product/B08PBJX9JP/ref=ox_sc_act_title_2?smid=A30Y6WWS77DGEW&psc=1

I am unsure what I need to build and if any programming is involved. I am moderately computer savvy but not a programmer.

Can anyone tell me an overview of how difficult it would be to do this? From searching online I think I also need an ESP board like this https://www.amazon.com/gp/product/B07Q576VWZ/ref=ox_sc_act_title_3?smid=A2JLTKYCWT3GQ2&psc=1

Is there anything else I need? Note: I am trying to do this the absolutely easiest way so do not mind paying a little more for the easiest and best way of doing this.

Also, I would like this to join via wifi. It is my understanding that HA will auto discover the ESP once it is on the network. However, how do I communicate with the ESP to set it up?

Thank you!

Install the ESPHome addon to HA.
Buy an esp8266 or esp32 board. You can also buy a smaller esp D1 mini.
Buy the BH1750 sensor.
You will need a USB cable to connect esp and HA to be able to upload yaml to esp.
Then look here

If you don’t know how to connect and add a new device, write.

1 Like

Thanks so much! Is there any difference between those options as far as ease of use? Or do you have a favorite?

This BH1750 sensor comes with a fresnel lens and the required connecting cables. 3-D print a small rectangle box with a hole in top (typically for IR motion sensor) and you’re good to go.

1 Like

If you want to avoid soldering (cheapest path for <$5 in total) you might work’a’round that choosing more expensive versions with some connector system like Qwiic for example :point_down:

2 Likes

Thanks @orange-assistant @FredTheFrog and @pepe59 ! I just ordered all those options. Wish me luck!

https://community.home-assistant.io/t/outdoor-lux-sensor/421926

I used the same sensor as recommend by FredTheFrog, though I got it from Aliexpress.

1 Like

Hey All,
I am giving this project a shot and have a working ESP32 (as a bluetooth proxy) but need a little help with the pinout connections. There is a video online but it uses a different ESP32 and it looks like although the pinout from mine is pretty standard it’s not clear which are the right ones for using the ambient sensor. Here is a picture of the chip and codes. Any help is appreciated.


  1. VCC → 3.3V
  2. SCL → P22 (I2C SCL)
  3. DAT → P21 (I2C SDA)
  4. GND → GND
  5. ADDR → No connection

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?

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.

No need to assume anything (you got it wrong):

So when I add these relevant parts to my config.yaml file, I get these errors from the Developer Tools configuration checker
image
image
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?

Load default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

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

Example configuration.yaml entry

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

configuration.yaml entry to enable the cloud integration

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:

1 Like

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