The weather is getting worse, it’s dark out, and the wife is in Berlin for advanced education - time for some home projects.
I’ve been working on making our home smarter for quite a while and the most recent addition were IKEA TRÅDFRI lights in almost every room. One of their best features is the integration with inexpensive infrared motion detection sensors. I’ve been using this for example in our hallway where we generally don’t need light except when someone walks through. The sensors have one big disadvantage, though: They can (currently) only trigger activation and deactivation of certain IKEA lightbulbs but they cannot report the current measurements to the smart home platform.
This would be useful to turn on other (non-TRÅDFRI) lights or to only act during certain times of the day (e.g. don’t turn on lights in the middle of the night when someone walks to the bathroom).
Therefore, I thought I’d replace the sensors with self-built ones based on the ESP8266 boards that I’ve accumulated. Additionally, I can then add additional sensors besides motion. The units frequently perform measurements, connect to WiFi and deliver the measurements to the MQTT broker. From there, Home Assistant collects them and tells the TRÅDFRI gateway to turn on the lights.
Here is an early protoype with a HTU21D temperature and humidity sensor and a HC-SR501 infrared motion sensor:
I’ve build three of them for all rooms and added an IR LED to the one in the livingroom to be able to turn on and off the TV. Then, I put everything in the cases and I thought I was done…
…Until one night when I woke up to bright light at 3 a.m. It turned out that the motion sensors started detecting motion every few minutes even though there clearly wasn’t any. After wasting half a day changing the sensitivity, masking the sensor, and reading up on issues with PIR sensors, I found the problem: It turns out that the BISS0001, that does the motion sensoring, is very sensitive to RF. I had moved it too close to the ESP8266 and whenever the controller connects to the WiFi, it causes a false detection and then turn on the light.
I was able to fix this by moving it a little further away and covering the sensor with some tin foil:
Here is the final result in the livingroom configuration with a PIR and the IR LED to control the TV:
With the current configuration, I haven’t used a light switch in quite a while and individual rooms turn on and off based on human presence in them.
I’ve uploaded the code and additional information on GitHub.