Home Automation
Using Home Assistant and ESPHome for helpful projects around the home.
Monitor and report - using a Current Transformer Module
Notifying the user when the laundry is done - by sensing the power consumption of the appliance.
LaundryBot 2.0 - Power Sensing
👕👖
Intro
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.
💡
Inventing smarter appliances
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.
👋 Say hello to our Current Transformer sensor module
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.
⚡
Disclaimer
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.
Materials
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
Step 1: Building the assembly
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.
Step 2: I needed to add a voltage divider
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.
Step 3: Installing ESPHome on ESP8266
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.
⚠ Please stop before touching line voltage cables!
Your safety is your responsibility. Clip-on current sensors are non-invasive and should not have direct (metallic) contact with the AC mains. However, installing the sensors will require working in close proximity to cables carrying high voltage. Before working around line voltage cables - ensure the cables are fully isolated, i.e. power is switched off and cables are unplugged prior to installing sensors, and proceeding slowly and with care.
⚠ If you have any doubts, seek professional assistance.
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.
Step 4: Set up the ESP8266 with ESPHome
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
Step 5: Create a Binary Sensor Template
We can use the Template functionality in HA to create a sensor with two states - in other words a binary sensor.
Add templates.yaml to configuration file
I like to split up my configuration.yaml file to keep things organized. Not everyone does it this way - either way works.
Create a templates.yaml file and add the binary sensor
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.
Step 6: Set up push notifications
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.
Laundry ready!
If everything is working, you should be able to receive notifications in the Home Assistant iOS app any time the dryer finishes a cycle!
Step 7: Bonus feature - conditional view in Home Assistant
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.
🎉
You made that old appliance more modern!
If all went well, you just added a helpful modern feature to your trusty home appliance - maybe even extended it's useful life!
Acknowledgement
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!
👏
You are amazing!
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.