0% found this document useful (0 votes)
37 views

IoT - 20 - HTTP

The document discusses HTTP (Hypertext Transfer Protocol) and its use in Internet of Things applications. It covers HTTP overview and components like request and response methods, messages, and headers. It also discusses HTTPS, cookies, and provides examples of creating an HTTP web server on ESP32 and connecting to ThingSpeak. The document aims to teach attendees about HTTP communication for IoT projects.

Uploaded by

adnan Adnan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

IoT - 20 - HTTP

The document discusses HTTP (Hypertext Transfer Protocol) and its use in Internet of Things applications. It covers HTTP overview and components like request and response methods, messages, and headers. It also discusses HTTPS, cookies, and provides examples of creating an HTTP web server on ESP32 and connecting to ThingSpeak. The document aims to teach attendees about HTTP communication for IoT projects.

Uploaded by

adnan Adnan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

LOGO

UNIV/POLTEK

DTS 2019
Internet of Things
20 HTTP

digitalent.kominfo.go.id
digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Topik Bahasan
• Overview
• Communication Chain
• Request method
• Request message
• Request header
• Response message
• Response header
• Status code
• HTTPS
• Cookie

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Praktek
• Membuat Web server di ESP32
• Menggunakan ThingSpeak
• Membuat koneksi ke ThingSpeak

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Overview
• HTTP kependekan dari Hyper Text Transfer Protocol
• HTTP merupakan Stateless Protocol

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Overview

HTTP berada pada application layer


digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Communication Chain

Client (web browser) mengirimkan HTTP request


lalu server (web server) membalas dengan mengirimkan HTTP
response

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Request Method
• GET
• POST
• HEAD
• OPTIONS
• PUT
• DELETE
• TRACE
• CONNECT

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Request Message

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Request Header
• Accept
• Accept-Charset
• Accept-Encoding
• Accept-Language
• Host
• User-Agent
• Cookie
• Content-Length
• Referer

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Response Message

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Response Header
• Date
• Server
• Last-Modified
• Expires
• Refresh
• Content-Length
• Content-Type
• Accept-Ranges

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Status Code
• 1xx - informational
• 2xx - success
• 200 - OK
• 3xx - redirection
• 301 - move permanently
• 304 - not modified
• 4xx - client error
• 403 - forbidden
• 5xx - server error

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

HTTPS
• Hyper Text Transfer Protocol Secure
• End to end encryption
• Menggunakan TLS atau SSL

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Cookie

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Praktek

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Membuat Web server di ESP32


#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>

const char* ssid = "........";


const char* password = "........";

WebServer server(80);

void handleRoot() {
server.send(200, "text/plain", "hello from esp!");
}

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Membuat Web server di ESP32


void handleNotFound() {
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Membuat Web server di ESP32


void setup(void) {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
}
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

if (MDNS.begin("esp32")) {
Serial.println("MDNS responder started");
}

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Membuat Web server di ESP32


server.on("/", handleRoot);
server.on("/inline", []() {
server.send(200, "text/plain", "this works as well");
});

server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}

void loop(void) {
server.handleClient();
}

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

• https://www.youtube.com/watch?v=2XH1bTWkWIE
• https://www.youtube.com/watch?v=AK4Lp1Ko0l8
• https://www.youtube.com/watch?v=XI_2eypZDwc

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

Menggunakan ThinkSpeak

digitalent.kominfo.go.id
LOGO
UNIV/POLTEK

IKUTI KAMI

digitalent.kominfo
digitalent.kominfo
DTS_kominfo
Digital Talent Scholarship 2019

Pusat Pengembangan Profesi dan Sertifikasi


Badan Penelitian dan Pengembangan SDM
Kementerian Komunikasi dan Informatika
Jl. Medan Merdeka Barat No. 9
(Gd. Belakang Lt. 4 - 5)
Jakarta Pusat, 10110

digitalent.kominfo.go.id
digitalent.kominfo.go.id

You might also like