Jeffrey PulsfortKenny Long
Published

MEGR 3171 - Filter Pitcher Pilfer Sensor

After getting absolutely fed up with our roommate's antics of not filling the pitcher back up, we put sensors on it to know when they steal.

BeginnerFull instructions provided8 hours80
MEGR 3171 - Filter Pitcher Pilfer Sensor

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Argon
Particle Argon
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Elegoo Water Level Sensor
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×12
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

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

Story

Read more

Schematics

Circuit Diagram

Argon Killswitch Diagram

Code

water-level-and-temp-sensors

C/C++
It is code.
// 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>

// This example assumes the sensor to be plugged into CONN2
#define DHTPIN A0     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT11        // DHT 11 

DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

int waterSens = A1; //define water sensor
int waterVal; //define the water sensor value


TCPClient client;


unsigned long myChannelNumber = 1574970;
const char * myWriteAPIKey = "9F1QX51OUX6HOH3S";


void setup() {
    
    ThingSpeak.begin(client);
    
 pinMode(A0, OUTPUT);
 pinMode(A1, OUTPUT);
 Serial.begin(9600); 
 dht.begin();

}

void loop() {
    // 2 second delay between loop iterations.
    delay(2000);

    waterVal = analogRead(waterSens); //read the water level sensor
      delay(1000);
    
    String level = String(waterVal);
      Particle.publish("Water_level_value", level, PRIVATE);
      delay(1000);
    
        Particle.publish("[kenny_argon]", String (waterVal), PUBLIC);
    
      ThingSpeak.setField(4,waterVal);
      

    // Read temperature in Celsius
    float t = dht.getTempCelcius();
    // Read temperature in Farenheit
    float f = dht.getTempFarenheit();

    // Check for any failed reads failed and exit before trying again.
    if (isnan(t) || isnan(f)) {
        Serial.println("Failed to read from DHT sensor.");
        return;
    }
    
    Particle.publish("[kenny_argon]", String (f), PUBLIC);

  ThingSpeak.setField(3,f);
  
  Serial.print(dht.getTempFarenheit());
  Serial.println("t");

  
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  

  delay(15000); // Delay ThingSpeak updates to 15 seconds so that it does not attempt to update too frequently 

}

Killswitch

C/C++
int button = D3;            //assigns button to D3
int val = 1;                //creates the val variable
int counter = 0;            //counter is set to 0
bool state = true;

void setup()
{
pinMode(button, INPUT);     //assigns button to input
Particle.variable("Butt",state);
}

void loop() {               //this will read the button press, and make an event for the main argon to power off.
    
    val = digitalRead(button);
    
    if (val == LOW) {
            counter = 0;
            state = false;
            Particle.publish("Butt", String(counter));
            delay(0);
    }
    else
    {delay(100);
    }
    
    if (state==false) {
        if (val==LOW) {
            state = true;
        }
    }
}

Credits

Jeffrey Pulsfort
1 project • 1 follower
Contact
Kenny Long
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.