SINAU PROGRAMMING
SINAU PROGRAMMING
  • Home
  • Source Code
  • Social
  • CONTROL
    • Internet of Think (IoT)
    • ESP
      • NodeMcu
      • Lora
      • WeMos
      • Esp 32 Dev
      • Node 32s
    • Arduino
    • Raspberry
    • Proteus
  • MATLAB
    • MATLAB PROJECT
    • PLC
      • Omron
      • Mitsubishi
      • Siemens
      • Schneider
      • ArduinoPLC
    • Arduino
    • Basic & Doc
  • Contact Us

            Arduino Ethernet shiled adalah modul yang menghubungkan arduino ke internet. Ethernet Shield menggunakan Ethernet chip wiznet W5100 menyediakan jaringan (IP) baik untuk TCP maupun UDP dengan menggunakan koneksi standar RJ-45.

            TCP (Transmission Control Protocol) merupakan standard komunikasi data internet. TCP handal dalam komunikasi dengan urutan pesan yang rapi. Sehingga memberikan jaminan pesan terkirim ke penerima. Contoh : Http ,Https, Smtp, POP3, Telnet dll.

            UDP(User Datagram Protocol) merupakan komunikasi yang mementingkan kecepatan data tanpa koneksi antar host dalam suatu jaringan. Contoh Audio Streaming dan video streaming.

            Pada tutorial kali ini Arduino akan membaca input dari sensor DHT22 yang akan mengukur kelembapan dan temperature. Arduino akan dihubungkan dengan Modul Ethernet Shiled agar arduino dapat mengirim data ke komputer melalui kabel Ethernet dan dapat di lihat pada web browser.

Langsung saja rangkai projek sesuai dengan yang di bawah ini :


Sebelum memulai pengujian, maka di perlukan pengaturan ip address komputer agar Ethernet Shield arduino dapat terhubung. Berikut langkah-langkahnya :

-Buka control panel, pilih network and internet.


-Pilih network and sharing center.


 

-klik Ethernet lalu klik propertis

-lalu klik TCP/IPv4

-pilih use the following IP address

-lalu setting IP address sesuai dengan yang di bawah ini




-Setelah itu upload program sesuai dengan yang di bawah ini.

#include "DHT.h"
#define DHTPIN 7
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

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

byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0x23, 0x36
};
IPAddress ip(192,168,10,11);

EthernetServer server(80);

void setup() {

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

dht.begin();

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



void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(t) || isnan(h)){
Serial.println("Failed to read from DHT");}
else{
Serial.print("humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}

// listen for incoming clients
EthernetClient client = server.available();// inisialisasi client
if (client) { // jika ada data yang masuk ke 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(); // client akan membaca data server
Serial.write(c); //menuliskan data c di server
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec

client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");//pembuka program
client.println("<H2>");//heading
client.print("Humidity: ");
client.println("</H2>");//penutup heading
client.println("<p />");//enter
client.println("<H1>");
client.print(h);
client.print(" %\t");
client.println("</H1>");

client.println("<p />");// enter
client.println("<H2>");// pembuka utk menuliskan data
client.print("Temperature: ");
client.println("</H2>");// penutup
client.println("<H1>");
client.print(t);
client.println(" &#176;");//kode derajad
client.print("C");
client.println("</H1>");

client.println("<html>");//penutup program
break;

}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
delay(5000);
}

Lalu copy paste IP Adress sesuai dengan yang tertera di serial monitor.

Dan masukan pada web browser.

Hasilya dapat di lihat seperti di bawah ini.

            Sekian terimakasih semoga bermanfaat dan selamat mencoba.


Watch The Video 




 


 

Newer Posts Older Posts Home





POPULAR POSTS

  • Skema Power Supply Switching SMPS
  • Proteus 8.5 Full Version Professional
  • Tutorial ILI9341 TFT SPI LCD touch Screen
  • Pulse Oxymetry (SPO2) + Raspberry Pi
  • Serial Communication UART Raspberry Pico (SoftSerial)
  • Artificial Neural Network for Identification MATLAB
  • Menampilkan Text Pada LCD 16x2 I2C Arduino

ABOUT ME

cobabaru

Sinau Programming

SUBSCRIBE & FOLLOW

Training


Contact Form

Name

Email *

Message *

Categories

  • alkes 1
  • Android 4
  • Arduino 35
  • Basic & Doc 12
  • centrifuge 1
  • ESP32 8
  • Internet of Things (IoT) 23
  • LCD TFT SPI 2
  • MATLAB 6
  • Metode kendali 1
  • Modul Charger 1
  • Nextion 4
  • NodeMcu 8
  • oled 1
  • Pattern Recognition 2
  • Pemrograman 2
  • Perbaikan 1
  • PID 2
  • PLC HMI VTSCADA ARDUINO 3
  • PRIVACY POLICY 1
  • Proteus 11
  • Python 1
  • raspberry 5
  • Teknik Elektromedik 2
  • Thingsboard 1
  • Video 5
  • Wemos 4

sinau_programming

Sinau Programming Distributed by Sinau Programming