Skip to content

Instantly share code, notes, and snippets.

@RubenKelevra
Last active January 30, 2023 02:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RubenKelevra/0d70d6b4c8e4bc9aedc8682865731d65 to your computer and use it in GitHub Desktop.
Save RubenKelevra/0d70d6b4c8e4bc9aedc8682865731d65 to your computer and use it in GitHub Desktop.
ESPHome example for an ambient light sensor with some smoothing / throttleling but overall low delay
esphome:
name: $devicename
platform: ESP8266
board: d1_mini
substitutions:
devicename: ambient-light-sensor
friendly_name: "Ambient Light Sensor"
logger:
esp8266_store_log_strings_in_flash: false
mdns:
disabled: true
api:
encryption:
key: !secret api_key-ambient-light-sensor
ota:
password: !secret ota_password_ambient-light-sensor
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.8.27
gateway: !secret wifi_gateway
subnet: !secret wifi_subnet
dns1: !secret wifi_dns1
dns2: !secret wifi_dns2
fast_connect: true
reboot_timeout: 5min
i2c:
sda: D1
scl: D2
scan: true
id: bus_a
sensor:
- platform: tcs34725
i2c_id: bus_a
red_channel:
name: "$friendly_name Red Channel relative"
accuracy_decimals: 2
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.5
green_channel:
name: "$friendly_name Green Channel relative"
accuracy_decimals: 2
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.5
blue_channel:
name: "$friendly_name Blue Channel relative"
accuracy_decimals: 2
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.5
clear_channel:
name: "$friendly_name Clear Channel"
accuracy_decimals: 5
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.5
illuminance:
name: "$friendly_name Illuminance"
accuracy_decimals: 2
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.2
color_temperature:
name: "$friendly_name Color Temperature"
accuracy_decimals: 2
filters:
- exponential_moving_average:
alpha: 0.05
send_every: 2
send_first_at: 2
- or:
- throttle: 10s
- delta: 0.5
gain: 1x
integration_time: 101ms
#integration_time maximum: 614ms (don't use this for an outdoor sensor!)
glass_attenuation_factor: 1.0
address: 0x29
update_interval: 1s
output:
- platform: gpio
pin: D3
id: white_led
inverted: false
light:
- platform: binary
output: white_led
name: "$friendly_name White LED"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment