Wesley AitkenJordan  BellamyShishir Desai
Published

Smart Human General Waste Receptacle

Ever shuffled outside in the freezing cold to take in the trash just to see it's still full? Well guess what, we have the product for you.

AdvancedFull instructions provided20 hours58
Smart Human General Waste Receptacle

Things used in this project

Hardware components

Argon
Particle Argon
×3
Breadboard (generic)
Breadboard (generic)
×4
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Analog Accelerometer: ADXL335
Adafruit Analog Accelerometer: ADXL335
×1
LED (generic)
LED (generic)
×3
Jumper wires (generic)
Jumper wires (generic)
×20
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
ELEGOO UNO R3 Project Complete Starter Kit
ELEGOO UNO R3 Project Complete Starter Kit
Power Supply Module 3.3V/5V
×1

Software apps and online services

ThingSpeak API
ThingSpeak API
Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Ultrasonic Sensor Circuit

LED Circuit Diagram

Accelerometer and Temperature Sensor Circuit

Code

Ultrasonic Sensor Code (Argon 2)

C/C++
#define HCSR04_PIN_TRIG	D2
#define HCSR04_PIN_ECHO	D6

int sound = 0;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
 
  pinMode(HCSR04_PIN_TRIG, OUTPUT);
  pinMode(HCSR04_PIN_ECHO, INPUT);
  Particle.subscribe("Day of the Week", Hot_Curry_Day,"e00fce68aa1fe5aba8cdab9a");
 
}

void Hot_Curry_Day (const char *event, const char *data) {
  // put your main code here, to run repeatedly:
  long timeTaken, distance;
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(HCSR04_PIN_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  timeTaken = pulseIn(HCSR04_PIN_ECHO, HIGH);//determine distance of wave
  distance = (timeTaken/2)/29.1;//using timeTaken calc distance of object

  /*determine corressponding leds to light up with respect to the distance
  of object*/

 if (strcmp(data, "Wednesday") == 0) {
      if(distance<=.5){
       Particle.publish("SMARTrash","Trash Can At Home Base" ,PUBLIC);
    }
    else{
      Particle.publish("SMARTrash","Trash Can not at home" ,PUBLIC);
      }
    delay(5000);
      
  }

}

Accelerometer/ Temperature Sensor Code (Argon 3)

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

#define DHTPIN 5     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT11         
int UVint;
DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

#include <math.h>
const int x_out = A1; /* connect x_out of module to A1 of Particle Photon board */
const int y_out = A2; /* connect y_out of module to A2 of Particle Photon board */
const int z_out = A3; /* connect z_out of module to A3 of Particle Photon board */
double currenttime;
double currenthour;
float ch = currenthour;
float cd = currenttime;


TCPClient client;

unsigned long myChannelNumber = 1966344;
const char * myWriteAPIKey = "2K0BZPJ0YIGH1E5B";

unsigned long myChannelNumber2 = 1358252; //Replace with your own channel number
const char * myWriteAPIKey2 = "1ETUJPTN9B1ZSOYL"; //Replace with your own API key


void setup() {
Particle.subscribe("SMARTrash", Hot_Curry_Trash,"e00fce68983af8f9dbcd3618");
Particle.subscribe("Day of the Week", Hot_Curry_Day,"e00fce68aa1fe5aba8cdab9a");
  Serial.begin(9600); 
  Time.zone(-4);
  ThingSpeak.begin(client);
  pinMode(D5, OUTPUT);
  Serial.begin(9600); 
 dht.begin();


}

void Hot_Curry_Trash (const char *event, const char *data) 
{

  int x_adc_value, y_adc_value, z_adc_value, y_above; 
  x_adc_value = analogRead(x_out); /* Digital value of voltage on x_out pin */ 
  y_adc_value = analogRead(y_out); /* Digital value of voltage on y_out pin */ 
  z_adc_value = analogRead(z_out); /* Digital value of voltage on z_out pin */ 
  Serial.print("x = ");
  Serial.print(x_adc_value);
  Serial.print("\t\t");
  Serial.print("y = ");
  Serial.print(y_adc_value);
  Serial.print("\t\t");
  Serial.print("z = ");
  Serial.print(z_adc_value);
  Serial.print("\t\t");
  Serial.print(cd);
  Serial.print(ch);
  
  // read the input on analog pin 0:
    int sensorValue =  y_adc_value;
	
	// Write to ThingSpeak, field 1, immediately
	 // ThingSpeak will only accept updates every 15 seconds.
    
 
  //Particle.publish("Z",String(z_adc_value),PRIVATE);
  //Particle.publish("Day",String(cd),PRIVATE);
  //Particle.publish("Hour",String(ch),PRIVATE);
  
  if (strcmp(data, "Trash Can not at home") == 0) {
     
      {Particle.publish("Hot Curry Y",String(y_adc_value),PUBLIC);}
      if (y_adc_value < 2000)
      {Particle.publish("Hot Curry Y Above/Below","Below",PUBLIC);}
      
      if (y_adc_value > 2000)
      {Particle.publish("Hot Curry Y Above/Below","Above",PUBLIC);}
      
        ThingSpeak.writeField(myChannelNumber, 1, sensorValue, myWriteAPIKey);
	    delay(20000);      
  }

}
 
void Hot_Curry_Day (const char *event, const char *data) {
    // Wait a few seconds between measurements.
    delay(1000);
   
    // Read temperature as Farenheit
    float f = dht.getTempFarenheit();

  String f_string = String(f);
  
  if (strcmp(data, "Wednesday") == 0){
      Particle.publish("Temp", f_string , ALL_DEVICES);
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  
    delay(3000); // ThingSpeak will only accept updates every 15 seconds.
  }
   
    
}

Home Base Code (Argon 1)

C/C++
#include <math.h>
int led1 = D1;
int led2 = D2;
int led3 = D3;
int led4 = D4;
int state = 0;
double currenttime;
double currenthour;
float ch = currenthour;
float cd = currenttime;


void setup() {
    
Particle.subscribe("Hot Curry Y Above/Below", Curry_Argon_Handler_Above,"e00fce68a353e04aa247b66a");
Particle.subscribe("SMARTrash",Curry_Argon_Handler_Trashcan,"e00fce68983af8f9dbcd3618");

// subscribe to the HC-SR04 sensor. Name is MEGR3171_IOTGROUP18_ParkingSensor 
// The handler name is used below for the void loop. Make sure name is identical. 

Serial.begin(9600);

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);

Time.zone(-4);

}


