Salman Faris
Published © LGPL

SEBi: Smart Electric Bin

Smart and efficient way to monitor your waste bin and help you to dispose of it at the correct time.

IntermediateFull instructions provided1 hour2,965
SEBi: Smart Electric Bin

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
LED (generic)
LED (generic)
×2

Software apps and online services

Cayenne
myDevices Cayenne
Arduino IDE
Arduino IDE

Story

Read more

Schematics

SEBi_Client

Sebi layout ifmz9ve7gk

Code

SEBI_Client NodeMCU code

C/C++
#include <CayenneMQTTESP8266.h> 

char ssid[] = "wifi name"; 
char password[] = "wifi password"; 

char username[] = "mqtt user name"; 
char mqtt_password[] = "mqtt password"; 
char client_id[] = "mqtt client id"; 

#define trigPin D2 
#define echoPin D5 

int green = D6; 

void setup()
{ 

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

pinMode(green,OUTPUT); 
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
Serial.begin(115200);  

digitalWrite(green,HIGH); 

} 
void loop(){
 
 Cayenne.loop(); 

long duration, distance; 

digitalWrite(trigPin, LOW);  
delayMicroseconds(2);  
digitalWrite(trigPin, HIGH); 
delayMicroseconds(10);  
digitalWrite(trigPin, LOW); 
duration = pulseIn(echoPin, HIGH); 
distance = (duration/2) / 29.1; 

Serial.println(distance); 

Cayenne.virtualWrite(3,distance); 

delay(1000); 

} 

CAYENNE_IN(1)
{ 
  digitalWrite(green,!getValue.asInt()); 
}  

Cayenne MQTT ESP8266 Library

Credits

Salman Faris

Salman Faris

11 projects • 227 followers
Maker | Hardware Hacker | Electronics Enthusiast

Comments