IoT Based Laundry Notification System

Hi

This instructable gives step by step introduction on how to build an IoT based laundry notification system.

The device is attached in your drawers and laundry bag. For the sake of demo here, we have taken two drawers and one laundry bag. It senses how empty/full the drawers/laundry bag are and notifies the user saying laundry needs to be done. It uses an ultrasonic sensor which basically measure the empty space in the bins. The sensor is connected to an ESP which in turn is connected to a cloud service. The cloud service is connected to IFTTT which uses applets to send notifications to the user via email, sms, google calendar event. The cloud comes with a dahboard on which the status of all the bins can be seen. When the cloud sees that you are running out of clean clothes, it instructs the applets to notify you. Besides this, the applet instructs the cloud to check for the data on a regular basis every day. It can be once everyday, or hourly, depending upon how the user wants it to be. Details instructions to build this system is described below.

Step 1: Gathering the Material You Need.

you are going to need:

1. 3 ultrasonic sensors HC SR04(5V)

2. 3 ESP8266 12(5V)

3. 3 9V batteries

4. 3 5V potentiometers(to power the ESPs and sensors)

5. A bunch of female to female and male to female connectors

6. Battery case

You can buy these things on amazon easily. The sensors and ESPs are really cheap if you buy pack with 6 of them in it.

Step 2: System Architecture

The architecture of the system can be understood from the picture. The sensors are connected to ESPs. ESP sends the data (the distance) to Adafruit which is then processed to see how full the containers are. Depending on which drawer is how empty and how full is the laundry bag, the user will receive notification saying and need to do laundry tomorrow. IFTTT is triggered from Adafruit and take the action whether to send an Email through Gmai, Create an event in calender or send notification through IFTTT app. This device comes with a dashboard which can be opened in any browser. The dashboard is connected to the hardware using Adafruit environment which shows readings from the sensors. Moreover, it is possible, from this level, to turn the ESPs on and off from the dashboard.

Step 3: Configuring Your ESP

You can easily operate your ESP by connecting it to Arduino IDE. All you need is to download and configure the libraries for it. You can follow the steps below:

1. Download the latest version of Arduino IDE.

2. Open your IDE, go to files < preferences and copy the below link in the Additional boards Manager and click OK to close the preferences tab.

http://arduino.esp8266.com/stable/package_esp8266...

3. Go to Tools < Board Manager < and search for ESP8266 and install version 2.4.1. You can install other versions depending on the volume of your IDE. But his works best.

After all this, chose board NodeMCU 1.0. Now you are ready to use your ESP just like an Arduino(or even better).

4. Once you are done connecting and working your ESP with the laptop like an Arduino, go to the next level and connect with either your WiFi or your mobile hotspot.

Step 4: Connecting Your Hardware: Sensor to ESP.

Here's how you need to connect your sensor and code it so that it gives you the empty space in the bins.

1. The sensor Vcc is connected to the NodeMCU VUpin. If you connect it to 3.3V, your sensor will not work, since its operating voltage is 5V.

2. The sensor GND is connected to the NodeMCU GND.

3. The sensor Trigger Pin is connected to the NodeMCU Digital I/O D4.

4. The sensor Echo Pin is connected to the NodeMCU Digital I/O D3.

After this you can write the below code to see if your ultrasonic is working. After you have established that you sensors, code and ESPs are working fine, you can connect your ESP to WiFi and check if its working. But doing this, the hardware connections will change a little as detailed below. But before that make sure you connect your 9V batteries to POTs and they have been adjusted for 5V output voltage. You dont wanna burn your ESPs(they smell bad).

1. The ESP Vin and sensor Vcc is connected to the positive of battery.

2. The ESP GND and sensor GND is connected to the negative of battery. Remember to make the ground common or else your sensor will give random data.

3. The sensor Trigger Pin is connected to the NodeMCU Digital I/O D4.

4. The sensor Echo Pin is connected to the NodeMCU Digital I/O D3.

Hers's a little about how the ultrasonic sensor works and how is it coded.

