Esp32 dht11/dht22

ESP32 DHT11/DHT22 Asynchronous Web Server (auto updates Temperature and Humidity) with led that It turns on when we click on a button in the applicaition

When I compile the code it’s success but when I upload it to the esp32 it give me this problem

The circuit of my project:
is connecting esp32 with sensor for tempreture DHT11 and connecting esp32 with led that should work by Blynk App.
I connet the output pin in the sensor with pin27 and (-) with ground and (+) with vcc (5volt)
And I connect the led with resistance
I connect the resistancewith ground and output(pin15)
And all of them connect with esp32

This is The code:

#include <WiFi.h>
#include "ESPAsyncWebServer.h"

const char* WIFI_NAME= "Anwar";  
const char* WIFI_PASSWORD = "12345678";  
WiFiServer server(80);

String header;

String LED_ONE_STATE = "off";
String LED_TWO_STATE = "off";
String LED_THREE_STATE = "off";
const int GPIO_PIN_NUMBER_22 = 22;
//const int GPIO_PIN_NUMBER_23 = 23;
//const int GPIO_PIN_NUMBER_15 = 15;


void setup() {
  Serial.begin(115200);
  pinMode(GPIO_PIN_NUMBER_22, OUTPUT);
  digitalWrite(GPIO_PIN_NUMBER_22, LOW);
  Serial.print("Connecting to ");
  Serial.println(WIFI_NAME);
  WiFi.begin(WIFI_NAME, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print("Trying to connect to Wifi Network");
  }
  Serial.println("");
  Serial.println("Successfully connected to WiFi network");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
}
void loop(){
  WiFiClient client = server.available();   
  if (client) {                            
    Serial.println("New Client is requesting web page");          
    String current_data_line = "";               
    while (client.connected()) {            
      if (client.available()) {             
        char new_byte = client.read();             
        Serial.write(new_byte);                    
        header += new_byte;
        if (new_byte == '\n') {                    
         
          if (current_data_line.length() == 0) 
          {
            
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();
            
            if (header.indexOf("LED0=ON") != -1) 
            {
              Serial.println("GPIO23 LED is ON");
              LED_ONE_STATE = "on";
              digitalWrite(GPIO_PIN_NUMBER_22 , HIGH);
            } 
            if (header.indexOf("LED0=OFF") != -1) 
            {
              Serial.println("GPIO23 LED is OFF");
              LED_ONE_STATE = "off";
              digitalWrite(GPIO_PIN_NUMBER_22, LOW);
            } 
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
            client.println(".button { background-color: #4CAF50; border: 2px solid #4CAF50;; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; }");
            client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");            
            // Web Page Heading
            client.println("</style></head>");
            client.println("<body><center><h1>ESP32 Web server LED controlling example</h1></center>");
            client.println("<center><h2>Web Server Example Microcontrollerslab.com</h2></center>" );
            client.println("<center><h2>Press on button to turn on led and off button to turn off LED</h3></center>");
            client.println("<form><center>");
            client.println("<p> LED one is " + LED_ONE_STATE + "</p>");
            // If the PIN_NUMBER_22State is off, it displays the ON button      
             client.println("<center> <button class=\"button\" name=\"LED0\" value=\"ON\" type=\"submit\">LED0 Off</button>") ;
             client.println("<button class=\"button\" name=\"LED0\" value=\"OFF\" type=\"submit\">LED0 ON</button><br><br>");
            client.println("</center></form></body></html>");
            client.println();
            break;
          } 
          else 
          { 
            current_data_line = "";
          }
        } 
        else if (new_byte != '\r') 
        {  
          current_data_line += new_byte;     
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }
}

Hi,

First thing you need to do is clean up your void loop() … .

Second, some ESP32 dev boards have a ‘boot’ button on the board, you need to press and hold the boot button when you hit compile, keep holding it until upload starts.

have you been able to upload basic blink sketch to the ESP32 as a test?

cul
billd

@ShoSha I don’t know what the connection is between you and @Anwar_A_Shanaa but you’ve both posted the same code, which has nothing at all to do with Blynk.

Can you explain the logic behind this, or should I just close both of your topics and delete your Blynk community accounts?

Pete.

Yes, We are working together on the same project
I will delete my topic