BH1750 sensor doesn't send data

Can someone explain why sensor doesn’t send any data? .yaml code taken from documentation.

Because it failed to turn it on. So we need to know how it is connected and your complete yaml. It’s no good just saying you got the yaml from the docs it’s what you did with that yaml that is important.

And post your logs and code always using code tags, not as an image.

its connected to GPIO7 and GPIO8 pins.
also pir motion enabled to the same board via binary sensor

.yaml

esphome:
  name: esphome-web-a10a90
  friendly_name: PIRmotion
  min_version: 2024.11.0
  name_add_mac_suffix: false

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

logger:

api:

ota:
  platform: esphome
  
wifi:
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password

i2c:
  sda: GPIO7
  scl: GPIO8
  scan: true
  id: bus_a

binary_sensor:
  - platform: gpio
    id: pir_pin1
    pin:
      number: GPIO4
      mode: INPUT
    device_class: motion

  - platform: gpio
    id: pir_pin2
    pin:
      number: GPIO5
      mode: INPUT
    device_class: motion

  - platform: template
    name: "Combined PIR Sensor"
    lambda: |-
      // Return true if either PIR sensor is active
      return id(pir_pin1).state || id(pir_pin2).state;
    device_class: motion
  
sensor:
  - platform: bh1750
    i2c_id: bus_a
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 1s

logs?

without them we are just guessing

1 Like

@neel-m
I changed pins to try anothers

INFO Upload took 3.18 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.144 using esphome API
INFO Successfully connected to esphome-web-a10a90 @ 192.168.1.144 in 5.131s
INFO Successful handshake with esphome-web-a10a90 @ 192.168.1.144 in 0.026s
[20:30:42][I][app:100]: ESPHome version 2025.3.1 compiled on Apr  4 2025, 20:30:05
[20:30:42][C][wifi:600]: WiFi:
[20:30:42][C][wifi:428]:   Local MAC: xx
[20:30:42][C][wifi:433]:   SSID: [redacted]
[20:30:42][C][wifi:436]:   IP Address: 192.168.1.144
[20:30:42][C][wifi:439]:   BSSID: [redacted]
[20:30:42][C][wifi:441]:   Hostname: 'esphome-web-a10a90'
[20:30:42][C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[20:30:42][C][wifi:447]:   Channel: 11
[20:30:42][C][wifi:448]:   Subnet: 255.255.255.0
[20:30:42][C][wifi:449]:   Gateway: 192.168.1.1
[20:30:42][C][wifi:450]:   DNS1: 192.168.1.1
[20:30:42][C][wifi:451]:   DNS2: 0.0.0.0
[20:30:42][C][logger:177]: Logger:
[20:30:42][C][logger:178]:   Max Level: DEBUG
[20:30:42][C][logger:179]:   Initial Level: DEBUG
[20:30:42][C][logger:181]:   Log Baud Rate: 115200
[20:30:42][C][logger:182]:   Hardware UART: USB_SERIAL_JTAG
[20:30:42][C][i2c.idf:083]: I2C Bus:
[20:30:42][C][i2c.idf:084]:   SDA Pin: GPIO3
[20:30:42][C][i2c.idf:085]:   SCL Pin: GPIO2
[20:30:42][C][i2c.idf:086]:   Frequency: 50000 Hz
[20:30:42][C][i2c.idf:092]:   Recovery: bus successfully recovered
[20:30:42][I][i2c.idf:102]: Results from i2c bus scan:
[20:30:42][I][i2c.idf:108]: Found i2c device at address 0x23
[20:30:43][C][bh1750.sensor:118]: BH1750 'BH1750 Illuminance'
[20:30:43][C][bh1750.sensor:118]:   Device Class: 'illuminance'
[20:30:43][C][bh1750.sensor:118]:   State Class: 'measurement'
[20:30:43][C][bh1750.sensor:118]:   Unit of Measurement: 'lx'
[20:30:43][C][bh1750.sensor:118]:   Accuracy Decimals: 1
[20:30:43][C][bh1750.sensor:119]:   Address: 0x23
[20:30:43][C][bh1750.sensor:124]:   Update Interval: 1.0s
[20:30:43][C][mdns:116]: mDNS:
[20:30:43][C][mdns:117]:   Hostname: esphome-web-a10a90
[20:30:43][C][esphome.ota:073]: Over-The-Air updates:
[20:30:43][C][esphome.ota:074]:   Address: esphome-web-a10a90.local:3232
[20:30:43][C][esphome.ota:075]:   Version: 2
[20:30:43][C][safe_mode:018]: Safe Mode:
[20:30:43][C][safe_mode:019]:   Boot considered successful after 60 seconds
[20:30:43][C][safe_mode:021]:   Invoke after 10 boot attempts
[20:30:43][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[20:30:43][C][api:140]: API Server:
[20:30:43][C][api:141]:   Address: esphome-web-a10a90.local:6053
[20:30:43][C][api:145]:   Using noise encryption: NO
[20:30:43][W][bh1750.sensor:102]: Reading BH1750 data failed
[20:30:43][D][sensor:093]: 'BH1750 Illuminance': Sending state nan lx with 1 decimals of accuracy
[20:30:43][D][api:103]: Accepted 192.168.1.116
[20:30:43][D][api.connection:1801]: Home Assistant 2025.3.4 (192.168.1.116): Connected successfully
[20:30:43][W][bh1750.sensor:053]: Turning on BH1750 failed
[20:30:43][D][sensor:093]: 'BH1750 Illuminance': Sending state nan lx with 1 decimals of accuracy
[20:30:45][W][bh1750.sensor:102]: Reading BH1750 data failed
[20:30:45][D][sensor:093]: 'BH1750 Illuminance': Sending state nan lx with 1 decimals of accuracy

The log says it found something at 0x23 on the i2c bus, which is good. But later it says it failed reading from the sensor, which is bad.

So, this doesn’t appear to be a simple issue. It could be your sensor really is bad, or it could be the connection to it is less than great.

Did it ever work?
How are things connected?

Sensor is new. Never used.
esp32nano board. Can it be a problem?


It can, but not probable because scan finds your sensor. How is your complete wiring between arduino and sensor(not visible on images)?

The cable is short enough to not introduce any appreciable crosstalk, those solder joints on the sensor board aren’t great but the fact that it does find the sensor but fails to turn it on suggests a dead sensor to me.

Try touching up the sensor board solder joints. Also try spreading apart the parallel wires between the boards. This was for a much longer cable but see my issue and its solution here under “Notes”: Outdoor Lux Sensor

Is it this board you are using?

https://docs.arduino.cc/tutorials/nano-esp32/cheat-sheet/

If so pins A1 and A2 are not gpio7 and 8 as in your yaml. Your wire need to be on D4 and D5. if it’s not this board ignore what I said, still not sure how it finds your sensor though.

I can’t explain why, but… The GND pin on the light sensor wasn’t working at all.
It had no effect whether it was on or off. Instead, I connected the ‘ADO’ pin, which theoretically shouldn’t have been connected at all. I grounded it (connected it to GND), and everything started working.

Mysticism. Or maybe someone can explain it ? Board pins switched?

Or really bad soldering;;;

1 Like

Yes, I re-soldered the GND and it started working well.
Thank you all for the help ! :slight_smile:

1 Like

Which I said a number of posts ago.