TwheelAaron Auth
Published

IOT Particle Argon Clean-Up

Do you have messy roommates that you constantly have to clean up after, this project might be for you.

IntermediateShowcase (no instructions)5 hours23
IOT Particle Argon Clean-Up

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×2
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

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

Story

Read more

Schematics

Trashcan Sesnor

Trashcan Trigger

Code

Trashcan Sesnor

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



// This is the variable section for code, calling in variables to be used 
double cm = 0.0;
bool beam_status = false;

int trigPin = D4;
int echoPin = D5;
int led = D7;

HC_SR04 rangefinder = HC_SR04(trigPin, echoPin);  

void setup ()
{
    Spark.variable("cm", &cm, DOUBLE);  
    // Subscribe to the integration response event
  Particle.subscribe("hook-response/TrashThrown", myHandler, MY_DEVICES);
}

void myHandler(const char *event, const char *data) {
     // Handle the integration response
}

void loop ()
{
    cm = rangefinder.getDistanceCM();
    if (cm<30){                         //setting the status of the beam up to differentiate between trash thrown away and not 
        if (beam_status==false){
            
            Particle.publish("TrashThrown", "Clean");           
            beam_status = true;
        }
    } else {
        if (beam_status==false){
            
        } else { 
            Particle.publish("TrashThrown", "CleanHouse");
            beam_status = false;
        }
    }
    delay(100);
}

Trashcan Trigger

C/C++
int led2 = D7; 
int button = D1;
int buttonState = 0;
void setup() {
  pinMode(led2, OUTPUT);
  pinmode(button, INPUT);
  Particle.subscribe("TrashThrown", LED, "e00fce6823dfa92be610e3c1");
}

void LED(const char *event, const char *data) {
    buttonState = digitalRead(button);
  if (buttonState==HIGH) {
    Particle.publish("Button_pushed", "Pushed");
    delay(1000);
    digitalWrite(led2, HIGH);
  } else {
      digitalWrite(led2, LOW);
  }
}

void loop() {
   
}

TwoWayComs1

C/C++
void setup() {
    pinMode(D7, OUTPUT);
    Particle.subscribe("TrashThrown", myHandler, MY_DEVICES);
}

void loop() {
    String data = String(2);
}

void myHandler(const char *event, const char *data) {
    
    digitalWrite(D7, HIGH);
    delay(1200);
     Particle.publish("TrashThrownAway", data, PRIVATE);
     delay(12000);
    digitalWrite(D7, LOW);
    delay(500);

}

TwoWayComs2

C/C++
void setup() {
    pinMode(D7, OUTPUT);
    Particle.subscribe("led-toggled", ledtoggled, MY_DEVICES);
}

void loop() {
    String data = String(1);
    digitalWrite(D7, HIGH);
    Particle.publish("TrashThrown", data, PRIVATE);
    delay(300);
    //data = "ledoff"
    digitalWrite(D7, LOW);
    delay(4000);
}
void ledtoggled(const char *event, const char *data) {
    digitalWrite(D7, HIGH);
    delay(500);
    digitalWrite(D7, LOW);
    delay(500);
}

Credits

Twheel

Twheel

1 project • 1 follower
Aaron Auth

Aaron Auth

0 projects • 0 followers

Comments

Add projectSign up / Login