Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Webserver with DHT11 Sensor and W5500 Ethernet Module for Temperature and Humidity Monitoring

Image of Arduino UNO Webserver with DHT11 Sensor and W5500 Ethernet Module for Temperature and Humidity Monitoring

Circuit Documentation

Summary

This circuit is designed to measure temperature and humidity using a DHT11 sensor and display the data on a web server hosted by an Arduino UNO with an Ethernet W5500 module. The Arduino UNO reads data from the DHT11 sensor and serves it over the network using the Ethernet module.

Component List

  1. DHT11 Humidity and Temperature Sensor

    • Description: Measures temperature and humidity.
    • Pins: VDD, DATA, NULL, GND
  2. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  3. Resistor

    • Description: Provides resistance in the circuit.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 10k Ohms
  4. Module Ethernet W5500

    • Description: Ethernet module for network communication.
    • Pins: NC, INT, RST, GND, 5V, SCK, SS, MOSI, MISO, 3.3V

Wiring Details

DHT11 Humidity and Temperature Sensor

  • VDD: Connected to 5V on Arduino UNO through a 10k Ohm resistor.
  • DATA: Connected to D2 on Arduino UNO through a 10k Ohm resistor.
  • GND: Connected to GND on Arduino UNO.

Arduino UNO

  • 5V: Connected to VDD of DHT11 through a 10k Ohm resistor.
  • D2: Connected to DATA of DHT11 through a 10k Ohm resistor.
  • GND: Connected to GND of DHT11 and GND of Ethernet W5500 module.
  • 3.3V: Connected to 3.3V of Ethernet W5500 module.
  • D13: Connected to SCK of Ethernet W5500 module.
  • D12: Connected to MISO of Ethernet W5500 module.
  • D11: Connected to MOSI of Ethernet W5500 module.
  • D10: Connected to SS of Ethernet W5500 module.

Resistor

  • pin1: Connected to 5V on Arduino UNO.
  • pin2: Connected to DATA of DHT11 and D2 on Arduino UNO.

Module Ethernet W5500

  • GND: Connected to GND on Arduino UNO.
  • 3.3V: Connected to 3.3V on Arduino UNO.
  • SCK: Connected to D13 on Arduino UNO.
  • MISO: Connected to D12 on Arduino UNO.
  • MOSI: Connected to D11 on Arduino UNO.
  • SS: Connected to D10 on Arduino UNO.

Documented Code

Webserver_1.ino

/*
  Elektrik Bağlantıları
W5500 Ethernet Modülünden Arduino Uno'ya:

VCC'den 3.3V'ye
GND'den GND'ye çevirme
SCK için Pin 13
MISO'dan Pin 12'ye
MOSI'den Pin 11'e
CS'den Pin 10'a

DHT11 Sensörden Arduino Uno'ya:
VCC'den 5V'ye çevirme
GND'den GND'ye çevirme
Pin 2'ye veri (VCC'ye 10k çekme direnci ile)
@ Harun OZKANLI 
WEBSERVER 29.12.2024 
*/

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

#define DHTPIN 2     // DHT11'in bağlı olduğu pin
#define DHTTYPE DHT11   // DHT 11

DHT dht(DHTPIN, DHTTYPE);

// Kontrol cihazınız için MAC adresini ve IP adresini aşağıya girin.
// IP adresi yerel ağınıza bağlı olacaktır.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177);

// kullanmak istediğiniz IP adresi ve port ile Ethernet sunucu kütüphanesini başlatın
//
EthernetServer server(80);

void setup() {
  // Ethernet bağlantısını ve sunucuyu başlatın
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
  dht.begin();
  Serial.print("Server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // Gelen clients  dinleyin 
  EthernetClient client = server.available();
  if (client) {
    Serial.println("New client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // Satırın sonuna geldiyseniz (yeni satır karakteri aldıysanız) 
        // ve satır boşsa, HTTP isteği sona ermiştir, bu nedenle bir 
        // yanıt gönderebilirsiniz
        if (c == '\n' && currentLineIsBlank) {
          // Standart bir HTTP yanıt başlığı gönder
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // yanıt tamamlandıktan sonra bağlantı kapatılacaktır
          client.println("Refresh: 5");  // sayfayı her 5 saniyede bir otomatik olarak yenile
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // DHT11 sensöründen sıcaklık ve nemi okuyun
          float h = dht.readHumidity();
          float t = dht.readTemperature();
          // Herhangi bir okumanın başarısız olup olmadığını kontrol edin ve erken çıkın (tekrar denemek için).
          if (isnan(h) || isnan(t)) {
            client.println("Failed to read from DHT sensor!");
          } else {
            client.print("Temperature: ");
            client.print(t);
            client.println(" *C");
            client.print("Humidity: ");
            client.print(h);
            client.println(" %");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // Yeni bir satıra başlıyorsun
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // Mevcut satırda bir karakter aldınız
          currentLineIsBlank = false;
        }
      }
    }
    // Web tarayıcısına verileri alması için zaman tanıyın
    delay(1);
    // Bağlantıyı kapatın
    client.stop();
    Serial.println("Client disconnected");
  }
}

documentation.txt

Arduino Uno , W5500 Ethernet Modul ve DHT-11 ile Webserver Sıcaklık ve Nem ölçme