Closed Nehessy closed 3 years ago
hi your code isnt using this driver at all. if you need project help - post in adafruit forums or some other project support forum.
This is the arduino code:
Adafruit_BMP085 bmp;
const char ssid = "iPhone de Mouya"; const char password = "1234567890";
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>
Temperature %TEMPERATURE% °C
Humidite %HUMIDITY% %
Pression %PRESSURE% Pa
)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(){
}
Hi, I am doing a final year project which is a weather station Web with DHT22 sensor for temperature and humidity and pressure with BMP180 sensor all on the Huzzah ESP32 I need help because when a client connects to the server the monitor shows this error and the ESP32 restarts:
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...
If you could help me because it is very urgent please.