DIY Lux Sensor with BH1750 (Battery)

I’m currently using my weather station lux sensor. Unfortunately (for me) this has turned out to be too slow. So (fortunately for you) I’m making a new BH1750 ESPHome sensor when the parts arrive next month. I’ll post something and tag you.

Also that post is out of date as I endued up using the delta filter in ESPHome to update the sensor as needed rather than every 3 minutes. This made it much more responsive, not so good for a battery powered application though.

That would be awesome, thank you! I’d really like to be able to have a sensor in each room, for more granularity, so that regardless of the reason that room is darkened (after sunset, thunderstorm, passing clouds, eclipse, horde of zombie drones, etc) HA can assist in brightening it up.

Very much looking forward to your update.

Tom
I realise this post is a bit old but as a newcomer to ESPHome I wanted to check my understanding of the “delta” filter.

My understanding is that if I am collecting say temperature readings and I set an update_interval of 240 seconds, it will report every 4-minutes even if the temp is identical… 22-degrees… 22-degrees. If I set a delta of 0.5, I assumed it would only report the temp if it was more than 22.5 (or less than 21.5). This appears to be the case in my testing. I have 17 minutes between reporting with the temp stable. If I sit on the thermistor, it will report the increased temp in 4 minutes - and then 4 minutes later with the thermistor in cool air it reports the lower temp.

I assumed this would be good for battery life. (I am about to tinker with deep-sleep)

Your comment makes me think it is supposed to report every time it moves more than 0.25.

Am I wrong or does update_interval take precedence?

It depends how you combine the filters. I do it like this:

  - 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

So the base sensor updates at 1 sec intervals. This is fed to s sliding window average (to reduce noise), that reports a value every 10 seconds. The output of the average is fed to an ORed throttle and delta filter. If the value is only changing less than +/- 5 then values are sent to home assistant every minute. If however the value changes more than +/- 5 then the value is sent instantly.

Obviously a 1 sec update interval is not going to be any use to a battery powered sensor.

I did write up the project. It is here: https://community.home-assistant.io/t/outdoor-lux-sensor/421926

Tks - a 1 second update would kill my system quickly.

I am looking at a battery powered sensor to track the temperature of a hot water system - hence the thermistor. I was also wanting to check the battery level (Lipo) but only needed to update every 30 minutes or a change of more than 0.25%. Pin 35 on my board gets power from the battery charger through a divider so gives a proxy. I am hoping this report time and use of delta will reduce battery drain, together with deep sleep.

Part of my code (the battery bit) looks like this:


- platform: adc
    id: source_ttgo
    pin: 35
    internal: true
    attenuation: 11db
    update_interval: 1800s
    accuracy_decimals: 1
    filters:
      - delta: 0.25
      
  - platform: template
    name: "TTGO_battery_level"
    unit_of_measurement: '%'
    accuracy_decimals: 1
    update_interval: 1800s
    filters:
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 100.0 -> 100.0
          - 71.4 -> 0.0
      - delta: 0.25
    lambda: |-
      return ((id(source_ttgo).state) /2.1 * 100.00);

71.4% = 3 volts (pin35 = 1.5v) which should be shutdown for the Lipo, hence the calibration.
I now have to get my head around polynomial calibration for the thermistor.