IoT Based Smart Dustbin – Using Blynk and Arduino

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.

Software requirements :

Hardware Requirements :

Ultrasonic Sensor

Ultrasonic Sensor

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

ESP8266 – 01 WiFi Module

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

The 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 applications through its GPIOs.

Features :

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

Servo SG90

Servo SG90

A servo motor is an electrical device that 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 a servo motor. It is just made up of a simple motor that runs through a servo mechanism. If the motor is used is DC powered then it is called DC servo motor, and if it is AC powered motor then it is called an AC servo motor.

We can get a very high torque servo motor in a small and lightweight package. Due to these features, they are being used in many applications like toy cars, RC helicopters, and planes, Robotics, Machine, etc.

Configuring Your ESP8266 – 01 WiFi Module

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()
  while (!Serial)



void loop()
  if (mySerial.available())
  if (Serial.available())

After Uploading the code.

Try sending the basic command: AT

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

Configuring Your ESP8266 – 01 WiFi Module

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.

Step 1 : Click on New Project

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

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

Step 4 : Configure the Pins and Data range

Now your Blynk should Look Like this Circuit Diagram

 Circuit Diagram

Circuit Diagram of IOT BAed smart Dustbin

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.

Working Code of IoT based Smart Dustbin

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

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()
  pinMode(ECHOPIN, INPUT);
  pinMode(IR, INPUT);
  Blynk.begin(auth, wifi, ssid, pass);

void sendSensor()
  // start working...
digitalWrite(TRIGGERPIN, LOW);
// Sets the TRIGGERPIN on HIGH state for 10 micro seconds
digitalWrite(TRIGGERPIN, HIGH);
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: ");
Blynk.virtualWrite(V1, distance);



void loop()


Also See

Temperature and Monitoring using IoT

IoT Based Soil Moisture Monitoring and Control System

Leave a Reply

Your email address will not be published. Required fields are marked *