Digital Developer Conference on Data and AI: Essential data science, machine learning, and AI skills and certification Register for free

Archived | Detect voltage anomalies in household IoT devices

Archived content

Archive date: 2019-05-21

This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.


Experts predict there will be over 20 billion IoT devices in the world by 2020, with a large percentage of those devices being located in our own homes. This developer journey will give you a head start on developing connected devices in the home. Using Node-RED and Watson IoT APIs, you’ll learn how to build a cognitive IoT application that detects irregularities in the voltage of your connected household devices.


The Internet of Things is now a reality, and according to a quick Google search, experts are predicting that at least 20 billion devices will be connected by 2020. Regardless of the type of development you do, whether enterprise systems or mobile games, you’ll be required to know how to connect a device — any device — to the wider IoT ecosystem.

Beyond adding to the sheer number of connected devices, IoT developers will also require an understanding of cognitive computing. Can your app take the inputs it’s given and learn from that data?

So, where do you start? Right here. This code pattern takes you through the process of building a cognitive IoT application. Your app will learn at the edge of your network; that is, you’ll push computing away from a cloud or data center towards the sensors that are receiving the input. Computations happen at the gateway, close to the sensors and actors (and they can take place even closer to the edge, on a microcontroller between the gateway and the sensors and actors).

In this code pattern, you’ll use the cloud to detect anomalies in a device familiar to everyone, your washing machine. Now, you might think it’s not that exciting to monitor your washing machine, but imagine what happens when you wash in hot water by mistake. There’ll be some excitement when your red towels turn your whole wardrobe pink. Or worse, what if the washer is running too fast? You certainly will get agitated if you have to replace a burned-out motor. And you’ll also be a little bit poorer.

Let’s assume that you have a washing machine with three sensors:

  • Fluid temperature
  • Water hardness
  • Motor speed

You can easily build an app that communicates with those sensors. When a sensor picks up instability, your app sends a command to deactivate. Additionally, you’ll be able to save and store data to perform batch analytics overnight. A machine-learning algorithm on the edge gateway can optimize the results and proactively notice, for example, the temperature is rising at a rapid rate. You can then deactivate the machine and send a service notification before a major catastrophe occurs.

You can see where this is going. Any developer who can write code that will save homeowners real money will be in demand. Complete this code pattern, learn to create valuable cognitive IoT applications, and keep your skills — and laundry — fresh.



  1. The three washing machine sensors are: 1) fluid temperature 2) water hardness 3) motor speed.
  2. The Node-RED Edge device simulator simulates device data; in this case that is the simulated Raspberry Pi. The Raspberry Pi is attached to the washing machine, with data continually flowing from the sensors to the Raspberry Pi. The simulated Raspberry Pi (that is, the Node-RED Edge device) is connected to the Internet by ethernet and is streaming data to the Watson IoT Platform.
  3. The Watson IoT Platform uses the MQTT Message broker and acts as asynchronous glue between all components in the IoT operational model. It publishes data back to the Node-RED Edge device (in a real world case, if it detects an anomaly, it would send a message back to the machine to deactivate its motor). Watson IoT Platform also streams data to the Node-RED cloud, which subsequently sends it to storage.
  4. The Node-RED Cloud subscribes to the data coming from the Watson IoT Platform. It’s used for streaming IoT sensor data to cloud storage (Cloudant) so that batch analytics can be performed later.
  5. The Edge Model is composed of a real-time anomaly detection algorithm called moving z-score which detects abnormal behavior patterns on sensor time-series.
  6. The Cloudant repository is used for batch analytics processing to identify trends.


Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.