Wesley MeakemWesley Goodwin
Published © GPL3+

Hot Water Accountability System (HWAS)

This device helps you keep your roommate from using all the hot water while they're showering.

IntermediateShowcase (no instructions)5 hours104
Hot Water Accountability System (HWAS)

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×2
Argon
Particle Argon
×2
LED (generic)
LED (generic)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

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

Story

Read more

Schematics

D1 Wiring Diagram

This is the downstairs breadboard wiring diagram

U1 Wiring Diagram

This is the upstairs breadboard wiring diagram

Code

Upstairs Board

C/C++
This is the board that contains the humidity sensor and buzzer
//Libraries
// This #include statement was automatically added by the Particle IDE.
#include <Grove_Temperature_And_Humidity_Sensor.h>
//Define pins used
DHT dht(D2);
int buzzerPin = D6;
//Declare Variables
int Humidity = 0;
bool tooHigh = false;
bool buzzerTrigger = false;
#define check_time 5000
unsigned long lastCheck = 0;
///////////////////////////////////////////////////////////////////
//Setup
void setup()
{
    Serial.begin(9600);
    
    dht.begin();
    
    Particle.variable("Humidity", Humidity);
    
    Particle.subscribe("Buzzer", buzzer, MY_DEVICES); // Subscribe to tooHigh Function
}
/////////////////////////////////////////////////////////////////////
//Functions
void buzz() // Function used to make buzzer "buzz"
{
    for (int i=0; i<100; i++)
    {
        digitalWrite(buzzerPin, HIGH);
        delay(1);
        digitalWrite(buzzerPin, LOW); 
        delay(1);
    }
}
void buzzer(const char *event, const char *data) // Turn buzzer trigger to true if a "buzzer" event is detected
{
    if(event)
    {
        buzzerTrigger = true; //set buzzer to be true if event "buzzer" is published
    }
    
    while(buzzerTrigger)
    {
        for(int i=0; i<5; i++)
        {
            buzz();
            delay(500);
        }
        
        buzzerTrigger = false;
    }
}
void checkHumidity() //Function to check humidity level
{
    if (dht.getHumidity())
    {
        Humidity = dht.getHumidity();
        
        Particle.publish("Humidity", String(Humidity), PRIVATE);
        
        if (Humidity >= 70)
        {
            tooHigh = true;
            Particle.publish("tooHigh", String(tooHigh), PRIVATE);
        }
    }
}
//////////////////////////////////////////////////////////////////
//Void loop
void loop()
{
    if (lastCheck + check_time < millis())
    {
        lastCheck = millis();
        checkHumidity();
        buzz();
    }
    
}

Downstairs Board

C/C++
This is the board that contains the button and LED
//Declare Variables
const int led = D0;
const int button = D6;
int buttonState = 0;
bool blink = false;
bool buzzer = false;
///////////////////////////////////////////////////////
void setup()
{
    Particle.subscribe("tooHigh", tooHigh, MY_DEVICES); //Subscrube to tooHigh Function
    pinMode(led, OUTPUT); // Set led pin as output
    pinMode(button, INPUT); // set button pin as input
}
///////////////////////////////////////////////////////
//Functions
void tooHigh(const char *event, const char *data)
{
    if(event)
    {
        blink = true; //set blink to be true if event "tooHigh" is published
    }
}
void blinkLED() //blink led
{
    digitalWrite(led, HIGH);
    delay(500);
    digitalWrite(led, LOW);
    delay(500);
}
////////////////////////////////////////////////////////////
//Void Loop
void loop()
{
    buttonState = digitalRead(button);
    
    if(blink == true)
    {
        blinkLED();
        
        if (buttonState == HIGH)
        {
            buzzer = true;
            Particle.publish("Buzzer", String(buzzer), PRIVATE);
            blink = false;
        }
        
    }
}

Credits

Wesley Meakem

Wesley Meakem

1 project • 0 followers
Wesley Goodwin

Wesley Goodwin

0 projects • 1 follower

Comments

Add projectSign up / Login