top of page

IoT Cloud Smart Garbage Monitoring System with Email, SMS Notification

Updated: Jul 2, 2021

In this tutorial, The Internet of Things (IoT) based garbage Waste Bin level monitoring and LCD Interface. and to build an IoT system using ESP8266 12E, myDevices Cayenne.

One of the main concerns with our environment has been solid waste management which impacts the health and environment of our society. The detection, monitoring and management of wastes is one of the primary problems of the present era. The traditional way of manually monitoring the wastes in waste bins is a cumbersome process and utilizes more human effort, time and cost which can easily be avoided with our present technologies.

This is our solution, a method in which waste management is automated. This is our IoT Garbage Monitoring system, an innovative way that will help to keep the cities clean and healthy.

Follow on to see how you could make an impact to help clean your community, home or even surroundings, taking us a step closer to a better way of living



Circuit Diagram



Components Required

HC SR04- Ultrasonic sensor

16x2.I2c- LCD display

ESP8266 12e- nodeMCU


HC-SR04 Ultrasonic Sensor - Working

As shown above the HC-SR04 Ultrasonic (US) sensor is a 4 pin module, whose pin names are Vcc, Trigger, Echo and Ground respectively. This sensor is a very popular sensor used in many applications where measuring distance or sensing objects are required. The module has two eyes like projects in the front which forms the Ultrasonic transmitter and Receiver. The sensor works with the simple high school formula that

Distance = Speed × Time

The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets objected by any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic receiver module as shown in the picture below

Now, to calculate the distance using the above formulae, we should know the Speed and time. Since we are using the Ultrasonic wave we know the universal speed of US wave at room conditions which is 330m/s. The circuitry inbuilt on the module will calculate the time taken for the US wave to come back and turns on the echo pin high for that same particular amount of time, this way we can also know the time taken. Now simply calculate the distance using a microcontroller or microprocessor.

How to use the HC-SR04 Ultrasonic Sensor

HC-SR04 distance sensor is commonly used with both microcontroller and microprocessor platforms like Arduino, ARM, PIC, Raspberry Pie etc. The following guide is universally since it has to be followed irrespective of the type of computational device used.

Power the Sensor using a regulated +5V through the Vcc ad Ground pins of the sensor. The current consumed by the sensor is less than 15mA and hence can be directly powered by the on board 5V pins (If available). The Trigger and the Echo pins are both I/O pins and hence they can be connected to I/O pins of the microcontroller. To start the measurement, the trigger pin has to be made high for 10uS and then turned off. This action will trigger an ultrasonic wave at frequency of 40Hz from the transmitter and the receiver will wait for the wave to return. Once the wave is returned after it getting reflected by any object the Echo pin goes high for a particular amount of time which will be equal to the time taken for the wave to return back to the sensor.

The amount of time during which the Echo pin stays high is measured by the MCU/MPU as it gives the information about the time taken for the wave to return back to the Sensor. Using this information the distance is measured as explained in the above heading.

Applications

  • Used to avoid and detect obstacles with robots like biped robot, obstacle avoider robot, path finding robot etc.

  • Used to measure the distance within a wide range of 2cm to 400cm

  • Can be used to map the objects surrounding the sensor by rotating it

  • Depth of certain places like wells, pits etc can be measured since the waves can penetrate through water



Installing Libraries

LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library.

In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.

After installing the required libraries, copy the following code to your Arduino IDE.

Subscribe and Download code.


arduino code:

#include <ESP8266WiFi.h>

#include <HCSR04.h>


#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);


#include <CayenneMQTTESP8266.h>



char ssid[] = "TP-Link_3200"; // your SSID

char password[]="9500112137"; // your password



// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.

char username[] = "2031dd30-5414-11eb-b767-3f1a8f1211ba";

char mqtt_password[] = "f2ce829d98df3a768328ac6936eae9fd47d28289";

char client_id[] = "3cd74400-6dde-11eb-8779-7d56e82df461";



#define MAX_HEIGHT 20 // your bin height

int Percentage;


UltraSonicDistanceSensor distanceSensor(D5,D6); //D1 trig, D2=ech



void setup(void){

Serial.begin(115200);

Cayenne.begin(username,mqtt_password,client_id,ssid,password);// starting cayenne

delay(1000);

lcd.init(); // initialize the lcd

// Print a message to the LCD.

lcd.backlight();


}


void loop(){

Cayenne.loop();

float actualCM=1*distanceSensor.measureDistanceCm();

// Serial.println(actualCM);

Percentage=(MAX_HEIGHT-actualCM)/(MAX_HEIGHT-5)*100 ;

Serial.println(Percentage);

lcd.clear();

lcd.setCursor(0,0);

lcd.print(" IOT Smart BIN ");

lcd.setCursor(0,1);

lcd.print("Waste Fill:");

lcd.setCursor(11,1);

lcd.print(Percentage);

lcd.setCursor(13,1);

lcd.print(" % ");

delay(1000);

Cayenne.virtualWrite(1, Percentage);

if(Percentage>=100)


{ lcd.setCursor(11,1);

lcd.print("FULL ");

delay(1000);

}

}


Then, upload the code to your NodeMCU board. Make sure you have selected the right board and COM port. Also, make sure you’ve inserted your WiFi Credentials in the code.

After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the ESP8266 board. Now it should print its IP address.


Hardware interfacing with Cayenne IoT platform

To interface the circuit with the IoT platform, open this link on any browser.

Refer previous Tutorial for more details






3,171 views0 comments
bottom of page