Bonjour, je fais un projet de fin d'études qui est une station météo Web avec un capteur DHT22 pour la température et l'humidité et une pression avec un capteur BMP180, le tout sur le Huzzah ESP32. J'ai besoin d'aide car lorsqu'un client se connecte au serveur, le moniteur affiche cette erreur et l'ESP32 redémarre :
Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.
Core 1 register dump:
PC : 0x40147ec1 PS : 0x00060830 A0 : 0x800d1430 A1 : 0x3ffcf740
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000002 A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00000000 A9 : 0x3ffcf720
A10 : 0x00ffffff A11 : 0x000000f8 A12 : 0x3ffc18b0 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000005 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x40147ec1:0x3ffcf740 0x400d142d:0x3ffcf760 0x400d0c7a:0x3ffcf780 0x400d0d03:0x3ffcf7b0 0x40147d4d:0x3ffcf7d0 0x400d6858:0x3ffcf7f0 0x400d6ae1:0x3ffcf880 0x400d56fa:0x3ffcf8d0 0x400d423a:0x3ffcf910 0x400d4c41:0x3ffcf950 0x400d0a4f:0x3ffcf990 0x400d6f29:0x3ffcf9d0 0x400d4e05:0x3ffcfa20 0x400d4ec9:0x3ffcfa60 0x400d5119:0x3ffcfab0 0x400d7fa5:0x3ffcfad0 0x400d8021:0x3ffcfb10 0x400d85fe:0x3ffcfb30 0x4008a02e:0x3ffcfb60
Rebooting...
Voici mon code Arduino:
Si vous pouviez m'aider, c'est vraiment urgent pour mon diplôme.Code:#include <Wire.h> #include <Adafruit_BMP085.h> #include "WiFi.h" #include "ESPAsyncWebServer.h" #include <Adafruit_Sensor.h> #include <DHT.h> Adafruit_BMP085 bmp; const char* ssid = "iPhone de Mouya"; const char* password = "1234567890"; #define DHTPIN 27 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); AsyncWebServer server(80); String readDHTTemperature() { float t = dht.readTemperature(); if (isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return "--"; } else { Serial.println(t); return String(t); } } String readDHTHumidity() { float h = dht.readHumidity(); if (isnan(h)) { Serial.println("Failed to read from DHT sensor!"); return "--"; } else { Serial.println(h); return String(h); } } String readBMPPressure() { float p = bmp.readPressure(); if (isnan(p)) { Serial.println("Failed to read from BMP180 sensor!"); return "--"; } else { Serial.println(p); return String(p); } } const char index_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML><html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"> <style> html { font-family: Arial; display: inline-block; margin: 0px auto; text-align: center; } h2 { font-size: 3.0rem; } p { font-size: 3.0rem; } .units { font-size: 1.2rem; } .dht-labels{ font-size: 1.5rem; vertical-align:middle; padding-bottom: 15px; } </style> </head> <body> <h2>Raspidomo</h2> <p> <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> <span class="dht-labels">Temperature</span> <span id="temperature">%TEMPERATURE%</span> <sup class="units">°C</sup> </p> <p> <i class="fas fa-tint" style="color:#00add6;"></i> <span class="dht-labels">Humidite</span> <span id="humidity">%HUMIDITY%</span> <sup class="units">%</sup> </p> <p> <i class="fas fa-parking"></i> <span class="dht-labels">Pression</span> <span id="pressure">%PRESSURE%</span> <sup class="units">Pa</sup> </p> </body> <script> setInterval(function ( ) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("temperature").innerHTML = this.responseText; } }; xhttp.open("GET", "/temperature", true); xhttp.send(); }, 10000 ) ; setInterval(function ( ) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("humidity").innerHTML = this.responseText; } }; xhttp.open("GET", "/humidity", true); xhttp.send(); }, 10000 ) ; </script> </html>)rawliteral"; // Replaces placeholder with DHT values String processor(const String& var){ //Serial.println(var); if(var == "TEMPERATURE"){ return readDHTTemperature(); } else if(var == "HUMIDITY"){ return readDHTHumidity(); } else if(var == "PRESSURE"){ return readBMPPressure(); } return String(); } void setup(){ // Serial port for debugging purposes Serial.begin(115200); dht.begin(); bmp.begin(); // Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } // Print ESP32 Local IP Address Serial.println(WiFi.localIP()); // Route for root / web page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); }); server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readDHTTemperature().c_str()); }); server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readDHTHumidity().c_str()); }); server.on("/pressure", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readBMPPressure().c_str()); }); // Start server server.begin(); } void loop(){ }
-----