Introduction: Smart Trash Bin - Email Notifier When Full (Wifi IoT)

This is a smart trash bin that senses if the trash is full and sends a notification to you to let you know its time to empty it!

Step 1: BoM

* ESP32

* Ultrasonic Sensor - HC-SR04

* Female-Female Jumper Cable

* Trash bin

Tools:

Hot Glue Gun

Step 2: Wiring

* Connect the VCC pin on the Ultrasonic sensor to 3.3V on the ESP32

* Connect the GND pin on the Ultrasonic sensor to the GND pin on the ESP32

* Connect the Trig Pin on the Ultrasonic sensor to D4 on the ESP32

* Connect the Echo Pin on the Ultrasonic sensor to D5 on the ESP32

Step 3: Mount

Glue the ultrasonic sensor such that it is facing downward towards the trash bin.

Step 4: Upload Code to ESP32

#define BLYNK_PRINT Serial
/* Set this to a bigger number, to enable sending longer messages */ //#define BLYNK_MAX_SENDBYTES 128

#include "WiFi.h"
#include "WiFiClient.h" #include "BlynkSimpleEsp32.h"

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
void emailOnButtonPress()
{
  // *** WARNING: You are limited to send ONLY ONE E-MAIL PER 15 SECONDS! ***
  // Let's send an e-mail when you press the button
  // connected to digital pin 2 on your Arduino
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
float duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
 
  if (distance<2)
  {
     Blynk.email("techmartian@techmartian.com", "Clean your Trash!");
    
  }
}
void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
  Blynk.run();
}

Step 5: Plug in and Enjoy!

Plug it in to an outlet and enjoy a clean trash bin!

Comments

author
AlexZhang (author)2017-09-01

I don't understand why you would want to do this. Wouldn't it be easier just to look at the trash can when you throw something in?

About This Instructable

182views

2favorites

License:

Bio: Aerospace Engineer working in Software Development with a passion for Hardware.
More by TechMartian:Flying Captain America's Shield - RC PlaneWide Angle ShotsLED Ping Pong With Shift Register
Add instructable to: