Flags when a restroom needs cleaning and shows the water tank level.
Built and tested by Shahan Fathima K · Industrial Robotics Institute

A monitoring system for public restrooms. A gas sensor measures odour, an ultrasonic sensor checks the water tank level, and a PIR sensor detects usage. The ESP8266 shows "Clean" or "Needs Cleaning" plus the water level on an LCD, and sounds a buzzer to call maintenance staff.
| Component | Qty |
|---|---|
| ESP8266 NodeMCU | 1 |
| PIR Motion Sensor | 1 |
| Gas Sensor (MQ-135) | 1 |
| Ultrasonic Sensor (HC-SR04) | 1 |
| 16×2 LCD with I2C Module | 1 |
| Buzzer | 1 |
| Jumper Wires | As needed |
| Power Supply | 1 |
| From | Connect to |
|---|---|
| PIR OUT | D1 |
| MQ-135 AOUT | A0 |
| Ultrasonic TRIG | D2 |
| Ultrasonic ECHO | D3 |
| LCD SDA | D4 |
| LCD SCL | D5 |
| Buzzer + | D6 |
| All sensors and LCD VCC / GND | 5V (VIN) / GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define pirPin D1
#define gasPin A0
#define trigPin D2
#define echoPin D3
#define buzzer D6
LiquidCrystal_I2C lcd(0x27, 16, 2);
long duration;
int distance;
void setup()
{
pinMode(pirPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Wire.begin(D4, D5); // SDA = D4, SCL = D5
lcd.init();
lcd.backlight();
lcd.print("Smart Restroom");
delay(2000);
lcd.clear();
}
void loop()
{
int motion = digitalRead(pirPin);
int gasLevel = analogRead(gasPin);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
lcd.setCursor(0, 0);
if (gasLevel > 400)
{
lcd.print("Needs Cleaning ");
digitalWrite(buzzer, HIGH);
}
else
{
lcd.print("Clean ");
digitalWrite(buzzer, LOW);
}
lcd.setCursor(0, 1);
lcd.print("Water: ");
lcd.print(distance);
lcd.print("cm ");
delay(1000);
}A monitoring system for public restrooms. A gas sensor measures odour, an ultrasonic sensor checks the water tank level, and a PIR sensor detects usage.
You need: ESP8266 NodeMCU (1), PIR Motion Sensor (1), Gas Sensor (MQ-135) (1), Ultrasonic Sensor (HC-SR04) (1), 16×2 LCD with I2C Module (1), Buzzer (1), Jumper Wires, Power Supply (1). Software: Arduino IDE, LiquidCrystal_I2C library.
It is rated intermediate and takes about 2–3 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-065). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.