121
make.co
The ESP8266 microcontroller is great for HA
projects as it is low cost, includes Wi-Fi, and is
supported by the Arduino IDE. The Arduino MQTT
library works well with the Home Assistant MQTT
server using a publish/subscribe model: the
Arduino client publishes wet/dry MQTT events
which are discovered by the MQTT server. This
creates an entity in Home Assistant which can be
used as a trigger in automations.
There are several water valve shutoff products
that integrate with Home Assistant. I used a
Z-Wave valve thats wirelessly paired with a
Z-Wave USB interface on my Home Assistant
Raspberry Pi.
The automation is:
Trigger: Leak detector entity changes to the
“wet” state.
Actions: Turn off water valve, send a text
message and email, turn on a piezo alarm
connected to the Raspberry Pi GPIO.
HUMANE MOUSETRAP WITH TASMOTA
Small furry uninvited houseguests often meet
their fate with lethal mousetraps, but they’re just
trying to live, right? A humane mousetrap is the
better approach for some, but if you don’t notice
that the mouse has checked in, the poor critter
might really suffer.
So, time to build a better mousetrap. I bought
a humane mousetrap and added a magnet and
a reed switch connected to an ESP8266. I chose
Tasmota open source firmware for the ESP
(tasmota.github.io), in conjunction with the Home
Assistant Tasmota integration. A web server on
the microcontroller, programmed in Arduino,
enables configuration such as selecting Wi-Fi
SSID and password, device name, and configuring
the IO pins. In this project, the mousetrap
detector appears as abinary sensor to Home
Assistant, with on/off states (Figure
E
).
Trigger: The door of the mousetrap is tripped.
Action: Send a text message, and tell Amazon
Alexa devices to announce “There’s a mouse in
the mousetrap.” I soon learned that this mouse
event is most likely to occur in the middle of the
night and wake everyone up. Not cool!
Condition: So, a simple change to the
automation delayed the announcement until
after our morning wake-up time.
SUMP PUMP ALERT
Like many homes, mine has a sump pump that
doesn’t run often — but if its running for more
than a few minutes, that’s a big concern.
Sump pump pits are not a great environment
for electronics. Worse, mine is outside, below
grade near a door to the walk-out basement. Not
great for radio communications, either.
My solution was to monitor the AC current in
the electrical panel for the sump pump circuit
(like I did the laundry machines at MIT). There
are products available to monitor AC circuits with
clamp-on transformers, but its easy to make one
at a low cost. How does this work? A wire carrying
an electrical current creates a magnetic field in
proportion to the current. A coil of wire wrapped
around the hot wire connected to a circuit breaker
can measure this current. I used a SCT013 split
core current transformer (Figure
F
), readily
available via Amazon, eBay, and other electronics
vendors.
I put together a circuit to adapt the transformer
output current to a voltage in the sensing range of
the ESP8266 microcontroller input pin. A Schottky
diode protects the input from the voltage spikes
produced when the sump pump motor turns on
or off. An Arduino sketch reads the voltage and
informs Home Assistant.
E
F
M85_118-23_SB_HomeAuto_F1.indd 121M85_118-23_SB_HomeAuto_F1.indd 121 4/9/23 1:18 PM4/9/23 1:18 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset