Smartify Your Laundry Machine On The Cheap

My family and I live in an apartment building and the laundry machine and the tumble dryer are in the basement. In the past, it happened many times that I went down to take out the laundry just to realize that the machine was still running. What a waste of time and energy! Engineers to the rescue!

Years ago I had already built a solution for this problem: it measured the energy consumption of the two appliances and sent notifications when the working cycle was completed. This project here does exactly the same, but it is much easier to implement and uses mostly off-the-shelf components.

The following project is doing the same, it’s just much easier and cheaper to implement.

At the core of this IoT application are two Sonoff POWs. You might know the regular ESP8266 based Sonoff which can switch mains current over WiFi up to 10A. The Sonoff POW can also switch currents but also measures the consumed current and transmits the information over WiFi. And that is exactly what we are interested in here.

Another important component in my setup is the Raspberry Pi 3 which runs IBM’s Node-Red. This application allows you to receive, process, transform and forward data from your IoT devices. In most cases, no programming is required and the flows can be configured in a graphical editor in your web browser. This setup is very versatile and there are many Node-Red plugins you can use to extend the system even farther.

In addition to Node-Red, you’ll also need to have an MQTT server running on your Raspberry Pi. I’m using this docker-compose project to run both servers on my Raspberry Pi. Docker makes it really easy to run these applications and I can only recommend to use this or a similar setup.

Using the Sonoff-Tasmota Firmware

While you could probably also use Sonoff’s stock firmware I recommend flashing the great Sonoff-Tasmota firmware by Theo Arends. This firmware is open-source and you have much more control over what is running in your house. If there was a back-door in the firmware it would have to be hidden in plain sight, since you can check (and change) every line of the source code yourself.

This wiki page explains how to flash Sonoff-Tasmote to the Sonoff POW. Just make sure that the Sonoff is disconnected from mains power when you are flashing the device!

After flashing the Tasmota firmware you have to connect the device to your WiFi network and to send data to your MQTT server. If you plan to use more IoT devices sending data to MQTT topic better think of a clever naming scheme for your MQTT topics or you will get into trouble real quick. Keep that naming pattern also when naming the device for the WiFi network.

Wiring the Sonoff POW

My laundry machine and the tumble dryer are connected to mains power with a regular 220V wall plug. I used extension wires to put the Sonoff-Pow between the machines and the wall plugs. Just make sure that you use the right lines. In Switzerland the 0-phase (or neutral phase, symbol N) is normally blue.

The Node-Red Flow For Sonoff POW

Node-Red flow for the Laundry Machine

This is my whole flow on Node-Red to process the information sent by the Sonoff-Tasmota firmware. The complete object looks like this:

{
   "Time":"2019-02-09T12:54:09",
   "ENERGY":{
      "TotalStartTime":"2019-0209T12:06:56",
      "Total":0.011,
      "Yesterday":0.000,
      "Today":0.011,
      "Period":0,
      "Power":0,
      "ApparentPower":0,
      "ReactivePower":0,
      "Factor":0.00,
      "Voltage":229,
      "Current":0.000
   }
}

MQTT Node

The MQTT node subscribes to the topic tele/laundry-machine/SENSOR of the local MQTT server. Make sure that you configure the Sonoff Pow to publish to the same topic. In the Tasmota Wiki you can find more about it.

JSON Node

The json node converts the plain text received over MQTT into a parsed JSON (javascript object notation) object. In the output you know longer just have text that looks like json, you actually have a json object.

JavaScript Node

In the JavaScript node we can add our own code. In our case we turn one input (the json object) into three outputs, one for power, one for current and one for voltage.

var out = [];
out[0] = {};
out[1] = {};
out[2] = {};

out[0].payload = msg.payload.ENERGY.Power;
out[1].payload = msg.payload.ENERGY.Current;
out[2].payload = msg.payload.ENERGY.Voltage;
return out;

The Chart Nodes

The chart nodes visualize the input in a graphical way, either the current value (the gauge node) or the current plus historical values (chart nodes). Here is a sample:

Gauge indicating current consumption
Charts for showing historical consumption

The Hysteresis Node

Since I want to get a push notification when the machine starts and when it ends we need to filter all data somehow. Only when specific events occur we want this filter to let the message pass. I used the hysteresis node here since it contains somehow a state machine: only when input passes upper limit (1000 Watts) or falls below a lower limit (500 Wats) the message will be let through.

Settings for the Hysteresis Node

The Throttle Node

The throttle node is a safety net in case the hysteresis filter doesn’t work properly. We don’t want to be flooded by push notifications, right? So the throttle node

The Pushbullet Node

Pushbullet is a convenient service which lets you push notifications to your smartphone without having to implement your own native iOS or Android app. They have an easy-to-use API which can also be used from the command line.

There is a plugin for Node-Red which lets you send and receive messages from Pushbullet. Just set up an account, optionally install the Pushbullet app on your smartphone. Then add the API credentials to your Node-Red/ Pushbullet configuration.

Shopping List

DescriptionPriceLink
Sonoff POWUSD $9-15Banggood
Gearbest
Aliexpress
Raspberry Pi 3+~USD $40-50Banggood
Gearbest
Aliexpress

Outlook

Using the Sonoff POW for energy consumption is just one of many projects you can easily add to your smart home. The Raspberry Pi with Node-Red as a central control tool is a good investment in future projects.

Did you like this post? Consider supporting me with a virtual coffee or beer.

Posted by squix78

One comment

  1. Timely project, for me. I just purchased a pair of Teckin smart plugs with energy monitoring and re-flashed them using tuya-convert. One is monitoring the dryer and the other is monitoring the washing machine. I ended up setting the hysteresis thresholds at 10 (upper) and 5 (lower), and that seems to be working well for both units. I haven’t implemented Pushbullet yet; I send the hysteresis output to an MQTT publish node, which I then subscribe to via MQTT Dash on my Android phones and tablets.
    Thanks for a great idea and project!

Leave a Reply