IoT Powered Restroom Usage Indication System

Abstract

Time management and work efficiency are essential components of a productive work environment. This project was launched to resolve a situation in which twenty employees had to share a restroom. In this scenario, they were required to physically leave the office to check if the restroom was available or not, decreasing working efficiency. In this project, a cost-efficient IoT powered motion detection system was devised to detect if a restroom is occupied or vacant. By transmitting information about whether the restroom is vacant or occupied, the device allowed the employees to leave their office room only when the restroom is vacant. The proposed system consists of two parts: detection and visualization. The detection part is composed of an Arduino Uno board, a Passive Infra-Red (PIR) sensor and a WIFI module. The visualization of the detection was created using an existing IoT platform, which is free of charge for non-commercial use. The developed system was implemented in the restroom of the office, increasing working efficiency and convenience.

Introduction

The project was developed to increase productivity and working convenience during an AI summer internship. At the start of the internship, there was a noticeable problem with the restroom: there was only one toilet on the floor where more than twenty people work. This proved to be an inconvenience because people would often walk to the restroom, only to find it occupied. However, if there was a way to detect the occupancy state of the restroom, people would not have to constantly check whether the restroom was occupied, improving working efficiency.

In order to solve this problem, an infrared sensor was used to detect if a person was using the restroom, and an Arduino circuit-based system was devised to detect the toilet occupancy. This system conveyed the occupancy information to an IoT server where people could see the toilet usage status with minimal time delay. An IoT server is also known as the ‘Internet of Things’; it is a system of devices that are connected to the internet, allowing mechanical devices to send and receive data.1 The PIR (Passive InfraRed) sensor detects if the toilet is occupied or not, but doesn’t violate the privacy of the people using the toilet. The information about toilet usage status is sent over a WIFI module, so the PIR sensor and the WIFI module are implemented into an Arduino circuit. The IoT platform receives the data sent by the Arduino’s WIFI component, processes and visualizes the information for the people. An existing IoT platform, Thinkspeak, was used for this project because it provides a simple but very intuitive built-in display free of charge.2 A more detailed description on the whole development process is provided in the following sections: ‘System Design’, ‘Experimentation and Problems’, and ‘Installation and Results’. This report ends with other applications for this system.

System Design 

The restroom usage indication system is created using an Arduino Uno circuit board, PIR sensor and the WIFI module, ESP-8266. The system diagram is shown in Figure 1.

Figure 1: Diagram of restroom usage indication system

The built system is set up in the restroom to detect the status of the toilet. The detected data is sent to an IoT platform where the indication status data is viewed by the employees.

Hardware implementation

The components that constitute the system include the following: a PIR sensor (Passive Infrared Sensor), a WIFI module, an Arduino Uno board, a breadboard, and an Arduino R3 Prototype shield. The PIR sensor is a passive sensor, meaning that it does not send IR rays or heat, but detects the infrared rays or reflected infrared rays from a person or an object that emits heat.3

The system’s hardware is implemented one step at a time. Firstly, the PIR sensor was connected to the Arduino Uno board to familiarize with its function and its sensing performance. If the PIR sensor detects motion, it will trigger a signal to display the message on the serial monitor as shown in Figure 2.

Figure 2: Occupied message displayed on the serial monitor as it detected motion

If the IR sensor didn\’t detect any movement, it would display ‘Vacant!’ on the serial monitor as shown in Figure 3.

Figure 3: Vacant message supposed to be displayed on the serial monitor

After implementing the PIR, the WIFI module was connected to the Arduino Uno board.

Figure 4: Wiring of IR sensor and WIFI module to Arduino Uno4

Figure 4 depicts the pinout between the Arduino Uno board, the ESP 8266 WIFI component, and the PIR sensor. ESP 8266’s RX, VCC, TX and GND pins are connected to TX 3.3V, RX, and the GND of the Arduino Uno board respectively. The PIR sensor’s GND, Output, and VCC are connected to GND, one of the digital pins (this PIR sensor was connected to digital pin 2), and 3.3V respectively. As there is only one slot for the 3.3V pin; it has to be shared between the ESP-8266 and the PIR sensor by using a breadboard or a shield.

Software Implementation

With the Arduino Uno board connected with the WIFI component and PIR sensor, a short program was coded in Arduino’s integrated development environment (IDE) to control the whole system’s functions. The Arduino IDE is a software primarily used to write and upload code to an Arduino device.5 In the beginning, there were a number of problems when configuring the ESP8266 WIFI component to connect to the office’s WIFI network; the ESP-8266 would time out before establishing a WIFI connection to the WIFI network. The error message of WIFI connection failure is shown in Figure 5.

Figure 5: Example of a failure message when connecting to the ESP8266 WIFI component

