Translate

Membuat Alat Monitoring Ketinggian Air (Water Level) ARDUINO via WIFI Ethernet Shield

Membuat Alat Monitoring Ketinggian Air (Water Level) ARDUINO via WIFI Ethernet Shield


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang digunakan untuk mengukur ketinggian air atau water level dengan menggunakan arduino dan sensor air, media pengiriman datanya menggunakan wifi dan penerimanya bisa menggunakan komputer atau handphone yang sudah dilengkapi software browser. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino Uno + Ethernet Shield




b. Sensor Hujan / Air




c. Router Wifi






d. Program Arduino IDE

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,200);

EthernetServer server(80);

String readString;

int x = 500;

void setup() {

 pinMode(4,OUTPUT);
 pinMode(7,OUTPUT);

  Serial.begin(9600);
   while (!Serial) {
  }

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  int dataadc1 = analogRead(0);
  int dataadc2 = analogRead(1);
  int dataadc3 = analogRead(2);

  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
     if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println(" ");
          client.println("<title> Monitor Ketinggian Air </title> ");    
          client.println("<body bgcolor = #000000>");    
          client.println("<center>");
            client.println("<font color = yellow><center><h1>MONITOR KETINGGIAN AIR<br></h1></center><br></font>");
            client.println("<font color = #FFFFFF>");
            client.println("<h2>");
            client.println("Sensor 1 = ");
            client.print(dataadc1);
            client.println("<br />");
            client.println("Sensor 2 = ");
            client.print(dataadc2);
            client.println("<br />");
            client.println("Sensor 3 = ");
            client.print(dataadc3);
            client.println("<br />");
            client.println("<br />");
            client.println("Ketinggian Air = ");
           
            if((dataadc1 > x)&&(dataadc2 > x)&&(dataadc3 > x)){
            client.println("Tidak ada Air ");
            digitalWrite(4,LOW);
            digitalWrite(7,LOW);           
            }
           
            if((dataadc1 < x)&&(dataadc2 > x)&&(dataadc3 > x)){
            client.println("1 - 30 cm ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);  
            }
           
            if((dataadc1 < x)&&(dataadc2 < x)&&(dataadc3 > x)){
            client.println("30 - 60 cm ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);
            }
           
            if((dataadc1 < x)&&(dataadc2 < x)&&(dataadc3 < x)){
            client.println("1 meter atau lebih ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);
            }
           
            client.println("</h2>");     
          client.println("</font>");
          client.println("</center>");
          client.println("</body>");
          client.println("</html>");
           
          break;      
        }   
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }

         readString="";

}




e. VIDEO HASILNYA









No comments:

Post a Comment