Hi all,
I'm having some problem using both DHT11 temperature sensor and a WiFi connection.
If I try to run following code the sketch works fine but when I try to run inside another sketch that is using a WiFi connection I can't read temperature anymore. The sketch with WiFi connection works fine capturing some voltage from 4 potentiometer and sends the values to a MQTT server.
I tried different GPIOs but the result is always the same.
Many thanks
//
#include "DHT.h"
#define DHTPIN 16 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}
Problem using DHT11 sensor with WiFi
-
- Posts: 101
- Joined: Tue Mar 22, 2022 5:23 am
Re: Problem using DHT11 sensor with WiFi
As you're facing issues with DHT11, I think this tutorial will help you: https://www.theengineeringprojects.com/ ... erver.html
This tutorial is based on ESP32. It shows how to interface DHT11 with ESP32. It also shows how to share the sensor readings obtained from the DHT11 sensor to a web server.
This tutorial is based on ESP32. It shows how to interface DHT11 with ESP32. It also shows how to share the sensor readings obtained from the DHT11 sensor to a web server.
Who is online
Users browsing this forum: Usama Masood and 91 guests