You will need to change the I2C pins as well. From this:
i2c:
sda: 21
scl: 22
to:
i2c:
sda: D2
scl: D1
You will need to change the I2C pins as well. From this:
i2c:
sda: 21
scl: 22
to:
i2c:
sda: D2
scl: D1
Thank you - gonna get on this - fed up of the lights being left on in the bright light!!!
These lines be changed to the following, right?
platform: ESP32 -> esp8266
board: mhetesp32minikit -> nodemcuv2
(educated guess from here)
Yes, if that is the ESP8266 board you have.
This should work:
esphome:
name: lux-sensor
platform: ESP8266
board: d1_mini
Thanks - will give that a go when the BH1750 arrives
Then need to work out how I’m going to power it longterm, but that’s a secondary problem, will probably just usb it on the windowsil
I did that for a few years. The only issue I had was the USB cable sheath disintegrating in the sunlight.
My BH1750 is this one
Appears the order is different to your module
Am i right in:
I’ve connected it like that for now, but sadly still showing offline for some reason
esphome:
name: lux-sensor
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid # CHANGE THIS SECTION TO SUIT YOUR NETWORK
password: !secret wifi_password
#manual_ip:
# static_ip: 10.1.1.76
# gateway: 10.1.1.1
# subnet: 255.255.255.0
api:
# password: !secret api_password ## No longer recommended if using encryption. ##
encryption:
key: "[copied from my other ESP8266]"
logger:
ota:
password: "[copied from my other ESP8266]"
binary_sensor:
- platform: status
name: "Lux Sensor Status"
i2c:
sda: D2
scl: D1
scan: False
sensor:
- platform: wifi_signal
name: "Outside Light Level WiFi Signal"
id: os_ll
update_interval: 15s
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
send_first_at: 1
- platform: bh1750
name: "Outside Light Level"
address: 0x23
update_interval: 1s
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 10
send_first_at: 1
- or:
- throttle: 60s
- delta: 5
switch:
- platform: restart
name: "Lux Sensor Restart"
Also few notes/questions…
I’m not quite sure what I’ve done wrong tho as it installs, but doesn’t seem to be connecting to the wifi
Yes that is correct. SDA = “Serial Data”. SCL = “Serial Clock” for I2C communication.
Um…
Connect via USB and check the logs in ESPHome.
Thanks for your help
It doesn’t seem to be pulling any logs
Connection seems fine
Code validated
Flash succeeded
Logs… blank
EDIT:
Okay, tried a different machine, hit reset and then it pulled some logs
[logger:351]: Log initialized
[C][ota:473]: There have been 1 suspected unsuccessful boot attempts.
[I][app:029]: Running through setup()...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]: Local MAC: [redacted]
[D][wifi:455]: Starting scan...
[D][wifi:470]: Found networks:
[I][wifi:513]: - '[correctwifi]' [redacted]▂▄▆█
[D][wifi:515]: Channel: 9
[D][wifi:516]: RSSI: -35 dB
[I][wifi:513]: - '[correctwifi]' [redacted]▂▄▆█
[D][wifi:515]: Channel: 1
[D][wifi:516]: RSSI: -59 dB
[I][wifi:513]: - '[correctwifi]' [redacted]▂▄▆█
[D][wifi:515]: Channel: 3
[D][wifi:516]: RSSI: -74 dB
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[D][wifi:518]: - [redacted] [redacted]▂▄▆█
[I][wifi:300]: WiFi Connecting to '[correctwifi]'...
[I][wifi:587]: WiFi Connected!
[C][wifi:405]: Local MAC: [redacted]
[C][wifi:410]: SSID: [redacted]
[C][wifi:411]: IP Address: 192.168.1.105
[C][wifi:412]: BSSID: [redacted]
[C][wifi:414]: Hostname: 'lux-light-illuminance-sensor'
[C][wifi:416]: Signal strength: -41 dB ▂▄▆█
[C][wifi:420]: Channel: 9
[C][wifi:421]: Subnet: 255.255.255.0
[C][wifi:422]: Gateway: 192.168.1.1
[C][wifi:423]: DNS1: 192.168.1.1
[C][wifi:424]: DNS2: 0.0.0.0
[D][wifi:596]: Disabling AP...
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]: Address: lux-light-illuminance-sensor.local:8266
[C][ota:101]: Using Password.
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2023.12.9 compiled on Feb 2 2024, 15:42:21
[C][wifi:573]: WiFi:
[C][wifi:405]: Local MAC: [redacted]
[C][wifi:410]: SSID: [redacted]
[C][wifi:411]: IP Address: 192.168.1.105
[C][wifi:412]: BSSID: [redacted]
[C][wifi:414]: Hostname: 'lux-light-illuminance-sensor'
[C][wifi:416]: Signal strength: -42 dB ▂▄▆█
[C][wifi:420]: Channel: 9
[C][wifi:421]: Subnet: 255.255.255.0
[C][wifi:422]: Gateway: 192.168.1.1
[C][wifi:423]: DNS1: 192.168.1.1
[C][wifi:424]: DNS2: 0.0.0.0
[C][logger:439]: Logger:
[C][logger:440]: Level: DEBUG
[C][logger:441]: Log Baud Rate: 115200
[C][logger:443]: Hardware UART: UART0
[C][captive_portal:088]: Captive Portal:
[C][mdns:115]: mDNS:
[C][mdns:116]: Hostname: lux-light-illuminance-sensor
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]: Address: lux-light-illuminance-sensor.local:8266
[C][ota:101]: Using Password.
[C][api:139]: API Server:
[C][api:140]: Address: lux-light-illuminance-sensor.local:6053
[C][api:142]: Using noise encryption: YES
So it’s connected to the wifi
Yet still offline
EDIT2: Reflashed from this new machine and seems to be online
BUT…
Not getting any values for the sensor
Alright!! A morning of messing about later…
So I got a reading, briefly. Seems one of the connections is duff, but seems to work now briefly!!
Think I’ll solder the connections and eliminate any problems
sounds as though you might have solved; but reading your logs I could not see the i2c scan. Can you see the scan and result? You should then see the log spitting out a sensor result every 1s.
I’m getting updates to my entity every 10s or so now, so I think it was a loose connection issue (the cable provided didn’t seem to fit properly so I presume it’s that…)
@tom_l very nice project, I have ordered some of the BH1750FVI to build the same system.
Just one question: In the picture of the first post (the one with the green roof), it seems you have installed the sensor to direct sunlight, is this correct? In this case, does the sensor work well also in summer? Do not become too hot?
It has been through two summers without issue.
Nice, i will try. I live in Sicily and last summer we had 45°, I hope the sensor doesn’t melt
Thank you.
Very nice project. Would you be so kind showing some close-up picture of the outside sensor box as well? Thanks.
I’m not getting up on the roof any time soon sorry.
It’s just these “Lego” bits:
Box: https://www.jaycar.com.au/polycarbonate-enclosure-with-mounting-flange-base/p/HB6211
Gland: https://www.jaycar.com.au/5-10mm-dia-ip68-waterproof-cable-glands-pack-of-2/p/HP0727
BH1750 with cover: https://www.aliexpress.com/item/1005003914658600.html
And some roof and gutter (neutral cure) silicone sealant to glue the BH1750 cover to the box.