IoT (Internet of Things) and home automation systems promise to simplify your daily routines by automatically performing repetitive tasks. For example, you can set your coffee maker to turn on at a specific time in the morning so your caffeinated bean juice is hot and ready when you get out of bed. The problem is that those systems mostly only operate on set schedules or in response to explicit commands. To truly automate your routines, your system needs to know what you’re actually doing. That’s why Lewis Barclay developed bed occupancy sensors for Home Assistant.
The purpose of these bed occupancy sensors is to register when you or your sleep partner are all tucked in for the night. You can then use that to trigger one or more actions through your Home Assistant. For example, you can have it turn off all of the lights, arm your security alarm, and turn down the air conditioner as soon as you crawl into bed. Barclay’s code is written to work with Home Assistant, but it may be possible to adapt it to other assistants like Amazon Echo or Google Home.
The key to this setup is in the sensors themselves, which are load cells. Those will output a value that is proportional to the weight applied to them. With the load cells placed under your mattress, you can determine how much weight is on the bed by measuring the values. A Wemos D1 Mini ESP8266 development board is used to monitor the load cells through a simple amplifier. When the value exceeds a programmed limit, it will send a MQTT (Message Queuing Telemetry Transport) message to Home Assistant. You can configure Home Assistant to perform any number of different actions when that message is received. Conversely, you can also have it perform actions when you get out of bed in the morning. Theoretically, you can use the same setup for other areas, such as the sofa in your living room.