The problem mentioned above was solved by using ‘AT’ commands in the Serial Monitor of Arduino IDE. ‘AT’ commands are commands or directions entered into a Serial Monitor that allow the user to control a device, an Arduino in this case. This method solved the issue of ‘timed out waiting for package header,’ and the ESP8266 WIFI module connected to the internet successfully. Apart from the WIFI establishment, a program was written to send the PIR sensor’s detection information to an IoT platform. In this project, Thinkspeak platform was used because it provides convenient features free of charge. The Arduino would use the API keys from Thinkspeak to access the website; then the platform would update the new imported data every 15 seconds, and the employees would see the restroom usage status.

The whole program is shown in Figure 6 as a reference. This program was sourced originally from Innovate Yourself, and the WIFI configuration part was modified to be compatible with the office’s WIFI network. Innovate Yourself is a Youtube channel that makes videos pertaining to IoT (Internet of Things) and arduino circuits.

Figure 6: The program of the system coded in Arduino IDE 6

Putting it all together

After the program and the hardware connection was established, the breadboard was replaced with a prototype shield that can be attached on top of the Arduino circuit board. Not only does this modification save space, but wires can also be directly soldered onto the shield, allowing the connections to stay permanent. Therefore, all of the components: wires, WIFI module, and the PIR sensor were all soldered onto the shield. This shield is slightly different from the breadboard; the holes are not connected so electricity cannot flow through them. Therefore, solder was applied to connect the two different holes, allowing the electricity to flow from one wire to another. The resulting product is shown in Figure 7.

Figure 7: Arduino Uno circuit with PIR and WIFI components after soldering

Experimentation and Problems

The system was tested to ensure that the PIR sensor gives accurate detections. There are two parameters to tune the sensor’s performance: the sensitivity and the delay time of the PIR sensor. As shown in Figure 8, the two orange ‘crosses’ control the delay time and the sensitivity of the PIR sensor.

Figure 8: PIR sensor’s sensitivity controller

The PIR sensor occasionally sent data as ‘occupied’ even though there was no person. This is known as a false alarm or a false positive. A few of the causes include the following: an unstable environment, wind, a sudden change in temperature, a prolonged delay time, etc. Additionally, there is a delay time in the PIR sensor because it is not always “awake” to sense any motion; the delay time was kept to a minimum to avoid false alarms. Conversely, false negatives, which are when the sensor sends data as ‘vacant’ even though there is a person, can be solved by increasing the sensitivity, decreasing the delay time, or changing the mode of the PIR sensor. However, by increasing the sensitivity, there will be an increased probability of a false positive. Therefore, it is difficult to solve both false negatives and false positives simultaneously using sensitivity adjustment.

The PIR sensor has two different modes: the single trigger and the retrigger mode. The single trigger mode will only detect motion for a certain amount of time before it goes ‘to sleep’. During the sleeping interval, the Arduino circuit will receive ‘vacant’ data from the PIR sensor, no matter what the circumstance is. So, the Arduino circuit can send the wrong data during PIR sensor’s sleeping interval over to \’Thinkspeak\’. In contrast, the retrigger mode allows the PIR sensor to recalculate the delay time every time it detects motion, meaning, the PIR sensor will continue to stay on and send ‘Occupied’ as long as the motion is present. In Figure 8, the trigger mode can be controlled using the yellow ‘cover’, or the jumper wire, by shifting it down a slot. The minimum range, or the sensitivity of the PIR sensor, is 3 meters, so the sensitivity was also kept at a minimum as the restroom is small and increasing the sensitivity may give false positives. False positives can also occur frequently under sunlight and in regions of unstable temperatures. Therefore, to maintain an ambient atmosphere, the sensor was encased to avoid airflow and prevent any droplets of water ending up on the shield (this can cause a short circuit). Lastly, a Fresnel lens, which is shown in Figure 9, is always attached to the sensor to give the best performance; it allows a wider range of infrared rays to be detected by scattering its ‘sensing areas’ through many different angles. Then, the Fresnel lens would also allow the infrared rays emitted by the person to be focused onto the sensor due to its shape.7

Figure 9: Fresnel lens for PIR sensor

Discussion and Real Life Applications

After the PIR sensor was tested and problems were resolved, it was set up in the restroom. A small rack that is attachable to the wall was bought as a base to place the device. Whenever a person entered the restroom, the lamp would turn on, and when there was no motion, the lamp would go off as shown in Figure 10. This simple indicator would tell the employees the immediate status of toilet usage with a delay of less than a minute.

Figure 10: A lamp indicator that shows whether or not the restroom is occupied.8

Although the results turned out to be better than expected, eliminating all false positives was not possible. The device was left on all day to observe when the restroom was most occupied. The trend of the restroom occupancy is plotted in a graph as shown in Figure 11. Wherever the graph spikes up to ‘1’ signifies that the restroom is occupied, whereas ‘0’ indicates that the restroom is vacant. Each point is separated into 10-minute intervals throughout the day: 10:50 AM-3:00 PM. By assessing this graph, it is evident that there are frequent uses of the restroom during the morning, almost none during lunch, and a few visits as the afternoon progresses.