void loop () { 
float time_now= Time.weekday();
cd = time_now;
float hour= Time.hour();   
ch = hour;



if (cd == 5){
    {Particle.publish("Day of the Week","Wednesday",PUBLIC);}
    delay(5000);
}

}

void Curry_Argon_Handler_Above(const char *event, const char *data)
{
  
    
    if (strcmp(data,"Below") == 0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led2, HIGH);
        digitalWrite(led1, LOW);
    }
    
    if (strcmp(data,"Above") == 0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led1, HIGH);
        digitalWrite(led2, LOW);
        Particle.unsubscribe(); 
     
    }  
        // if the data is something else, don't do anything.
        // Really the data shouldn't be anything but those two listed above.
    delay(1000);
}

void Curry_Argon_Handler_Trashcan(const char *event, const char *data)
{
 
    if (strcmp(data,"Trash Can not at home") == 0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led3, HIGH);
        digitalWrite(led4, LOW);
    }
    
    if (strcmp(data,"Trash Can At Home Base") == 0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led4, HIGH);
        digitalWrite(led3, LOW);
     
    }  
        // if the data is something else, don't do anything.
        // Really the data shouldn't be anything but those two listed above.
    delay(1000);
}

Credits

Wesley Aitken

Wesley Aitken

1 project • 2 followers
Jordan  Bellamy

Jordan Bellamy

0 projects • 1 follower
Shishir Desai

Shishir Desai

0 projects • 1 follower

Comments

Add projectSign up / Login