Added ESP32, ESP8266 compatibility

This commit is contained in:
Dhruba Saha 2023-09-20 06:45:14 +05:30
parent 833a45c6ab
commit e69a910c92
4 changed files with 26 additions and 4 deletions

View File

@ -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()

View File

@ -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.

View File

@ -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.

View File

@ -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()