Erna Novia Safitri
Published

Deteksi Ketinggian Banjir berbasis NodeMCU dan Blynk

Alat deteksi ketinggian banjir ini berfungsi memonitoring ketinggian air sebagai antisipasi bahaya banjir.

IntermediateProtip391
Deteksi Ketinggian Banjir berbasis NodeMCU dan Blynk

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Buzzer
Buzzer
×1
water level sensor
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×3
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Rancangan Desain Hardware

Code

Code Deteksi Ketinggian Banjir

C/C++
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// Authorization token from the Blynk App.
char auth[] = "7683eab38c524f71869e07cd3affda1f";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ALHUSNA";
char pass[] = "wetgareng";


const int sensorPin= A0;
float liquid_level;
int liquid_graph;
const int LedHijau = D1;
const int LedKuning = D2;
const int LedMerah = D3;
const int Buzzer = D4;
const int BatasBawah = 250;
const int BatasAtas = 550;

        void setup() {
          Serial.begin(9600);
          Blynk.begin(auth, ssid, pass);
          pinMode(LedMerah, OUTPUT);
          pinMode(LedHijau, OUTPUT) ;
          pinMode(LedKuning, OUTPUT) ;
          pinMode (Buzzer, OUTPUT);
          pinMode(sensorPin, INPUT);
          Blynk.virtualWrite(V0, liquid_level);
          Blynk.virtualWrite(V1, liquid_graph);//This wil show the percentage of water in the container in a virtual pin V1
          Blynk.run();
        // initialize the LED pin as an output:
        pinMode(LedMerah, OUTPUT);
        pinMode(LedHijau, OUTPUT) ;
        pinMode(LedKuning, OUTPUT) ;
        pinMode (Buzzer, OUTPUT);
        // initialize serial communications:
        
        }

        void loop() {
        // read the value of the potentiometer:
        liquid_level = analogRead(sensorPin);
        liquid_graph =analogRead(sensorPin);//Percentage of water in the container 
        Serial.println(liquid_level);//This will print the liquid level in the monitor 
        Serial.println(liquid_graph);//This will print the percentage of liquid in the monitor
        Blynk.virtualWrite(V0, liquid_level);
        Blynk.virtualWrite(V1, liquid_graph);
        
        Blynk.run();
        int analogValue = analogRead(sensorPin);

        // if the analog value is high enough, turn on the LED:
        if (analogValue < BatasBawah) {
         digitalWrite(LedHijau, HIGH);
        } else {
         digitalWrite(LedHijau, LOW);
        }

        if (analogValue > BatasBawah ) {
        digitalWrite(LedKuning, HIGH);
        } else {
        digitalWrite(LedKuning, LOW);
        }

       if (analogValue > BatasAtas) {
       digitalWrite(LedKuning, LOW);
       digitalWrite(LedMerah, HIGH);
       digitalWrite(Buzzer , HIGH);
       
   
      } else {
       digitalWrite(LedMerah, LOW);
       digitalWrite(Buzzer , LOW);

      }
      // print the analog value:
      Serial.println(analogValue);
      delay(100);        // delay in between reads for stability
    }

Credits

Erna Novia Safitri

Erna Novia Safitri

1 project • 0 followers
Teknik Informatika, Uin Sunan Kalijaga

Comments

Add projectSign up / Login