The sensor basically sends out a pulse and times it till it reflects and reaches back to the sensor. Based on the time and the speed of sound, we have to formulate the distance. This is essentially what we have done here. The sensor itself simply holds it's "ECHO" pin HIGH for a duration of time corresponding to the time it took to receive the reflection (echo) from a wave it sent. The module sends out a burst of sound waves, at the same time it applies voltage to the echo pin. The module receives the reflection back from the sound waves and removes voltage from the echo pin. On the base of the distance a pulse is generated in the ultrasonic sensor to send the data to the ESP. The starting pulse is about 10us and the PWM signal will be 150 us-25us on the base of the distance. If no obstacle is there, then a 38us pulse is generated for ESP to confirm that there are not objects detected.

D = 1/2 × T × C; D is the distance, T is the time between the Emission and Reception, and C is the sonic speed, the value is multiplied by 1/2 because T is the time for go-and-return distance.

Connect these together as in the above figure and place it in the inside of your bins on the top.

Step 5: Connecting ESP8266 With Adafruit IO: Creating Adafruit IO Account

To connect ultrasonic sensor and ESP8266 to the cloud Adafruit IO service (using MQTT protocol) was choosen.

MQTT is a simple and extremely light-weigh protocol, which allows devices to publish data (from the device to the server) and subscribe data (collect data from the server). Ease of this solution is supplied by MQTT broker, which in this case is Adafruit.IO. Through it devices are able to send and receive messages.

To register enter the website: https://io.adafruit.com/ and click Get Started for Free. At the next site user should put personal details and click button Create Account. After registration user is moved to the Home section of an account. For further writting a code for ultrasonic sensors important is to check AIO Key (button View AIO Key) for both: Username and Active key.

Now we are ready to create Feeds (which hold sensors data values) and Dashboard, on which it will be possibe to monitor a laundry system.

Step 6: Connecting ESP8266 With Adafruit IO: Creating Feeds

For this project 6 different feeds were used:

  • ON/OFF feeds- feeds which activate/deactivate ESP8266 to get measurements. Added because of energy management. (Feed: Drawer-1-Onoff, Drawer-2-On-off, Laundry-bag-On-off).
  • Reading feeds- feeds which, are getting store data from ultrasonic sensors (Drawer-1, Drawer-2, Laundry-bag).

Creating a Feed

  1. Enter Feeds section
  2. Click Actions and Create a New Feed
  3. Fill: Name of the feed (here for the first Drawer- Drawer-1, and short description)

The same way create five more feeds. Remember that the names will be used for further ESP8266's code development.

Feeeds are ready, however there is no an easy way to attempt all the readings at the same time. That is why Dashboards are needed.

Step 7: Connecting ESP8266 With Adafruit IO: Creating Dashboard

Creating dashboard starts in Dashboards section. Click Actions button (similarly like in Feeds section)-> Create a New Dashboard-> fill name (in this case: Your_Laundry_System) and short description-> Click Create button. After that you are able to enter the Dashboard.

In the Dashboard click Create a new block button. For this application we need three types of blocks:

  • 3x Toggle (for turning on and off sensing)
  • 3x Gauge (showing actual level in a drawer/laundry bag)
  • 3x Line chart (showing historical data)

Toggle

  1. Click on the Toggle icon.
  2. Pick first ON/OFF feed, i.e. Drawer-1-Onoff.
  3. Add block title i.e. Clean T-shirts- Drawer 1. Click Create block.

Place the toggle in the upper corner of the dashboard. In the same way connect the rest of ON/OFF feeds with the Toogle.

Gauge

  1. Click on the Gauge icon.
  2. Pick first data collecting feed: Drawer-1.
  3. Fill Data accordingly: for Block title i.e.: Clean T-shirts- Drawer 1, Gauge Max Value (depending of the depth of the drawer- it this case 10), Low/High Warining Value (change of the color of gauge).

Place the gauge on the dashboard. In the same way connect the rest of data storing feeds with the Gauge.

Line chart

  1. Click on the Line chart icon.
  2. Pick fist data collecting feed: Drawer-1.
  3. Change Show History field into 24 hours, change Y-Axis Maximum and Decimal places depending on the depth of the drawer.

Place the line chart on the dashboard. In the same way connect the rest of data storing feeds with the Line chart.