Figure 11: Graph indicating if the restroom is occupied or vacant.9

Furthermore, the restroom indication system can be used outside of the restroom for other purposes, the detection of suspicious break-ins or potential thefts. Other uses of the system include automatic lights, automatic flushing for toilets, and automatic doors. In addition, there are various types of IR sensors such as thermal infrared sensors and active infrared sensors. For larger companies, bathroom occupancy data could be collected and utilized to install bathrooms in areas that have a higher occupancy rate. In case that you have any plumbing issue whether at home or your business this emergency plumber in Sydney can help you out as they offer 24/7 services. 

Conclusion

Although this project has been successful, there were also several limitations. In the future, the battery efficiency should be improved because the battery of the PIR sensor ran out at an extremely fast pace; in future experiments, an Arduino Nano should be used instead of an Arduino UNO to reduce power consumption and increase its compactness. Moreover, to enhance the reliability of the PIR sensor, a better and more advanced sensor should be used, such as a system that utilizes two PIR sensors. This method could significantly reduce false positives due to a sudden change in airflow or temperature that cannot be solved by the methods used in this experiment.10 Furthermore, there are various applications of the PIR sensor related to security, and these low-cost devices can be implemented in schools and other institutions. By doing so, students and users can be notified of when the restroom is available, which will be useful during time-constraining situations. Make sure to maintain your bathroom by scheduling a bord gais boiler replacement with plumbing professional near you.

References

Ada, and Dicola Tony. “PIR Motion Sensor.” Adafruit Learning System, by Ada and Tony Dicola, 2019. Accessed August 12, 2019. https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work.

Adnan Aqeel. “Introduction to Arduino IDE.” The Engineering Projects. The Engineering Projects,by Adnan Aqueel. October 5, 2018. ://www.theengineeringprojects.com/2018/10/introduction-to-arduino-ide.html.

Components101. “ESP8266 – WiFi Module.” ESP8266 Pinout, Pin Configuration, Features,Example Circuit & Datasheet, March 20, 2018. Accessed June 22, 2019.https://components101.com/wireless/esp8266-pinout-configuration-features-datasheet.

Electronics & Communication, Anitha Shetty. “Infrared Sensor – How It Works, Types,Applications, Advantage & Disadvantage.” by Shetty Anitha.electricalfundablog.com, October 23, 2018. Accessed August 2, 2019. https://electricalfundablog.com/infrared-sensor/.

Last Minute Engineers. “How HC-SR501 PIR Sensor Works & How To Interface It With Arduino.” by Last Minute Engineers, December 7, 2018. Accessed August 13, 2019.https://lastminuteengineers.com/pir-sensor-arduino-tutorial/.

ioBridge. “ThingSpeak for IoT Projects.” IoT Analytics – ThingSpeak Internet of Things. The Math Works, INC, 2010. Accessed June 16, 2019 https://thingspeak.com/.

Malik Balil and Oljaca Miro. Texas Instruments. “Advanced Motion Detector Using PIR Sensors Reference Design For False Trigger Avoidance.” by Malik Balil and Miro Oljaca http://www.ti.com. Texas Instruments Incorporated, February 2017. http://www.ti.com/lit/ug/tiducv3b/tiducv3b.pdf.

McClelland, Callum. “What Is IoT? – A Simple Explanation of the Internet of Things.” IoT For All, November 19, 2019. https://www.iotforall.com/what-is-iot-simple-explanation/.

Yourself, Innovate. “HOW TO CONNECT ESP8266 TO INTERNET | ARDUINO WITH IOT | PART 7.” YouTube. YouTube, July 29, 2017. Accessed August 2, 2019. https://www.youtube.com/watch?v=9Kg9idg2np0.

  1. (McClelland, Callum, November 19, 2019)
  2. (Thinkspeak, 2010)
  3. (Anitha Shetty, 2019)
  4. (Components 101, 2019)
  5. (Adnan Aqueel, 2018)
  6. (Innovate Yourself, 2017)
  7. (Ada and Tony Dicola, 2019)
  8. (Last Minute Engineers, 2018)
  9. (Thinkspeak, 2017)
  10. (Malik Balil and Oljaca Miro, 2017)

About the author

 

 

Youngwoo Chang is 15 years old and attends St. Mary’s International School in Tokyo, Japan. His favorite subjects are math and science. He likes playing the guitar and tennis in his free time. He also co-founded an AI Club where he writes articles about astronomy and AI. He hopes to learn further about how AI is becoming more advanced in those fields.

Leave a Comment

Your email address will not be published. Required fields are marked *