Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
M6hlqueeutbzfkhid4ph
Arduino Ethernet Shield 2
×1
12002 04
Breadboard (generic)
×1
Openbuilds wire cable by foot
OpenBuilds Wire Cable - By the Foot
×1
386 00
DHT11 Temperature & Humidity Sensor
×1
Relay (generic)
×1
pompa air
×1

Schematics

Code

Monitoring jamurC/C++
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>

#include <DHT.h>

#define DHTPIN 9  //menggunakan pin 2 untuk pemasangan sensornya
#define DHTTYPE DHT11 //memilih tipe DHT11, bisa diubah menjadi DHT22, DHT21 
DHT dht(DHTPIN, DHTTYPE);
// Board Ethernet
byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0x48, 0xD3 };
IPAddress ip(192, 168, 1, 177);
IPAddress gateway(192,168,1,177);
IPAddress subnet(255, 255, 255, 0);
// Request and Callback
EthernetServer server(80);
String readString;

int relay = 8;
volatile byte relayState = LOW;

boolean status_motor = true;
void setup() {
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  dht.begin();
  // Server Network
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.print("IP Board : ");
  Serial.println(Ethernet.localIP());
  Serial.println("Jamur");
  Serial.begin(9600);
}
void loop() {
  float kelembaban = dht.readHumidity(); //menyimpan nilai Humidity pada variabel kelembaban
  float suhu = dht.readTemperature(); //menyimpan nilai Temperature pada variabel suhu
  
  Serial.print(" Kelembaban: "); //menampilkan tulisan Kelembaban di Serial Monitor
  Serial.print(kelembaban); //menampilkan nilai kelembaban
  Serial.print(" Suhu: "); //menampilkan tulisan suhu
  Serial.println(suhu); //menampilkan nilai suhu
  
  delay(500); //memberi jeda waktu baca selama 500 mili detik
  
  if(status_motor){
    if(suhu<=29){
      digitalWrite(relay, LOW);
    }
    if(suhu>=30){
      digitalWrite(relay, HIGH);
    }
  }

  // Server
  EthernetClient client = server.available();
  if (client)
  {
  Serial.println("new client");
  while (client.connected())
  {
    if (client.available())
    {
      char c = client.read();
      if (readString.length() < 100)
      {
        readString += c;
        Serial.write(c);
        if (c == '\n') {
        Serial.println(readString);
        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println();
        client.println("<HTML>");
        client.println("<HEAD>");
        client.println("<TITLE>Jejamur</TITLE>");
        client.println("<center>");
        client.println("</HEAD>");
        client.println("<BODY>");
        client.println("<H1>Monitoring Jamur</H1>");
        client.println("<BR/>");
        client.println("<center>");
        client.println("Suhu Jamur:");
        client.println(suhu);
        client.println("<BR/>");
        client.println("Kelembaban Jamur:");
        client.println(kelembaban);
        client.println("<BR/>");
        client.println("<a href='?matikan'>Matikan</a> | <a href='?hidupkan'>Hidupkan</a>");
        client.println("</center>");
        client.println("</BODY>");
        client.println("</HTML>");
        delay(1);
        client.stop();
        if(readString.indexOf("?matikan") >0)
        {
          digitalWrite(relay, LOW);
          status_motor = true;
          Serial.println("Matikan");
        }
        else if(readString.indexOf("?hidupkan") >0)
        {
          digitalWrite(relay, HIGH);
          status_motor = false;
          Serial.println("Hidupkan");
        }
        readString="";
        delay(1);
        client.stop();
        Serial.println("client disonnected");
        }
      }
    }
  }
 }
  

}

Credits

12391226 1726711220881597 7569077402558281475 n
Kitami Akromunnisa
0 projects • 0 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login