Final dashboard is enclosed in the images section. Remember that the dashboards show how much empty place is still in the laundry bag/drawers.

Step 8: Connecting ESP8266 With Adafruit IO: Creating Code for Ultrasonic Sensors

Firstly, Adafruit MQTT library is needed. In aim to install it open Arduino IDE->Tools->Manage libraries and type into search: Adafruit MQTT. The library should be installed into your computer.

After that download enclosed example of the code (here enclosed a code for ultrasonic sensor working in the laundry bag).

To make it applicable for your configuration you have to change following details:

  • WLAN_SSID- your WiFi network's name.
  • WLAN_PASS- password to your WiFi network.
  • AIO_USERNAME- name of your user in Adafruit IO (from step 4).
  • AIO_KEY- Adafruit IO key (from step 4).
  • Adafruit_MQTT_Publish .... "/feeds/Laundry-bag"- here you have to put name of the feed to which data will be published.
  • Adafruit_MQTT_Subscribe "/feeds/Laundry-bag-On-off"- here you have to put name of the feed, which triggers sensor.

After that program has to be uploaded into ESP8266. It is needed to change feeds' names for Drawer 1 and Drawer 2.

Important notice: because of if (message == "ON") the system will measure the distance only once and when dashboard button ON/OFF is on ON position. To measure again a user have to turn off and turn the sensor on the dashboard again.

After uploading the program to every ESP8266 dashboard should be showing reading from each sensor. Sensors can be triggered from the level of the dashboard. Tiggering the system is also possible from the IFTTT applet level (step 13).

Step 9: IFTTT, Connect IFTTT to Adafruit

Warning: IFTTT is not the most reliable connection when triggering Google Calendar and e-mail using three sensors connected to Adafruit IO. Go to Step 14 to learn more about Zapier.

IFTTT is web-based service which create simple condition “If This Then That”. It works with other web-based service like Gmail, Facebook, Instagram, etc. The simple condition consists of “This” which is actually the trigger and “That” which is the action required to be perform. Applets requires to be created to have this simple condition works in IFTTT platform. This project utilizes Adafruit.io MQTT as a cloud to show the level of clothes in laundry bag, and drawers then IFTTT will receive the trigger from Adafruit.io to send the reminder to user through google calendar or Gmail.

First Create IFTTT account in IFTTT website. Sign in to your account. IFTTT requires to be connected to Adafruit account where the dashboard was created. Go to the following link to connect to Adafruit https://ifttt.com/adafruit

Next Click Connect, you will be directed to the Adafruit webpage, and click Authorize. For this project IFTTT has been connected to Adafruit account as shown in the picture. After IFTTT connected to Adafruit account, Applets are ready to be created.

Step 10: Create Applet in IFTTT

This project has tried to connect to Gmail, Google Calender and IFTTT app. The followings are the steps are to create Applet in platform and create the trigger from Adafruit.

1. Go to My applet https://ifttt.com/my_applets and click New Applet

2. You will be directed to if +this then that and click +this or click build on the platform.

Step 11: Create Trigger From Adafruit

Now, you can start to configure your own Applet.

1. First If Trigger, search Services type Adafruit, then select Monitor a feed on Adafruit IO

2. Set other parameters Feed Label Name, Feed Label Relationship and Feed Label Value. Set as customizable by the user to ease if there is any changes required later, you don't have to change it through platform.

3. For this project the Feed that is required to monitor is Drawer 1, Drawer 2 and Laundry Bag. For Drawer 1 and Drawer 2 has the relationship of greater than 5 which indicates that drawer is almost empty while laundry bag has the relationship less than 5 which indicate that it is almost full.

Step 12: Create Action to Gmail, Google Calender and Notification to IFTTT App.

Finally the actions for IFTTT to be configured, for this project we have created Applet which sends email to Gmail and an event to Google Calendar whenever the Drawer 1 or Drawer 2 are empty or Laundry Bag are full. The following are the step for creating the Action:

1. Action Search services Gmail, Google Calender and Notification

2. After that you can select from pull menu, either an email or quick add event or send notification from IFTTT app

3. Then Apllets are ready, any additional text can be added according to yout project for the email, event ot notification from IFTTT appl

Step 13: Testing

Now we test our Laundry system. As explained Email, or Event in Calendar as well as Notification will be received by user whenever one of Drawers is almost empty or Laundry Bag is almost full.

However we find the problem with delay in receiving Email or Google Calender and IFTTT only send one email or eventhough eventhough Both Drawer 1 and 2 as well as Laundry Bag are triggered. Furthermore there is no significant delay in IFTTT App in giving the notification. As shown in picture all three notification received around the same time. Therefore we recommend to use IFTTT app to be used for this such kind of system to mitigate the delay.

Step 14: Using Zapier Service

Since we faced the problem in IFTTT where we have significant delay and only receive one notification (either Gmail or Google calendar) where all drawers and laundry bag are actually triggered. The problem was consulted to Adafruit and they suggested to use Zapier. In order to use Zapier you have to be invited since connection with Adafruit IO is still in testing phase (right now there is less than 10 active users). By deploying we can receive both email and Google calendar within 5 minutes (every 5 minutes Zapier checks if a new value in a monitored feed appeared, if yes the applet runs). In addition, there is task history where we can monitor the trigger from Adafruit to Gmail and Google calendar.

Basically it is the same principle with IFTTT, where you need to set the trigger from Adafruit, after that set the feed from your dashboard in this case whether drawer1, drawer2 or laundry bag. The relationship is set in filter setup and condition where we set as greater than 6 for drawer and less than 5 for laundry back. Finally set the action whether to send an email through Gmail or quick add event.

Step 15: Tiggering the System From IFTTT Level

The system can be also triggered from IFTTT, what supplies the user with a level of automation. In order to do that we are creating two additional applets for each sensor- one which is turning on the sensor and the second one which is turning it off.

Turning on applet

Trigger (If)

  1. In Search service window type: Data & Time.
  2. Choose option: Every day at.
  3. Set value for the hour needed (in this example 9:00 PM).

Action (Then)

  1. In Search services window type Adafruit IO.
  2. Field label- name of the ON/OFF feed.
  3. Value: On

Fill Applet title field with the name of the applet and add a short Applet description.Click Save and turn on the applet.

Turning off applet

Clone your on applet and change:

  1. Trigger section: Time value into 15 minutes later (i.e. 9:15 PM).
  2. Action section: Value: OFF.

Click Save and turn on the applet.

The same way create applets for the rest of the sensors. Remember- to get notification from every sensor, not only the dashboard reading, two sensors should not be triggered at the same time (meaning Drawer 1 triggered- 9:00-9:15 PM, Drawer 2- 9:15-9:30PM, Laundry baf- 9:30-9:45 PM).


Step 16: Future Scope: Industrilization of the Product

The IoT device built here can be easily produced in bulk and sold to companies selling smart homes. It is a helpful tool for people with busy schedules or in large homes with lots of people and rooms. In this case, the dashboard can include data from all the rooms of all the people and thus make their lives easier. As this is completely wireless and thus can be easily scaled to any number of drawers needed.

Step 17: Possible Troubles You Might Face

1. you may see your ultrasonic giving random values. Its because your power might not be 5V. The safest thing is to use 9V batteries and use Potentiometers.

2. Make sure the ground is same for sensor and ESP, else your whole system will not work.

Step 18: Towards the End...

This laundry system is a novel idea. There is no such product like this in the market yet. So if you want it in your home, you have to build it yourself. We are hoping you understand the instructions. It was just a gist of IoT and electroncics.

This system is really easy to use. However, it has guidelines of use. The clothes in the bins should be kept folded, otherwise the sensor just senses wrong distance. It is not advisable to use this for winter clothes in small drawers, since jakets are bulky and the removal of one or two jackets would mean the drawer is empty. Which might not be very useful.

During our work we used following sources, which can be useful in deeper understanding of the project:

https://learn.adafruit.com/mqtt-adafruit-io-and-yo...

https://www.instructables.com/id/Distance-Measurem...

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • PCB Contest

      PCB Contest
    • Toys Contest

      Toys Contest

    Discussions