Introduction: Clothes Washer/Dryer Monitoring With ESP8266 & Acceleration Sensor

About: We are a group of makers. We work in IoT, IOS app, android app, embedded design, sensor design, raspberry pi, arduino, beaglebone, particle electron, particle photon, Bluetooth.

The clothes washer/dryer is in the basement, and you, as a rule, put a heap of clothing in it and after that, you become occupied in your another house work. You overlook the clothing which was left soggy and absorbing in the basement on your machine. Well then again, once in a while you simply run downstairs expecting that machine has completed the work and afterward you see the machine still running. I know, it is irritating.

Imagine a scenario in which you can watch the status of the clothes washer/dryer on your cellular phone or tablet. Likewise, where you can get a message on your telephone stating that the machine has finished its assignment. Sounds exceptionally fascinating and accommodating, right!

Indeed, with the assistance of ESP8266 and an accelerometer sensor you can monitor the status of your clothes washer/dryer. You can make this venture at your own home in a simple manner if you just follow the instructions and copy the code.

Step 1: Equipment We Need

1. Adafruit Huzzah ESP8266

The initial step was getting an Adafruit Huzzah ESP8266 board. Adafruit Huzzah ESP8266 is a low-cost Wi-Fi chip with full a TCP/IP stack and microcontroller capability.The ESP8266 provides a mature platform for monitoring and control applications using the Arduino Wire Language and the Arduino IDE. The ESP8266 module is an extremely cost effective board with a huge, and ever growing community.

2.Adafruit Huzzah ESP8266 Host Adapter (USB Programmer)

This ESP8266 host adapter was designed specifically for the Adafruit Huzzah version of the ESP8266, providing an I²C interface. The integrated USB port supplies power and programming to the ESP8266.

3. H3LIS331DL Acceleration Sensor

The H3LIS331DL is a low-power high-performance 3-axis linear accelerometer with digital I²C serial interface. It is equipped for measuring accelerations with output data rates from 0.5 Hz to 1 kHz. All these things make this sensor an ideal choice for this project.

4. Connecting Cable

I used the I²C connecting cable available at the above link.

5. Mini USB cable

The mini USB cable Power supply is an ideal choice for powering the Adafruit Huzzah ESP8266.

Step 2: Hardware Connections

In general, the connections are very simple. Follow the instructions and images below, and you should have no difficulties.

Connection of the Adafruit Huzzah ESP8266 and USB Programmer

