Sullivan Stevens
Published

IOT Project

This is project is designed to let you know when you have reached the optimal level of water for your pre-workout!

BeginnerFull instructions provided62
IOT Project

Story

Read more

Schematics

Water Level Sensor Schematic

This graphs shows the collected data from the Water Level Sensor put into an Excel data graph. You can see that the value is 0 until water begins to touch the sensor, where it spikes to 1 and stays constant. If the graph were to continue further, then the the output value for the water level sensor would drop back to zero, representing the sensor being dried off.

Buzzer Schematic

Water Sensor Breadboard

This was the breadboard used to indicate when the water had hit the appropriate level, and sent a signal to the buzzer to alarm the operator to stop pouring.

Buzzer breadboard

This component of the project received signals from the water level sensor and relayed the signal to the buzzer to alarm the operator to quit pouring.

Data Graphs

Code

Water Level Sensor

C/C++
#include "levsens.h"

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

bool humid = false;

TCPClient client;

unsigned long myChannelNumber = 1246842;
const char * myWriteAPIKey = "ARNKAD108UGVH72";


int resval = 0;  // Holds pin value
int respin = A3; // sensor pin used
int wl = 0; //waterlevel sensor value

SerialLogHandler logHandler;
int i = 0;

void Sierra(const char *event, const char *data)
{
  i++;
  Log.info("%d: event=%s data=%s", i, event, (data ? data : "NULL"));
}

void setup () {
    
     levsens.begin(client);
     
     Serial.begin(9600);
     pinMode(D3, OUTPUT); // Get output from LED
     pinMode(D2, OUTPUT); // Get output from the buzzer
    
    Particle.subscribe("waterlevel", Sierra); //Subscribes to both LED and Buzzer argon board
}

void loop()  {
   
    resval = analogRead(respin);

    if (resval<=100){
        wl = 0;
        Particle.publish("Keep Pouring", String (wl), PRIVATE);
    }
      else if (resval>100 && resval<=2000){
        wl = 1;
        Particle.publish("Start Shaking!", String (wl), PRIVATE);
   
     delay(10000); //Delay 10 seconds between measurements
    }
    
  Serial.println("wl"); 
    
  delay (10000);  

  levsens.setField(1,wl);
  
  levsens.writeFields(myChannelNumber, myWriteAPIKey);  

}

Buzzer Code

C/C++
The buzzer good is a loop that receives data from the water level sensor argon. Once the water level sensor outputs a value of 1, this activates the buzzer, allowing the user to know to stop pouring.
void setup() {
    
pinMode(D2, OUTPUT);  // buzzer on pin D2

Particle.subscribe("Start Shaking", alarm, "Sierra");

tone(D2, 3500, 2000); //desired pin, frequency and time
}

void alarm(const char *event, const char *data) //what the buzzer argon is looking for
{
     if (event)
    {
      tone(D2, 3500, 2000); //chosen frequency and time
      
      Particle.publish("Buzzer", PRIVATE);
      Particle.publish("Keep Pouring", PRIVATE);
      Particle.publish("Start Shaking", PRIVATE);
    }
}

Credits

Sullivan Stevens
1 project • 0 followers

Comments