DIY Lux Sensor with BH1750 (Battery)

I would, like I said, it doesn’t have to be a wemos d1 mini. I can go Zigbee , RF or Wifi … but I don’t know how to do it. I don’t know how to build a Zigbee sensor. Thats my main problem.

I want to use the lux sensor for my cover automations. If the sun shines directly into my living room I want the cover go down. Thats why 30mins is to much…

The idea with the solar panel is good! Do you have a example of your wemos? Or some pictures how you created your sensor?

Luck. I build this today .
Board is WeMos D1 ESP-Wroom-02
Firmware is latest Tasmota + Deep Sleep
Deep Sleep is set to 300 sec
Pics:

3 Likes

Wow … that’s really called luck :D…

What to you think, how long will this work with battery? Could you maybe tell me also how you installed tasiota with deep sleep? Like I said, im totally new and willing to learn this :slight_smile:

When I tested board Wemos D1 mini + 18650 battery shield + BME280 sensor + ESPEasy with Deep Sleep (30 min sleep /10 sec awake) as outdoor temperature sensor battery lief was more than two months.

I’m guessing you measured that with a multimeter. Which is not fast enough to capture the real current. Using a current shunt and an oscilloscope I measured 250mA to 750mA when awake. Others have found similar results. My assumption of 500mA average is valid for a ballpark figure.

I guess it depends on the use case. But for my system I use a (wall powered) BH1750 sensor reporting every 3 minutes and it does a reasonable job of making my indoor lights react to sunrise / sunset and even passing squalls in the afternoon.

I use 5W 5V panels and two 18650 cells for my gate and shed door sensors. They are barely sufficient to make it through the winter. And these sensors only report in a couple of times a day on average. Mind you I live at 42°S.

What it comes down to is that for a regularly reporting sensor wifi on battery is not the way to go.

Using my calculations from above I get 65 days for a 10s wake every 30 minutes. So that’s a good confirmation of my wake current estimation.

I have found I need to wake for longer than 10s to get a reliable mqtt connection from the edge of my wifi range though (more like 45s).

Just FYI, the wemos D1 mini is not the best choice for battery use, simply because they use ME6211 regulators with Iq = 40uA (that’s the spec anyways, clones likely come with even worse ldo’s). Since that quiescent current burns 24/7, even during deepsleep, you can get a lot longer battery life using an esp12 module with a decent LDO with lower Iq (like ADP160AU @0.56uA, or similar). I know, it’s a lot more tedious soldering work, but it is usually worth it if it saves having to charge as often. For perspective, I have an 18650 powered esp node that wakes every 10min and warms up a DHT sensor for 30sec before it starts up the wifi radio and updates ha. This node lasts 3 months on average… in practice over several years (not just a calc). I appreciate your progress, and I don’t mention this to diminish your project by any means… just that I know there can sometimes be disappointment involved if you don’t account for Iq in a battery powered design before building it out. :wink:

[edit: On a closely related note, if you’re building battery powered stuff, you should really make a micro amp meter for testing and validation. Here’s the one I built myself… there’s a case for it too if you have a 3d printer:


]

It’s not the sleep current that makes this non-viable. 40uA running 24 hours is less than 1mAh. Which is basically zero compared to the 600mAh required by the wake state per day.

Hmm… that’s doesnt look good for my project. Seems like I have no other choice than a wired sensor.

I don’t know how other sensors work. There are Wifi Battery cameras on the market, that work like 2-3 months with one charge …

How can just a esp8266 with a lux sensor drain so much energy?

Maybe you can tell us results of your built sensor?
what is the current energy consumption with this setting?

Sorry ,I don’t have hardware for serious monitoring energy consumption.

i don’t mean values… just a approx life time of one battery charge :slight_smile: … its running since 2 days for you now :smiley:

omg budy , ask mi after two months :wink:

Im again here… I received my board and got everything working. But how do you use Deep Sleep? Do you have the shematic of the board and can share it please? I didn’t find anything about GPIO16. Also, how are you using SCL and SDA with D1 and D2? I don’t know wich GPIOs are that…

I know this is a really old post, (forgive the bump) but your use case is exactly what I want to achieve (HA reacting to interior light levels, regardless of time of day). Wall powered is great. Can you provide any details on your build of these sensors? Thanks in advance!

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.