Building a Light Level Sensor for Home Assistant – Part 1

(This turned from a light sensor into a light/temperature/humidity/pressure multi-sensor in Part 2. By Part 3 it might be sentient.)

I’ve been mucking about with Home Assistant for several months now after buying wifi lights (and shamefully haven’t been blogging about it). Home Assistant is a hugely configurable, Python-based home automation server. I recommend checking it out.

The first thing I set up is automation of our main lights. They turn off when we go out, and turn on when we arrive home. This works fine, but I’d also like the lights to turn off when not required during the day. Home Assistant natively knows about sunrise & sunset, so the obvious thing is to turn the lights off maybe 45 minutes after sunrise. This is fine on sunny days, but on rainy day the lights end up turning off while it’s still quite dim inside.

There are options to solve this with sensors, but they’re pretty expensive off-the-shelf, especially if you factor in an often-required z-wave controller. Fortunately, Mal introduced me to the wonderful world of ESP8266: incredibly cheap Arduino-compatible boards with built in WiFi.

Hacked together luminance sensor

A quick check on Aliexpress turned up a TLS2561 digital luminance sensor for the princely sum of $1 (or $5 for 5). Throw in a tiny battery or power supply and it’s easy to build a WiFi-connected IoT thingy for well under ten bucks!

I’m still waiting on the ESP8266 board, but in about 30 minutes I’ve thrown together a proof of concept using an ancient Arduino Duemilanove. I’m using a little SSD1306 OLED screen for output. These things are outrageously expensive at four bucks!