IoT Based Smart Dustbin

IoT Based Smart Dustbin Monitoring System

IoT Based Smart Dustbin

In this tutorial we are going to create a IoT Based Smart Dustbin Monitoring System

We are going to monitor whether the Dustbin is full or not and if full then notify the Owner through a push notification on their phone.

Table of Content :

Software Requirements

Hardware Requirements

Ultrasonic Sensor

ESP8266 – 01 WiFi Module

Servo Motor SG90

Configuration ESP8266 – 01 WiFi Module

Configuration of Blynk Application

Circuit Diagram

Code

OUTPUT Video

Software requirements :

Blynk Application

Arduino IDE

Hardware Requirements :

Ultrasonic Sensor

IoT Based Smart Dustbin

It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.

ESP8266 – 01 WiFi Module

IoT Based Smart Dustbin
ESP8266-01 WiFi Module

ESP8266-01 is a Serial WiFi Transmitter and Receiver which can give any Micro-controller access to WiFi Network.

ESP8266 module is of low cost and comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers.This module has a powerful on-board processing and storage capability that allows it to be integrated with the sensors and other application through its GPIOs .

Features :

  1. Wi-Fi Direct (P2P), soft-AP
  2. Integrated TCP/IP protocol stack
  3. It features an integrated TR switch, balun, LNA, power amplifier and matching network
  4. Equips integrated PLL, regulators, DCXO and power management units
  5. Integrated low power 32-bit CPU could be used as an application processor
  6. SDIO 1.1 / 2.0, SPI, UART
  7. STBC, 1×1 MIMO, 2×1 MIMO
  8. A-MPDU & A-MSDU aggregation & 0.4ms guard interval
  9. Wake up and transmit packets in < 2ms
  10. Standby power consumption of < 1.0mW (DTIM3)

Servo Motor SG90

servo motor is an electrical device which can push or rotate an object with great precision. If you want to rotate and object at some specific angles or distance, then you use servo motor. It is just made up of simple motor which run through servo mechanism. If motor is used is DC powered then it is called DC servo motor, and if it is AC powered motor then it is called AC servo motor. We can get a very high torque servo motor in a small and light weight packages. Doe to these features they are being used in many applications like toy car, RC helicopters and planes, Robotics, Machine etc.

Configuring your ESP8266 – 01 WiFi Module

Connect your ESP 01 in according to the connections given below.

Then upload this code to your Arduino Uno.

#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(2,3); //connect esp rx pin to 3
                               //connect esp tx pin to 2
void setup()
{
  Serial.begin(9600);
  while (!Serial)
  {
  }
  mySerial.begin(115200);
  mySerial.println("AT");
  delay(1000);
  mySerial.println("AT+CWMODE=1");
  delay(1000);
  mySerial.println("AT+UART_DEF=9600,8,1,0,0");
}

void loop()
{
  if (mySerial.available())
  {
    Serial.write(mySerial.read());
  }
  if (Serial.available())
  {
    mySerial.write(Serial.read());
  }
}

Now Upload the code and open Serial Monitor. Selectr Both NL & CR and Set baud rate to 9600.

COM Port
COM Port

Try sending the basic command : AT

You must get a OK response. (This means your ESP 01 is working Fine).

Now your ESP 01 will be automatically configured. There are two commands which we have written in the above code.

AT+CWMODE=1 ( Sets the Wi-Fi mode (Station/AP/Station+AP) )

AT+UART_DEF=9600,8,1,0,3 (This will change the baud rate to 9600 you can even set it to 115200.)

Configuration Blynk App

Now let’s setup your Blynk App to receive data of Temperature and Humidity on Graphs.

Steps : Click on New Project

Blynk Configuration

Step 2: Add your Project Name and which Board we are going to use, In our Case it is Arduino Nano

Blynk Configuration

Step 3 : Select your Widget i.e. Level Vertical

Blynk Configuration

Step 4 : Configure the Pins and Data range

Blynk Configuration

Now your Blynk should Look Like this

Blynk Configuration

Circuit Diagram

IoT Based Smart Dustbin
Circuit Diagram

In the above diagram all the connections are shown for this project IoT Based Smart Dustbin .

We have used an Arduino Nano Shield for ease of connection. Connection will be the same for Arduino Nano Shield too.

Code

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include<Servo.h>

char auth[] = "your Auth Token";
char ssid[] = "Your Wifi Name";
char pass[] = "Your WiFI Password";

Servo myservo;
#define TRIGGERPIN  11
#define ECHOPIN     12
#define IR          10

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&Serial);

long distance, duration;

void setup()
{
  myservo.attach(9);
  Serial.begin(ESP8266_BAUD);
  delay(10);
  pinMode(TRIGGERPIN, OUTPUT);
  pinMode(ECHOPIN, INPUT);
  pinMode(IR, INPUT);
  Blynk.begin(auth, wifi, ssid, pass);
}

void sendSensor()
{
  // start working...
  digitalWrite(TRIGGERPIN, LOW);
  delayMicroseconds(2);
  // Sets the TRIGGERPIN on HIGH state for 10 micro seconds
  digitalWrite(TRIGGERPIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGERPIN, LOW);
  // Reads the ECHOPIN1, returns the sound wave travel time in microseconds
  duration = pulseIn(ECHOPIN, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);
  Blynk.virtualWrite(V1, distance);
  delay(500);

  if (digitalRead(IR))
  {
    Serial.println("enter");
    myservo.write(120);
  }

  else
  {
    myservo.write(0);
  }
}

void loop()
{
  sendSensor();
  Blynk.run();
}

Now upload the code and Open The Serial Monitor and wait for the ESP 01 to connect with your WiFi then it will automatically connect to blynk ( don’t forget to press the play button in blynk application).

Video tutorial With OUTPUT – IoT Based Smart Dustbin

Checkout More IoT Projects :

IoT based Soil Moisture Monitoring and Control System

0

Leave a Comment

Your e-mail address will not be published. Required fields are marked *