Home Automation
Using Home Assistant and ESPHome for helpful projects around the home.
Using Home Assistant and ESPHome for helpful projects around the home.
Notifying the user when the laundry is done - by sensing the power consumption of the appliance.
👕👖
If you enjoy seeing older appliances and devices coming up in the world - I invite you to follow me as I upgrade my 20th century dryer to send me notifications when the laundry is done.
💡
Ok - ready to get technical?
In this example I'm using an ESP8266 in conjunction with a Current Transformer (CT) type power sensor to the back of a dryer to enable remote notification based on whether or not the dryer is running. The end result is a pop-up notification on my phone with a message that will remind me to grab the dry clothes when they're ready.
Here I'm using a relatively high-end sensor I rescued from the electronics recycling but a less expensive sensor would work okay too.
I've got Home Assistant (HA) running on the same network as the sensor unit. I proceeded through the process to add the ESPHome integration to HA.
⚡
The following assumes that the reader has intermediate knowledge and experience with electronics prototyping, soldering, scripting, debugging, and - most importantly - safe practices around electrical equipment.
As with any project there are many ways to achieve the desired result and this is just one of them.
While I hope you may find my writing helpful, I offer no warranty and assume no liability.
I was lucky I had all the necessary materials on hand from previous projects:
Home Assistant running on the local network
Home Assistant companion app running on iOS or Android
Current Transformer Sensor Module
2 conductor cable - 22AWG wire
USB cable
Once I collected all the materials, I then sketched out the assembly first with simplified symbols and lines showing the point to point connections. This can be helpful to avoid common wiring problems and to be able to refer back to for troubleshooting later. I prepared the components and wires and plugged them into the proto-board. I also prepped the wires for the CT but I didn't connect them to the CT just yet.
The output of the CT is a very low-voltage (0-5VDC) analog signal that is sampled by the onboard Analog / Digital Converter (ADC) on the ESP8266.
In order to use receive the ~0-5VDC input from the CT on the A0 pin of the ESP8266, I had to create a voltage divider. This is because the ESP8266 operates on a slightly lower voltage, somewhere in the range of 0-3.3VDC.
Whenever I find a USB that has conductors for power only and no data conductors I label it with something like "No D" or "No Data" to remind me of the fact that this cable is not going to transmit any data. This saves me headaches down the road in case I'm trying to find a USB cable suitable for data.
Setting up my ESP8266 "out of the box", I needed to connect it via a USB cable with data capability to the computer that is running ESPHome.
Once the initial setup is done, subsequent updates to the ESP8266 will be possible over WiFi and at that point, a cable that has conductors for power only would be okay to use.
My dryer has a 3 conductor cable - 2 hot and 1 neutral. In order to function properly, the Current Transformer (CT) sensor needs to be installed on one (and only one) insulated current-carrying wire on the dryer power cable. With the dryer cable disconnected from the wall outlet, I installed the sensor on one of the hot conductors on the cable.
Connect ESP8266 to a solderless breadboard aka proto-board.
Install Home Assistant
Install ESPHome and continue through the steps to set up your the ESP9266.
Run the first time setup wizard in ESPHome by clicking the New Device button.
Once the device is recognized in Home Assistant, add the following code (making substitutions where necessary) to the ESP8266 using ESPHome - this time using the wireless update option.
esphome:
name: laundry1
friendly_name: laundry1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "encryption-key"
ota:
- platform: esphome
password: "ota-password"
wifi:
ssid: "network-id"
password: "network-password"
sensor:
- platform: ct_clamp
sensor: adc_sensor
name: "Measured Current"
update_interval: 10s
# Sample the analog signal
- platform: adc
pin: A0
id: adc_sensor
update_interval: never
Once you've installed and tested the hardware, you'll need to calibrate the signal that is measured by the ESP8266 pin A0.
Open the Logs for the ESP device.
Looking at the logs, you can find the measured value and add the appropriate filters and values to the sensor section of the code.
sensor:
- platform: ct_clamp
sensor: adc_sensor
name: "Measured Current"
update_interval: 10s
filters:
- calibrate_linear:
# Measured value 0 maps to 0A
- 0.000 -> 0
# Measured value 0.003 maps to known load of 23.0A
- 0.003 -> 23.0
We can use the Template functionality in HA to create a sensor with two states - in other words a binary sensor.
I like to split up my configuration.yaml file to keep things organized. Not everyone does it this way - either way works.
Here we create a binary sensor which will be critical for us to trigger notifications upon state changes.
We can also use it to drive conditional logic which will enable us to do more advanced configurations - for instance we can show and hide sections of the dashboard based on whether we're doing laundry. We'll take a closer look at that later.
Now, we'll get push notifications set up in Home Assistant.
Configure the sensor in Home Assistant in the Integrations tab (located in Settings, Devices and Services).
Create an Automation (located in Settings, Automations and Scenes, + Create Automation, Create New Automation) for each sensor using the visual editor.
If everything is working, you should be able to receive notifications in the Home Assistant iOS app any time the dryer finishes a cycle!
In the context of the dryer running - I want to see the state of the dryer. Otherwise I would prefer not to see it. Now we can show and hide sections in the Home Assistant dashboard based on conditionals.
Configure the binary sensor in Home Assistant as a condition in the Visibility tab of a dashboard card.
Going forward, the card will only appear when the dryer is running.
🎉
If all went well, you just added a helpful modern feature to your trusty home appliance - maybe even extended it's useful life!
This project was inspired by the amazing members of the Seattle DIY IoT Meetup - which was a meetup I co-founded in 2018. Shout out to all who helped make that happen!
👏
The vibration sensor detects when the washer or dryer is running and when it's done a notification gets sent to let folks know to get the clothes out of the washer or dryer.