BH1750 with NodeMCUv3 : Found no i2c devices

Hi Everyone,

I’m trying to build my first sensor. I configured NodeMCUv3 with ESPHome integration within HA and added sensors step by step as guide suggested. Temperature/Humidity sensor (dht) is working fine. Motion sensor (AM312) is working fine. LUX sensor BH1750 is not coming up.

I tried many different config that I found on HA and ESP forum but nothing seems to work.

Here is the error :slightly_frowning_face:

[01:27:53][C][i2c:028]: I2C Bus:
[01:27:53][C][i2c:029]:   SDA Pin: GPIO4
[01:27:53][C][i2c:030]:   SCL Pin: GPIO5
[01:27:53][C][i2c:031]:   Frequency: 50000 Hz
[01:27:53][I][i2c:033]: Scanning i2c bus for active devices...
[01:27:53][I][i2c:049]: Found no i2c devices!

[01:27:53][C][bh1750.sensor:027]: BH1750 'Bedroom LUX'
[01:27:53][C][bh1750.sensor:027]:   Unit of Measurement: 'lx'
[01:27:53][C][bh1750.sensor:027]:   Accuracy Decimals: 1
[01:27:53][C][bh1750.sensor:027]:   Icon: 'mdi:brightness-5'
[01:27:53][C][bh1750.sensor:028]:   Address: 0x23
[01:27:53][E][bh1750.sensor:030]: Communication with BH1750 failed!
[01:27:53][C][bh1750.sensor:048]:   Resolution: 0.5
[01:27:53][C][bh1750.sensor:049]:   Update Interval: 5.0s

My config :
i2c:
sda: D2
scl: D1
scan: True

sensor:

  • platform: dht
    pin: D7
    model: dht22
    temperature:
    name: “Bedroom Temp”
    humidity:
    name: “Bedroom Humidity”
    update_interval: 30s

  • platform: bh1750
    name: “Bedroom LUX”
    address: 0x23
    measurement_time: 128
    update_interval: 5s

I shall be thankful if someone can take a look here and help me out.

Thanks,
Dhaval

Please format your pasted code correctly.

Do you have the BH1750 address pin pulled low?

Are you powering it from 3.3v?

Hi Tom,

Thank you for your time.

Here is the complete code in correct format.

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:



sensor:
  - platform: dht
    pin: D7
    model: dht22    
    temperature:
      name: "Bedroom Temp"
    humidity:
      name: "Bedroom Humidity"
    update_interval: 30s
    
  - platform: bh1750
    name: "Bedroom LUX"
    address: 0x23
    measurement_time: 128
    update_interval: 5s
    

binary_sensor:
  - platform: gpio
    pin: D6
    name: "Bedroom Motion"
    device_class: motion
    
i2c:
  sda: D2
  scl: D1
  scan: True

I don’t really know what ‘address pin pulled low’ means. I did try to learn it thru different manuals yesterday and connected the address pin to GND and set ‘0x23’ as address.

VCC – Connected to 3v on nodemcu
GND – Connected to GND pin on nodemcu
SDA – Connected to D2 on nodemcu
SCL – Connected to D1 on nodemcu
ADD – Connected to GND on nodemcu

Is there a way I can access this nodemcu thru GUI by the private IP address? I tried to connect to the IP thru web browser but it displays ‘refused to connect’ message

No need to ADD to GND.
What is the distance from the sensor to the node?

Floating inputs are a bad idea.

I have it here for 1 year without a problem.

bh1750

Good for you. This guy has a problem though so lets eliminate possibilities.

Just to clarify what can be found in the documents.
ADDR
Device address pin, used to select the address when more than two modules are connected

I know that. It changes the address between one of two options. The esphome i2c scan is not finding either address though so to eliminate the possibility that a floating input is the problem I advised him to tie it high or low to select one of the address.

Hi Tom and Pepe,

Thanks for your efforts.

First I tried the setup without connecting ADD pin to anything. It didn’t work so I tried to educate myself on potential issues. I came across the floating inputs documents and tried to correct my mistake by connecting ADD to GND pin on Nodemcu. That didn’t work either.

I just tested it again few minutes ago without connecting ADD pin. Same result. “Found no i2c devices”.

The distance between sensor and the node is about 15 cm. All sensors, DHT22, BH1750 & AM312 are connected to the Nodemcu thru Jumper cables. I did change those Jumper cables connecting BH1750 and Nodemcu just to rule out any cable related issue.

The diagram provided by Pepe displays 10Kohm resistors. Just to clarify, I do not have any resistors connected between Nodemcu and BH1750. Is that a potential issue?

I read a document regarding pull up resistor inbuild in the Nodemcu. I don’t know how to enable it though. I can not open GUI of Nodemcu in a browser thru local IP. Is there a way to do so ?

Regards,
Dhaval

I just tried another way by connecting ADD pin to 3v on Nodemcu and setting the address “0x5C”. That did not work either. Same error.

[23:07:31][C][i2c:028]: I2C Bus:
[23:07:31][C][i2c:029]:   SDA Pin: GPIO4
[23:07:31][C][i2c:030]:   SCL Pin: GPIO5
[23:07:31][C][i2c:031]:   Frequency: 50000 Hz
[23:07:31][I][i2c:033]: Scanning i2c bus for active devices...
[23:07:31][I][i2c:049]: Found no i2c devices!

23:07:32][C][bh1750.sensor:027]: BH1750 'Bedroom LUX'
[23:07:32][C][bh1750.sensor:027]:   Unit of Measurement: 'lx'
[23:07:32][C][bh1750.sensor:027]:   Accuracy Decimals: 1
[23:07:32][C][bh1750.sensor:027]:   Icon: 'mdi:brightness-5'
[23:07:32][C][bh1750.sensor:028]:   Address: 0x5C
[23:07:32][E][bh1750.sensor:030]: Communication with BH1750 failed!
[23:07:32][C][bh1750.sensor:048]:   Resolution: 0.5
[23:07:32][C][bh1750.sensor:049]:   Update Interval: 5.0s

It’s catching stalks, but I don’t use resistors because I have short connecting cables. This is my configuration including Lcd display on one I2C. Notice that I have swapped sda -scl. I don’t remember why I did it like this, but it works for more than a year.

i2c:
  sda: D1
  scl: D2
  
display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x3F
    id: lcd_1
    lambda: |-
      it.printf(0,0, "Doma  > %.1f *C", id(teplota_byt).state);
      it.printf(0,1, "Venku > %.1f *C", id(teplota_ven).state);

dallas:
  - pin: D0
  
sensor:
  - platform: dallas
    address: 0xD500000434A21B28
    name: "Teplota byt"
    id: teplota_byt
    filters:
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 0.0 -> 0.0
          - 21 -> 19
  - platform: homeassistant
    id: teplota_ven
    name: Venku
    entity_id: sensor.venkovni_teplota
  - platform: bh1750
    name: "Senzor jas 6"
    id: svetlo_6
    address: 0x23
    update_interval: 60s

Changed the config and SDA & SCL pins on Nodemcu.

VCC – Connected to 3v on nodemcu
GND – Connected to GND pin on nodemcu
SDA – Connected to D1 on nodemcu
SCL – Connected to D2 on nodemcu
ADD – Connected to GND on nodemcu / Also tried with not connected to anything

i2c:
  sda: D1
  scl: D2
  scan: True

Same error persist.

[01:16:16][C][i2c:028]: I2C Bus:
[01:16:16][C][i2c:029]:   SDA Pin: GPIO5
[01:16:16][C][i2c:030]:   SCL Pin: GPIO4
[01:16:16][C][i2c:031]:   Frequency: 50000 Hz
[01:16:16][I][i2c:033]: Scanning i2c bus for active devices...
[01:16:16][I][i2c:049]: Found no i2c devices!

The internal pull-up resistors required fo operate i2c are enabled automatically and should be fine for 15cm of cable length. You’ve eliminated just about everything I can think of.

Might be time to try another sensor.

I see in the log the I2C bus frequency is 50KHz, change it to 400KHz

1 Like

Good find!

Thank you everyone for your time and help. Unfortunately nothing works.

I ordered a new BH1750 sensor and connected that one. Didn’t work.
I changed the I2c frequency to 400kHz. Didn’t work either.

[18:45:33][C][i2c:028]: I2C Bus:
[18:45:33][C][i2c:029]:   SDA Pin: GPIO4
[18:45:33][C][i2c:030]:   SCL Pin: GPIO5
[18:45:33][C][i2c:031]:   Frequency: 400000 Hz
[18:45:33][I][i2c:033]: Scanning i2c bus for active devices...
[18:45:33][I][i2c:049]: Found no i2c devices!

[18:45:34][C][bh1750.sensor:027]: BH1750 'Bedroom LUX'
[18:45:34][C][bh1750.sensor:027]:   Unit of Measurement: 'lx'
[18:45:34][C][bh1750.sensor:027]:   Accuracy Decimals: 1
[18:45:34][C][bh1750.sensor:027]:   Icon: 'mdi:brightness-5'
[18:45:34][C][bh1750.sensor:028]:   Address: 0x23
[18:45:34][E][bh1750.sensor:030]: Communication with BH1750 failed!
[18:45:34][C][bh1750.sensor:048]:   Resolution: 0.5
[18:45:34][C][bh1750.sensor:049]:   Update Interval: 5.0s

Here is the modified config :

 sensor:
  - platform: dht
    pin: D7
    model: dht22    
    temperature:
      name: "Bedroom Temp"
    humidity:
      name: "Bedroom Humidity"
    update_interval: 30s
  - platform: bh1750
    name: "Bedroom LUX"
    address: 0x23
    measurement_time: 128
    update_interval: 5s

i2c:
  sda: D2
  scl: D1
  scan: True
  frequency: 400kHz

The batch of them I purchased about 6 months ago had sda and scl misslabeled/reversed. try reversing your clock and data pin definitions.

Changed the config. Kept the pin connection same. Didn’t work. Same error.

[19:59:13][C][i2c:028]: I2C Bus:
[19:59:13][C][i2c:029]:   SDA Pin: GPIO5
[19:59:13][C][i2c:030]:   SCL Pin: GPIO4
[19:59:13][C][i2c:031]:   Frequency: 400000 Hz
[19:59:13][I][i2c:033]: Scanning i2c bus for active devices...
[19:59:13][I][i2c:049]: Found no i2c devices!

I flashed tasmota-sensor.bin on another NodemcuV3. Connected the BH1750 sensor to it. No other sensors are connected to this nodemcu.
GND – GND
VCC – 3V
SCL – D1
SDA – D2
ADD – Not connected / Connected to GND

Still it doesn’t work :disappointed: :disappointed:

22:36:47 CMD: i2cscan
22:36:47 MQT: stat/tasmota_79AA5E/RESULT = {"I2CScan":"No devices found"}