Experiment No. 11
Experiment No. 11
Design and Implementation of HTTP based IoT Web Server to display sensor value
The goal of this experiment is to integrate the HTTP webserver with Sensor. As we know, most
IoT Nodes are equipped with sensors and the IoT systems should provide these sensor data to
users. In this experiment, we used DHT11 Temperature and Humidity sensor connected to an
IoT Node/ ESP32 development board. The IoT Node is configured as a Webserver and the
sensor data can be accessed via a web browser.
CODE:
#include <WiFi.h>
#include <WebServer.h>
#include "DHT.h"
// Uncomment one of the lines below for whatever DHT sensor type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
WebServer server(80);
// DHT Sensor
uint8_t DHTPin = 4;
float Temperature;
float Humidity;
void setup() {
Serial.begin(115200);
delay(100);
pinMode(DHTPin, INPUT);
dht.begin();
Serial.println("Connecting to ");
Serial.println(ssid);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
void handle_OnConnect() {
void handle_NotFound(){
server.send(404, "text/plain", "Not found");
}