Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

error for compiling ESp 32 dev module on arduino ide  #6

Open
@hadjer39

Description

@hadjer39

Hi,
I'm trying to use Higrow esp32 moisture sensor on arduino ide,
I upload this sketch I got this error:
Build options changed, rebuilding all
/home/hadjer/arduino-1.8.5/Arduino/higrow-test/higrow-test.ino:2:17: fatal error: DHT.h: No such file or directory
compilation terminated.
Multiple libraries were found for "WiFi.h"
Used: /home/hadjer/arduino-1.8.5/hardware/espressif/esp32/libraries/WiFi
Not used: /home/hadjer/arduino-1.8.5/libraries/WiFi
exit status 1
Error compiling for board ESP32 Dev Module.

here is the code source :
#include <WiFi.h>
#include "DHT.h"

#define DHTTYPE DHT11

const char* ssid = "Buffalo-G-38D3";
const char* password = "n7pws65ixfb7f";

WiFiServer server(80);

const int DHTPin = 22;
DHT dht(DHTPin, DHTTYPE);

static char celsiusTemp[7];
static char fahrenheitTemp[7];
static char humidityTemp[7];

char linebuf[80];
int charcount=0;

void setup() {

dht.begin();

Serial.begin(115200);
while(!Serial) {
;
}

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while(WiFi.status() != WL_CONNECTED) {

delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFI connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

server.begin();

}

void loop() {

WiFiClient client = server.available();
if (client) {
Serial.println("New client");
memset(linebuf,0,sizeof(linebuf));
charcount=0;

boolean currentLineIsBlank = true;
while (client.connected()) {
  if (client.available()) {
    char c = client.read();
    Serial.write(c);
    linebuf[charcount]=c;
    if (charcount<sizeof(linebuf)-1) charcount++;
    if (c == '\n' && currentLineIsBlank) {

        float h = dht.readHumidity();
        float t = dht.readTemperature();
        float f = dht.readTemperature(true);
        if (isnan(h) || isnan(t) || isnan(f)) {
          Serial.println("Failed to read from DHT sensor!");
          strcpy(celsiusTemp,"Failed");
          strcpy(fahrenheitTemp, "Failed");
          strcpy(humidityTemp, "Failed");
        }
        else{

          float hic = dht.computeHeatIndex(t, h, false);
          dtostrf(hic, 6, 2, celsiusTemp);
          float hif = dht.computeHeatIndex(f, h);
          dtostrf(hif, 6, 2, fahrenheitTemp);
          dtostrf(h, 6, 2, humidityTemp);
        }

        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println("Connection: close");
        client.println();
        client.println("<!DOCTYPE HTML><html><head><meta name=\"viewport\"content=\"width=device-width, initial-serial=1\">");
        client.println("meta http-equiv=\"refresh\" content=\"30\"></head>");
        client.println("<body><div style=\"font-size: 3.5rem;\"><p>ESP32 - DHT</p><p>");
        if(atoi(clesiusTemp)>=25) {
          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:\">");
        }
        client.println(celsiusTemp);
        client.println("*C</p><p>");
        client.println(fahrenheitTemp);
        client.println("*F</p></div><p>");
        client.println(humidityTemp);
        client.println("%</p><p>");
        client.println(analogRead(32));
        client.println("</p></div>");
        client.println("</body></html>");
        break;
    }
    if (c == '\n') {
      currentLineIsBlank = true;
      memset(linebuf,0,sizeof(linebuf));
      charcount=0;
    } else if (c != '\r') {
      currentLineIsBalnk = false;
      
    }
    }

}
delay(1);

client.step();
Serial.println("client disconnected");

}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions