I am trying a project from Random Nerd Tutorials which involves using 2 x ESP32's in a Client/Server mode. The project calls for a BME280 Sensor which I do not have so I am attempting to substitute a DHT11 Sensor.
I have come unstuck with the code and have an Error Message which I do not understand (Im completely new at the programming).
This is a copy of the error message I am getting, can anyone please assist and possibly comment if I have made the substitution of the DHT11 correctly.
Arduino: 1.8.19 (Mac OS X), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
/Users/melchiorrabie/Documents/Arduino/Mel_Client_Server_ver1/Mel_Client_Server_ver1.ino: In function 'void setup()':
Mel_Client_Server_ver1:67:10: error: void value not ignored as it ought to be
status = dht_sensor.begin(0x76);
^
Multiple libraries were found for "WiFi.h"
Used: /Users/melchiorrabie/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/WiFi
Not used: /Users/melchiorrabie/Desktop/Arduino.app/Contents/Java/libraries/WiFi
exit status 1
void value not ignored as it ought to be
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
or paste code here
[code]
/*
Rui Santos
Complete project details at https://RandomNerdTutorials.com/esp32-client-server-wi-fi/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
// Import required libraries
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include <DHT.h>
#define DHT_SENSOR_PIN 27 // ESP32 pin GIOP27 connected to DHT11 sensor
#define DHT_SENSOR_TYPE DHT11
DHT dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE);
// Set your access point network credentials
const char* ssid = "ESP32-Access-Point";
const char* password = "123456789";
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
String readTemp() {
return String(dht_sensor.readTemperature());
//return String(1.8 * DHT.readTemperature() + 32);
}
String readHumi() {
return String(dht_sensor.readHumidity());
}
void setup() {
// Serial port for debugging purposes
Serial.begin(115200);
Serial.println();
// Setting the ESP as an access point
Serial.print("Setting AP (Access Point)…");
// Remove the password parameter, if you want the AP (Access Point) to be open
WiFi.softAP(ssid, password);
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(IP);
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send_P(200, "text/plain", readTemp().c_str());
});
server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send_P(200, "text/plain", readHumi().c_str());
});
bool status;
// default settings
// (you can also pass in a Wire library object like &Wire2)
status = dht_sensor.begin(0x76);
if (!status) {
Serial.println("Could not find a valid DHT11 sensor, check wiring!");
while (1);
}
// Start server
server.begin();
}
void loop() {
}
[/code]