ESP32 and DHT22 HTTP Device

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Posts: 6
Joined: 28 Feb 2015 21:02

ESP32 and DHT22 HTTP Device

Post by Ruffy » 24 Dec 2017 14:31

Dear all,

I have a question about HTTP Devices.

I built with a ESP32 and DHT22 sensor a easy ans cheap humidity and temperature sensor.
It is also possible that ESP sent the data to IP address with GET / POST.

I also can see the data in the browser on the IP address. Here is my code for the ESP.
At the moment I have problems to configure the HTTP Device. I'm really not a expert in programming HTTP /Java script...

Hope you can help me...

// 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("<!DOCTYPE HTML><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<meta http-equiv=\"refresh\" content=\"30\"></head>");
client.println("<body><div style=\"font-size: 3.5rem;\"><p>ESP32 - DHT</p><p>");
client.println("<div style=\"color: #930000;\">");
else if(atoi(celsiusTemp)<25 && atoi(celsiusTemp)>=5){
client.println("<div style=\"color: #006601;\">");
else if(atoi(celsiusTemp)<5){
client.println("<div style=\"color: #009191;\">");

Br, Ruffy

the wife
Posts: 12
Joined: 27 Oct 2015 21:02

Re: ESP32 and DHT22 HTTP Device

Post by the wife » 24 Dec 2017 19:08

Hi Ruffy,

here is my approach. Not sure it is what you are actually looking for, but maybe it will help.

I am using ESP32 based boards from Adafruit and Sweetpeas and TMP 36GT9 temperature sensors. These are configured as HTTP devices in the SmartHome UI.

On the ESP32 side, I use the ESP8266WebServer library to create a simple web server:

// web server
ESP8266WebServer server(80);
server.on("/temperature", handleTemperature);

An HTTP request for the temperature looks like this:

And the ESP32 response is coded as follows:
server.send(200, "text/plain", webString);

In a browser, you will just see the temperature returned.

From the SmartHome UI I setup an HTTP device as follows:


From the SmartHome UI, this results in a device on the dashboard:


The data is updated every 10 minutes. The readings are a little high and I need to revisit the code but for an idea as to how the HTTP side works you can see my code here ... thermo.ino. This code also includes control of RF transmitters which I use for sockets/lamps.

I am using these temp sensors, as well as ZWave temperature sensors as part of my central heating / lighting solution which I occasionally blog about here

Post Reply