Professional Documents
Culture Documents
Efficient Waste Monitoring
Efficient Waste Monitoring
Submitted to:
Leah Aquino-Alindayo, D. Eng., PCpE
Submitted by:
Fuentes, Christine Jay F.
Solon, Hanzel Bam G.
Tagas, Monica B.
JUNE 2023
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
INTRODUCTION
Background of the Study
In this IoT project, the primary focus is on the user input to detect the level of trash. If the
ESP32 device is connected to the internet, the control can be done through the Arduino IoT Cloud
dashboard. However, if the device is not connected to the internet, we will not be able to control the
trash level using the Arduino IoT Cloud.
BLOCK DIAGRAM
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
ESP32
MICROCONTROLLER
ULTRASONIC
SERVO IFFT PLATFORM
CLOUD
In this project, we are interfacing the ultrasonic sensor with ESP32. HC-SR04 ultrasonic sensor works
on 5V. The VCC pin of the ultrasonic sensor is connected to the VIN pin of Esp32. Trig and Echo
pins are connected to D2 and D5 pin of ESP32 while the GND pin of the sensor is connected to the
GND pin of ESP32.
ALGORITHM (Pseudocode)
HTML page. If the dustbin level exceeds or equals 70, it sends an event using the send_event function.
The send_event function connects to the specified host, constructs a URL with the event name and
private key, sends an HTTP GET request to the host, and prints the response. Overall, the algorithm
continuously measures the dustbin level, updates the webpage for connected clients, and sends an event
when the Smart Trashbin is almost full.
CODING:
#include <WiFi.h>
#include <WiFiClient.h>
// define the pins where you connected the Trig and Echo pins and also define two variables for
calculating distance and duration.
long duration;
int distance;
// make instances for Wi-Fi name, Wi-Fi password, IFTTT host name and private key.
//Now to access the WiFiServer, we declared an object WifiServer library. 80 is the default port for
HTTP.
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
WiFiServer server(80);
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(115200);
Serial.print("Connecting to Wi-Fi Network: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Successfully connected to WiFi.");
Serial.print("IP address is: ");
Serial.println(WiFi.localIP());
server.begin();
Serial.println("Server started");
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.0340 / 2;
Serial.println("Distance:");
Serial.println(distance);
level = ((14 - distance) / 14.0) * 100;
Serial.println("Level:");
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
Serial.println(level);
delay(1000);
if (client) {
Serial.println("Web Client connected");
String request = client.readStringUntil('\r');
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 10");
client.println();
\\ This code is for the display of our project the font and design
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<style>html { font-family: Cairo; display: block; margin: 0px auto; text-align:
center;color: #333333; background-color: #f3ffee;}");
client.println("body{margin-top: 50px;}");
client.println("h1 {margin: 50px auto 30px; font-size: 50px; text-align: center;}");
client.println(".side_adjust{display: inline-block;vertical-align: middle;position: relative;}");
client.println(".text1{font-weight: 180; padding-left: 5px; font-size: 50px; width: 170px; text-
align: left; color: #3498db;}");
client.println(".data1{font-weight: 180; padding-left: 1px; font-size: 50px;color: #3498db;}");
client.println(".data{padding: 1px;}");
client.println("</style>");
client.println("</head>");
client.println("<body>");
client.println("<div id=\"webpage\">");
client.println("<h1>IoT Based Trashbin</h1>");
client.println("<div class=\"data\">");
client.println("<div class=\"side_adjust text1\">Status:</div>");
client.println("<div class=\"side_adjust data1\">");
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
client.print(level);
client.println("<div class=\"side_adjust text1\">% filled</div>");
client.println("</div>");
client.println("</div>");
client.println("</body>");
client.println("</html>");
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("Connection failed");
return;
}
while (client.connected()) {
if (client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
} else {
delay(50);
}
}
Serial.println();
Serial.println("Closing connection");
client.stop();
}
Figure 3
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
Figure 4 and 5: Labeling the Waste Monitoring of the IoT-Based Trash Bin using ESP32 on
IFTTT
In Figure 4 and Figure 5, the trash display label shows that the trash levels are 0% and 81% respectively.
When the label of the trash bin exceeds 70%, an email notification is sent to inform that the trash bin is almost
full.
Figure 6: Notification
COMPUTER APPLICATIONS DEPARTMENT
COLLEGE OF COMPUTER STUDIES
Mindanao State University – Iligan Institute of Technology
Tibanga, Iligan City
BILL OF MATERIALS
REFERENCES:
https://www.researchgate.net/publication/353161459_Smart_Dustbin_Using_IOT_Notif
ication
https://quartzcomponents.com/blogs/electronics-projects/iot-based-smart-dustbin-
using-nodemcu