Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
Sierra DummermuthFranklin Adu-BandohSydney Prince
Published

MEGR 3171 Water Level Sensor

This water level sensor will notify you if the water level of your fish tank or any other body of water gets too low.

BeginnerFull instructions provided271
MEGR 3171 Water Level Sensor

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
Our team used three breadboards in total, one for each component in the project.
×3
Jumper wires (generic)
Jumper wires (generic)
Our team used a total of eight jumper wires, two for the water level sensor, two for the LED, and three for the passive buzzer.
×7
Male/Female Jumper Wires
Male/Female Jumper Wires
Our group used three male/female jumper wires for the water level sensor component.
×3
LED (generic)
LED (generic)
Our group used one LED for the LED component of the project.
×1
Argon
Particle Argon
Our group used three particle argons, one per each component. These boards communicated with one another through a set of code.
×3
Resistor 220 ohm
Resistor 220 ohm
Our group used one 220 ohm resistor for the LED component of our project.
×1
Water Level Sensor
Our group used one water level sensor in the water level sensor component of the project.
×1
Passive Buzzer
Our group used one Passive buzzer in the noise alert component of our project.
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Our group used this website to connect our boards together as well as program the boards to communicate with one another and read/ receive data.

Story

Read more

Custom parts and enclosures

Water Level Sensor

Schematics

Water Level Sensor Schematic

Here is a hand drawn image of the schematic setup for our water level sensor.

Passive Buzzer Sensor

Here is a hand drawn image of the schematic setup for the passive buzzer sensor.

LED

Here is a hand drawn image of the schematic setup for the LED.

Code

Water Level Sensor Code

C/C++
This code uses the publish and subscribe functions in order to display and send data to the LED and buzzer. This code also utilizes thingspeak in order to publish our data to the thingspeak website to output a graph.
//Water Level Sensor Code - By Sydney Prince

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

bool humid = false;

TCPClient client;

unsigned long myChannelNumber = 1246842;
const char * myWriteAPIKey = "55PIFS2J2GPK72VM";


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 () {
    
     ThingSpeak.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("Water Level Low", String (wl), PRIVATE);
    }
      else if (resval>100 && resval<=2000){
        wl = 1;
        Particle.publish("Water Level Good", String (wl), PRIVATE);
   
     delay(10000); //Delay 10 seconds between measurements
    }
    
  Serial.println("wl"); 
    
  delay (10000);  

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

}

LED Code

C/C++
This code subscribes to when the water level is low so the LED will blink notifying the user.
//LED Code - By Sydney Prince

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

void setup () {
    
    Particle.subscribe("Water Level Low", water, "Sierra"); 
    
    Serial.begin(9600);
    
    pinMode(led1, OUTPUT);
    
}

void water(const char *event, const char *data) {
  // To blink the LED, first we'll turn it on...

if(event){
    
    digitalWrite(led1, HIGH);
    delay (500);
    digitalWrite(led1, LOW);
    delay (500);
    
    digitalWrite(led1, HIGH);
    delay (500);
    digitalWrite(led1, LOW);
    delay (500);
  
    Particle.publish("waterlevel", PRIVATE);
    }
    
  delay (1000);
}

Buzzer Code

C/C++
This code also subscribes to "water level low" and emits a buzzing noise when the water level sensor drops below a certain output value.
//Buzzer Code - By Sydney Prince

void setup() {
    
pinMode(D2, OUTPUT);  // buzzer on pin D2

Particle.subscribe("Water Level Low", 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("Water Level Low", PRIVATE);
      Particle.publish("Water Level Good", PRIVATE);
    }
}

Credits

Sierra Dummermuth
1 project • 0 followers
Contact
Franklin Adu-Bandoh
1 project • 0 followers
Contact
Sydney Prince
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.