Tech Gyan Set
Published © MIT

ESP32 Smart Public Toilet Monitoring System

ESP32-based smart system that monitors public toilet hygiene, odor, and water level in real time.

BeginnerFull instructions provided8 hours45
ESP32 Smart Public Toilet Monitoring System

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

🚻 ESP32 Smart Public Toilet Monitoring System – Complete Code

C/C++
// --------------------------------------------
// Smart Public Toilet Monitoring System
// ESP32 + PIR + MQ135 + Water Sensor + Buzzer
// --------------------------------------------

#include <WiFi.h>

// WiFi Credentials
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";

// Pin Configuration
#define PIR_PIN 27
#define GAS_SENSOR 34
#define WATER_SENSOR 35
#define BUZZER_PIN 26

// Threshold Values
int gasThreshold = 2000;
int waterThreshold = 500;

// Variables
int motionValue;
int gasValue;
int waterValue;

void setup()
{
  Serial.begin(115200);

  pinMode(PIR_PIN, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  digitalWrite(BUZZER_PIN, LOW);

  // WiFi Connection
  Serial.println("Connecting to WiFi...");

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi Connected");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  Serial.println("Smart Public Toilet Monitoring System Started");
}

void loop()
{

  // Read Sensors
  motionValue = digitalRead(PIR_PIN);
  gasValue = analogRead(GAS_SENSOR);
  waterValue = analogRead(WATER_SENSOR);

  Serial.println("----------- SENSOR DATA -----------");

  Serial.print("Motion Status: ");
  Serial.println(motionValue);

  Serial.print("Gas Level: ");
  Serial.println(gasValue);

  Serial.print("Water Level: ");
  Serial.println(waterValue);

  // Odor Detection
  if (gasValue > gasThreshold)
  {
    Serial.println("⚠ Bad Odor Detected - Cleaning Required");
    digitalWrite(BUZZER_PIN, HIGH);
  }
  else
  {
    digitalWrite(BUZZER_PIN, LOW);
  }

  // Water Level Check
  if (waterValue < waterThreshold)
  {
    Serial.println("⚠ Water Tank Low - Refill Required");
  }
  else
  {
    Serial.println("Water Level OK");
  }

  // Motion Detection
  if (motionValue == HIGH)
  {
    Serial.println("Toilet In Use");
  }
  else
  {
    Serial.println("No User Detected");
  }

  Serial.println("-----------------------------------");

  delay(3000);
}

Credits

Tech Gyan Set
32 projects • 12 followers
Tech Gyan Set | IoT & Embedded Systems Creator | Arduino, ESP32, GSM & NodeMCU Projects | Smart Home & Real-Life Automation Tutorials
Thanks to Tech Gyan Set .

Comments