First of all take the Adafruit Huzzah ESP8266 and place the USB Programmer (with Inward Facing I²C Port) on it. Press the USB Programmer gently into place and we are done with this step. Easy as pie (See the pic #1).

Connection of the Sensor and Adafruit Huzzah ESP8266

Take the sensor and Connect the I²C Cable to it. For proper operation of this cable, please remember I²C Output ALWAYS connects to the I²C Input. The same should be done for the Adafruit Huzzah ESP8266 with the USB Programmer mounted over it (See the pic #2).

With the help of the ESP8266 USB Programmer, it is very easy to program the ESP8266. All you need to do is plug the sensor into the USB Programmer and you are good to go. I prefer to use this adapter because it makes it a lot easier to connect the hardware. Without this plug and play USB Programmer, there is a lot of risk of making a wrong connection. One wrong wire can kill your wifi as well as your sensor.

Note : The brown wire should always follow the Ground (GND) connection between the output of one device and the input of another device.

Powering of the Circuit

Plug in the Mini USB cable into the power jack of Adafruit Huzzah ESP8266. Light it up and voila, we are good to go!

The final assembly will look like in pic #3.

Place the sensor inside Cloths washer/dryer

Before doing this, ensure you cover the sensor totally with plastic so it survives the contact with water. Now, place the sensor and paste it on the drum of the clothes washer/dryer. Do it deliberately without harming the wirework of the washer/dryer and getting yourself hurt.

With this, we are done with all the hardware work.

Step 3: Adafruit Huzzah ESP8266 Arduino Code

The ESP Code for the Adafruit Huzzah ESP8266 and H3LIS331DL Sensor is available on our Github repository.

Before going on to the code, make sure you read the instructions given in the Readme file and setup your Adafruit Huzzah ESP8266 according to it. It will just take a moment to do so.

Note: Before uploading, make sure you enter your SSID network and password in the code.

You can copy the working ESP code for this sensor from here also:

// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works. // Cloth Washer/Dryer Monitoring with ESP8266 // This code is designed to work with the H3LIS331DL_I2CS I2C Mini Module available from //

#include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> #include <Wire.h>

// H3LIS331DL I2C address is 0x18(24) #define Addr 0x18

const char* ssid = "your ssid network"; const char* password = "your password";

ESP8266WebServer server(80);

void handleroot() { unsigned int data[6];

for (int i = 0; i < 6; i++) { // Start I2C Transmission Wire.beginTransmission(Addr); // Select data register Wire.write((40 + i)); // Stop I2C Transmission Wire.endTransmission();

// Request 1 byte of data Wire.requestFrom(Addr, 1); // Read 6 bytes of data // xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb if (Wire.available() == 1) { data[i] =; } } delay(300);

// Convert the data int xAccl = ((data[1] * 256) + data[0]); if (xAccl > 32767) { xAccl -= 65536; } int xAcc = ((100 * 9.8) / 32768) * xAccl;

int yAccl = ((data[3] * 256) + data[2]); if (yAccl > 32767) { yAccl -= 65536; } int yAcc = ((100 * 9.8) / 32768) * yAccl;

int zAccl = ((data[5] * 256) + data[4]); if (zAccl > 32767) { zAccl -= 65536; } int zAcc = ((100 * 9.8) / 32768) * zAccl;

// Output data to serial monitor Serial.print("Acceleration in X-Axis : "); Serial.print(xAcc); Serial.println(" m/s"); Serial.print("Acceleration in Y-Axis : "); Serial.print(yAcc); Serial.println(" m/s"); Serial.print("Acceleration in Z-Axis : "); Serial.print(zAcc); Serial.println(" m/s"); delay(300);

// Output data to Web Server server.sendContent ("<html><head><meta http-equiv='refresh' content='10'</meta>" "<h1 style=text-align:center;font-size:300%;color:blue;font-family:britannic bold;>CONTROL EVERYTHING</h1>" "<h3 style=text-align:center;font-family:courier new;><a href= target=_blank></a></h3><hr>" "<h2 style=text-align:center;font-family:tahoma;><a href= \n" "target=_blank>H3LIS331DL Sensor I2C Mini Module</a></h2>"); server.sendContent ("<h3 style=text-align:center;font-family:tahoma;>Acceleration in X-Axis = " + String(xAcc) + " m/s/s"); server.sendContent ("<h3 style=text-align:center;font-family:tahoma;>Acceleration in Y-Axis = " + String(yAcc) + " m/s/s"); server.sendContent ("<h3 style=text-align:center;font-family:tahoma;>Acceleration in Z-Axis = " + String(zAcc) + " m/s/s");

if (xAcc > 2) { // Output data to serial monitor Serial.println("Cloths Washer/Dryer : Working");

// Output data to Web Server server.sendContent ("<h3 style=text-align:center;font-family:tahoma;> Cloths Washer/Dryer : Working"); } else { // Output data to serial monitor Serial.println("Cloths Washer/Dryer : Completed");

// Output data to Web Server server.sendContent ("<h3 style=text-align:center;font-family:tahoma;> Cloths Washer/Dryer : Completed"); } }

void setup() { // Initialise I2C communication as MASTER Wire.begin(2, 14); // Initialise serial communication, set baud rate = 115200 Serial.begin(115200);

// Connect to WiFi network WiFi.begin(ssid, password);

// Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid);

// Get the IP address of ESP8266 Serial.print("IP address: "); Serial.println(WiFi.localIP());

// Start the server server.on("/", handleroot); server.begin(); Serial.println("HTTP server started");

// Start I2C Transmission Wire.beginTransmission(Addr); // Select control register 1 Wire.write(0x20); // Enable X, Y, Z axis, power on mode, data output rate 50Hz Wire.write(0x27); // Stop I2C Transmission Wire.endTransmission();

// Start I2C Transmission Wire.beginTransmission(Addr); // Select control register 4 Wire.write(0x23); // Set full scale, +/- 100g, continuous update Wire.write(0x00); // Stop I2C Transmission Wire.endTransmission(); delay(300); }

void loop() { server.handleClient(); }

Step 4: Practicality of the Code

Now, download (git pull) or copy the code and open it in the Arduino IDE.

Compile and Upload the code and see the output on your Serial Monitor. After few seconds, it will display all the parameters.

Copy the IP address of ESP8266 from the Serial Monitor and paste it in your web browser. You will see a web page with acceleration reading in 3-axis and status of the Cloth washer/dryer. Before moving on to the final testing, you have to modify the acceleration value according to washer's drum position and sensor placement in the if-else condition in the code.

The output of the sensor on Serial Monitor and Web Server are shown in the picture above.

Step 5: Applications and Upgrading

With the assistance of this project, you can monitor the status of your clothes washer/dryer on your phones and laptops. No need of going over and over and holding up/listening for it to finish the assignment.

You can likewise get a message on your phone expressing that the machine has finished its assignment. With this, you will always remember clothes in the washer. For this, you can simply upgrade this project by adding some part in the code given above.

I hope you like this project and it inspires further experimentation. The Adafruit Huzzah ESP8266 board is incredibly versatile, cheap and accessible to all hobbyists. This is just one of many simple projects which can be constructed using the ESP8266.

Step 6: Resources on Going Further

For more information about H3LIS331DL and ESP8266, check out the links below:

You can also view our additional articles on Home Automation & ESP8266 projects: