Hi!
Wanted to share my very very cheap and dirty (no pun intended!) way to turn on the heat lamp above my baby’s changing table when we lay her down for a nappy change. The basic elements are as follows:
- Soft changing mat on changing table (like this one: https://www.mothercare.com/changemats/on-the-road-changing-mat/455777.html)
- Home made (<50 cents) capacitive pressure sensitive pad
- ESP32 running ESPHome (https://esphome.io/index.html)
- Standard heat lamp (like this one: https://www.reer.de/en/easyheat-flex-changing-table-heater.html)
- Shelly plug S Wi-Fi plug (https://shelly.cloud/shelly-plug-s/)
The key is the home made capacitive pressure pad sensor which is heavily based on the instructions here: https://blog.yavilevich.com/2017/10/40-cent-diy-pressure-sensor-based-on-a-capacitive-principle/. Basically if you follow the building instructions on that page, you’ll end up with a home made pad from just tin foil and office supplies that will change its capacitance based on pressure on the mat (check it with a multimeter to be sure). I’d recommend soldering the wires to the paperclips because they slide out easily. Then you can put it under the baby changing matt - like this (apologies for picture quality):
Connect one wire from the pad to the Ground pin of an ESP32 and the other to one of the ESP32’s capacitive sensing pins (GPIO 4, GPIO 0, GPIO 2, GPIO 15, GPIO 13, GPIO 12, GPIO 14, GPIO 27, GPIO 33, GPIO 32) - I used GPIO 4. From here you can load an ESPHome image onto the ESP 32, I used the following code (see the comments for parameters that I changed):
# Setup the ESP32 board
esphome:
name: changing_matt_esp32
platform: ESP32
board: esp32doit-devkit-v1
board_flash_mode: dio
# Setup the Wi-Fi connection
wifi:
ssid: <Wi-Fi SSID>
password: <Wi-Fi Password>
# Enable the Home Assistant API as the communications method
api:
# Enable logging
logger:
# Enable OTA updates
ota:
#Setup the touch platform
esp32_touch:
# Set this to True when you first setup the sensor - then in the ESPHome log you'll see the actual measured value being constantly output. This lets you find what the threshold is for occupied/not occupied
setup_mode: False
# Set the low voltage as high as it will go and the high as low as it will go - the smaller range improves the sensitivity so the matt makes noticeable changes
low_voltage_reference: 0.8V
high_voltage_reference: 2.4V
# Set the maximum voltage attenuation to help provide a better signal
voltage_attenuation: 1.5V
# Setup a sensor to monitor the changing matt pressure pad on GPIO 04
binary_sensor:
- platform: esp32_touch
name: "Changing Matt Occupied"
pin: GPIO4
# This threshold should be set individually, see the note on "setup_mode" above
threshold: 250
When you first connect this you should set setup_mode
to True to get messages in the logs about the value being measured. Once you’ve done this put the pad under the changing mat and load the ESPHome logs to check what the “unoccupied” value is. Then lay something roughly baby-weight on the mat and see what the value changes to. You can then edit the ESPHome YAML to put setup_mode
back to False and set threshold
to be between the “occupied” and “unoccupied” values.
With that done - you can add the ESPHome device in Integrations in Home Assistant and you’ll have a new binary sensor telling you if the changing matt is occupied or not! Bonus points for customising the entity with the baby-face-outline
MDI icon
That’s really the hard part complete - all that remained was to add an automation that turned on the heat lamp using the Shelly Plug S. I’m using this HACS component to have all my Shelly devices in HA: https://github.com/StyraHem/ShellyForHASS so I already have a switch for the heat lamp in HA. Then just add the automation using automations or Node Red and you have an auto-heat lamp for the changing mat!