Detect voltage anomalies in household IoT devices  

Use Node-RED and Watson IoT to build an app that detects anomalies in sensor data

Last updated | By Laura Bennett, Bradon Kanyid, Romeo Kienzler


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
  • Hardness of H2O
  • Speed of the motor

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.

Related Blogs

Two “edgy” AI TensorFlow models for you!

The global Call for Code is well underway, we want to share some visual recognition models which could help you. These AI models can operate on the edge, which could be particularly useful for this years’ theme: disaster preparedness. How could visual recognition help in relief work? From satellite and drone imagery analysis, to classifying...

Continue reading Two “edgy” AI TensorFlow models for you!

Leveraging the power of AI at Unite Berlin

Last week, from June 19 – 21, we were at Unity’s premiere in Berlin: Unite 2018. This conference brought together Unity’s video game and development community. Unity touches 770 million gamers all over the world and is the market leader for consumer AR and VR use cases and is also rapidly emerging as the market...

Continue reading Leveraging the power of AI at Unite Berlin

Related Links

IoT architecture

Learn how this Journey fits into the Internet of Things Reference Architecture