Johan Sandoval
Published

Lane Tech HS - PCL - Rain Detector

A sensor that detects rain.

BeginnerFull instructions provided1 hour297
Lane Tech HS - PCL - Rain Detector

Things used in this project

Hardware components

Elegoo Water Level Sensor
×1
Argon
Particle Argon
×1
Breadboard (generic)
Breadboard (generic)
×2
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Jumper wires (generic)
Jumper wires (generic)
×19
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
IFTTT

Story

Read more

Schematics

Water Sensor

Water Sensor Schematic

Water Sensor File

Code

Source Code

C/C++
The code reads a sensor value as an analogue input, if the input is greater than a predetermined threshold set a particle variable to true.
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal.h>

//Initialize Pins
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int waterSense = A0;
int waterDet = 0;

void setup()
{
    //Initialize LCD Screen
    lcd.begin(16, 2);
    pinMode(waterSense, INPUT_PULLUP);
    //Declare Particle Variable
    Particle.variable("Water Detected", waterDet);
}

void loop()
{
    //Read sensor value as an analogue input, if the input is greater than a predetermined threshold set Particle variable to true.
    int sensorValue = analogRead(waterSense);
    lcd.setCursor(0, 1);
    lcd.print(sensorValue);
    delay(400);
    if (sensorValue >= 900 && sensorValue < 2000){
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("WET");
        delay(50);
        waterDet = 1;
        
    }
    else{
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("NOT WET");
        delay(50);
        waterDet = 0;
    }
}

Credits

Johan Sandoval

Johan Sandoval

2 projects • 4 followers

Comments

Add projectSign up / Login