@groston and @terryhonn Here is how I created my outside light sensor:
Hook-up the BH1750 to your ESP as follows:
Load up this config to your ESP:
esphome:
name: lux-sensor
platform: ESP32
board: mhetesp32minikit
wifi:
ssid: 'WAPLO' # CHANGE THIS SECTION TO SUIT YOUR NETWORK
password: !secret wifi_pwd
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: !secret api_encryption_key
logger:
ota:
password: !secret esp_pwd
binary_sensor:
- platform: status
name: "Lux Sensor Status"
i2c:
sda: 21
scl: 22
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"
Install it somewhere facing north if you are in the southern hemisphere, or facing south if in the northern hemisphere. Tilted at 90° minus your latitude is optimal but not essential.
Add the integration in Home Assistant:
Notes:
You should keep the I2C connections (SDA and SCL) shorter than 30cm. However if you need to extend the length you can get up to 2m if you use twisted pair cat5 cable like this:
I have my ESP a meter away in the roof where I have wifi:
Initially I used outdoor two pair telephone cable to connect between the ESP and BH1750. As I had power on one pair and SDA and SCL on the other pair I ended up with the connection shown as âBADâ in the above image. This caused loads of crosstalk between SDA and SCL which caused the connection to fail. Even lowering the I2C speed to 10kHz I could only get 30cm and there were still many errors. After changing to some Cat6 cable, with more pairs, connected as shown in the âGOODâ diagram I got 1.5m easy. No errors.
Ideally you would use Cat5/6 cable like this:
- Orange: 3.3V
- Orange-white: GND
- Brown:
GNDSDA - Brown-white: GND
- Blue: SCL
- Blue-white: GND
- Green:
SDAGND - Green-white: GND
This should minimise the crosstalk between SDA and SCL as the green and blue pairs have the biggest twist ratio difference.
EDIT: actually it is blue and brown pairs that have the biggest twist ratio difference.