Connecting DIY sensors to Home Assistant
Since Home Assistant (HASS) runs on raspberry Pi, I can easily extend it using my cheap home built sensors.
Temperature Sensor:
The first sensor I attached was a temperature. My thermostat is outside the room and if the door is closed, the difference between the room and outside can be as high as 4°F. The sensor I used is DS18b20 (it has high accuracy — 0.5° and is quite cheap <$0.5) and HASS supports it out of the box using one wire plugin. The schematic is:
You need to add “dtoverlay=w1-gpio” to “/boot/config.txt” and reboot the device. Execute the following commands:
sudo modprobe w1-gpio
sudo modprobe w1-therm
ls /sys/bus/w1/devices
You will see the 28-xxxx which is the ID of the device and you can now add the following to the HASS configuration.
sensor:
- platform: onewire
names:
28-xxxx: Bedroom
Motion Sensor:
The next step was connecting motion sensor which I can use to track when the room is empty. PIR Sensor (HC-SR501) is one of the most fascinating pieces of technology. It uses a fresnel lens to focus the IR on the sensor, can detect movement 7m away and cost <$1! The schematic is:
Note that you can directly connect the Data Out of PIR Sensor to GPIO of raspberry pi but I added a LED and 220Ω resistor so I can easily test the range of the sensor. You also need to add the following to the HASS config:
binary_sensor:
- platform: rpi_gpio
pull_mode: DOWN
ports:
19: Bedroom Motion
I now have complete history of motion in the room :).
Changes:
- Add motion and temperature sensor to the room
- Expense: ~$1.5