Washing-Machine Learning with Bolt IoT

Mayank Joneja
Bolt IoT
Published in
4 min readNov 6, 2017

Because “Anomaly Detection for a Vibration Sensor using the Bolt IoT platform and Boltduino with Z-score Analysis on Node-RED for early detection of motor failure on a washing machine” was too long for a title (even-though more accurate).

In the previous two posts, I covered the basics of using Node-RED for an interactive Jack-O’-Lantern as well as the link between the Internet of Things (IoT) and Machine Learning (ML).

This post is about a project building up on those articles for one of the use cases discussed previously, i.e. Anomaly Detection based on the really nice introduction by Romeo Kienzler, Chief Data Scientist at IBM.

Node-RED flow for Z-score calculation and Alert

Z-Score

Analysis based on Z-score, also called Standard Score, is one of the basic statistical approaches for identifying outliers in a data-set assuming a parametric distribution, mostly a Normal/Gaussian distribution with known mean and standard deviation. The Z-score is given by:

z = (x-mean)/(standard deviation)

Wherein x is the new reading we wish to test, the mean and standard deviation are calculated from the existing data samples. A positive z-score indicates that the new reading is greater than the mean, while a negative one implies that x is less than the mean.

Comparing the z-score to a certain threshold can help categorize the new value as anomalous, i.e. atypical or instead, typical.

Z-score is a common metric used for small data-sets with less features. Ideally, data should be prepared such that it conforms to a normal distribution, but the purpose of this project is to give a basic and intuitive hands-on project which highlights the strength of this approach.

Bolt bolted onto a Boltduino with the vibration sensor

In case you skipped over the long “sub-title”, the application used for framing here is: Using a vibration sensor on your washing machine to identify if it is working fine or has it started to vibrate in an anomalous fashion. This could help catch a failing part such as the belt or the motor inside much earlier than without the use of Bolt IoT or Z-Score analysis.

Setup

The code for this project can be found on GitHub which contains a TL;DR set of instructions and pre-requisites along with the Node-RED flow and Arduino sketch which can be flashed onto an Arduino Uno (or others) or even the Boltduino. :) You can also check out the setup in this video:

The detailed steps are as follows:

0. Connect the hardware as shown in the video.

  1. Get the repository
git clone https://github.com/Inventrom/bolt-vibration-anomaly.git

2. Open the Arduino sketch

vibration_bolt.ino

3. Compile the sketch by clicking on the ‘verify’ button and flash it onto your Boltduino/Arduino Board by clicking on the ‘upload’ button.
Note: Make sure to select the correct port and board under the “Tools” menu

4. Follow the Node-RED guide linked above and launch your flow editor (by default on http://localhost:1880).
Note: Of the methods mentioned in the guide I have used Docker to setup my local Node-RED environment.

5. Copy and paste the Node-RED blocks in the file “vibration_flow.json” in the repository you cloned into your Node-RED editor.

6. Log in to the Bolt IoT Cloud and copy your API Key and replace the placeholder text in the “set_params” block in the flow.

7. Also, replace the Bolt Device ID in the “set_params” block with the one you setup by following the Getting Started guide for your Bolt IoT hardware.

8. *almost there..* Link your email ID in the ‘userid’ and ‘password’ fields in the “email_alert” block and also fill the ‘To’ field in that block with the email address you wish to send alerts to.

9. Time for the Big Red Button…..no not the Done button, the one in the top-right corner that says: DEPLOY

10. Keep an eye on the console where you launched node-RED from, (attach to the container if using Docker), create “anomalies” and get alerts!!

Final Note: The terminal session will give a constant read-out of the sensor values if all the above steps are followed accurately.

An easy way to test the sensor before sticking it to the washing machine and kicking it is to just stick the vibration sensor on a flat surface like your table with foam tape. Then, KNOCK hard on the table right beside the sensor. You should see a message in your Node-RED debug console and also in your terminal session. The default windows size chosen is 30 samples and the threshold for anomaly detection is set to 0.5 but you could play around to see how the behavior changes.

Hope you enjoyed these past few posts about using ML with the Bolt IoT platform, feel free to ask questions in comments. ^_^

P.S.: No real insects were harmed in the testing of this project ;)

Anomaly Detector Testbench for Vibration Sensor (mounted on a Hexbug Nano)

— — —

Bolt is now live on Kickstarter! Here is the link to know more crowdfunding.boltiot.com. BACK US! and spread the word! :)

To know more about Bolt IoT platform, check out our website. To know what other interesting projects can be built on Bolt you can check out the Docs section on Bolt Cloud.

--

--