mirror of
https://github.com/dhrubasaha08/DHT11.git
synced 2023-10-23 22:17:45 +03:00
Added ESP32, ESP8266 compatibility
This commit is contained in:
parent
833a45c6ab
commit
e69a910c92
@ -11,7 +11,10 @@
|
||||
// Include the DHT11 library for interfacing with the sensor.
|
||||
#include <DHT11.h>
|
||||
|
||||
// Create an instance of the DHT11 class. The sensor is connected to digital I/O pin 2.
|
||||
// Create an instance of the DHT11 class.
|
||||
// - For Arduino: Connect the sensor to Digital I/O Pin 2.
|
||||
// - For ESP32: Connect the sensor to pin GPIO2 or P2.
|
||||
// - For ESP8266: Connect the sensor to GPIO2 or D4.
|
||||
DHT11 dht11(2);
|
||||
|
||||
void setup()
|
||||
|
@ -10,7 +10,10 @@
|
||||
// Include the DHT11 library for interfacing with the sensor.
|
||||
#include <DHT11.h>
|
||||
|
||||
// Create an instance of the DHT11 class. The sensor is connected to digital I/O pin 2.
|
||||
// Create an instance of the DHT11 class.
|
||||
// - For Arduino: Connect the sensor to Digital I/O Pin 2.
|
||||
// - For ESP32: Connect the sensor to pin GPIO2 or P2.
|
||||
// - For ESP8266: Connect the sensor to GPIO2 or D4.
|
||||
DHT11 dht11(2);
|
||||
|
||||
void setup()
|
||||
@ -24,6 +27,11 @@ void loop()
|
||||
{
|
||||
// Attempt to read the temperature and humidity values from the DHT11 sensor.
|
||||
int temperature = dht11.readTemperature();
|
||||
|
||||
// If using ESP32 or ESP8266 (xtensa architecture), uncomment the delay below.
|
||||
// This ensures stable readings when calling methods consecutively.
|
||||
// delay(50);
|
||||
|
||||
int humidity = dht11.readHumidity();
|
||||
|
||||
// Check the results of the readings.
|
||||
|
@ -11,7 +11,10 @@
|
||||
// Include the DHT11 library for interfacing with the sensor.
|
||||
#include <DHT11.h>
|
||||
|
||||
// Create an instance of the DHT11 class. The sensor is connected to digital I/O pin 2.
|
||||
// Create an instance of the DHT11 class.
|
||||
// - For Arduino: Connect the sensor to Digital I/O Pin 2.
|
||||
// - For ESP32: Connect the sensor to pin GPIO2 or P2.
|
||||
// - For ESP8266: Connect the sensor to GPIO2 or D4.
|
||||
DHT11 dht11(2);
|
||||
|
||||
void setup()
|
||||
@ -25,6 +28,11 @@ void loop()
|
||||
{
|
||||
// Attempt to read the temperature and humidity values from the DHT11 sensor.
|
||||
int temperature = dht11.readTemperature();
|
||||
|
||||
// If using ESP32 or ESP8266 (xtensa architecture), uncomment the delay below.
|
||||
// This ensures stable readings when calling methods consecutively.
|
||||
// delay(50);
|
||||
|
||||
int humidity = dht11.readHumidity();
|
||||
|
||||
// Check the results of the readings.
|
||||
|
@ -11,7 +11,10 @@
|
||||
// Include the DHT11 library for interfacing with the sensor.
|
||||
#include <DHT11.h>
|
||||
|
||||
// Create an instance of the DHT11 class. The sensor is connected to digital I/O pin 2.
|
||||
// Create an instance of the DHT11 class.
|
||||
// - For Arduino: Connect the sensor to Digital I/O Pin 2.
|
||||
// - For ESP32: Connect the sensor to pin GPIO2 or P2.
|
||||
// - For ESP8266: Connect the sensor to GPIO2 or D4.
|
||||
DHT11 dht11(2);
|
||||
|
||||
void setup()
|
||||
|
Loading…
Reference in New Issue
Block a user