-40C to 80C
-40C to 80C
0-100% RH
1C (temperature), 5% RH (humidity)
Conclusion
The ESP-01S DHT11 Temperature Humidity Sensor Module is a versatile and powerful IoT module that combines Wi-Fi capabilities, a microcontroller, and a temperature and humidity sensor in a compact package. Its low power consumption, compact design, and ease of use make it an ideal choice for a wide range of applications, including environmental monitoring, home automation, industrial automation, and IoT projects.
ESP-01S DHT11 Temperature Humidity Sensor Module DocumentationOverviewThe ESP-01S DHT11 Temperature Humidity Sensor Module is a versatile and compact IoT component that integrates a DHT11 temperature and humidity sensor with an ESP-01S Wi-Fi module. This module allows for easy measurement of temperature and humidity levels and wirelessly transmits the data to a connected device.Technical SpecificationsDHT11 Temperature and Humidity Sensor:
+ Temperature range: 0C to 50C
+ Humidity range: 20% to 80% RH
+ Accuracy: 2C (temperature), 5% RH (humidity)
ESP-01S Wi-Fi Module:
+ Wi-Fi protocol: 802.11 b/g/n
+ Frequency: 2.4 GHz
+ Data rate: up to 150 MbpsConnecting the ModuleTo connect the ESP-01S DHT11 module, follow these steps:1. Connect the VCC pin to a 3.3V power source.
2. Connect the GND pin to a ground pin.
3. Connect the RX pin to the TX pin of your serial communication device (e.g., serial monitor).
4. Connect the TX pin to the RX pin of your serial communication device.
5. Connect the DHT11 sensor pins to the corresponding pins on the ESP-01S module.Code Examples### Example 1: Basic Temperature and Humidity ReadingsThis example demonstrates how to read temperature and humidity values from the DHT11 sensor and print them to the serial monitor using the Arduino IDE.
```c
#include <DHT.h>#define DHT_PIN 2 // DHT11 sensor pin connected to ESP-01S pin 2DHT dht(DHT_PIN, DHT11);void setup() {
Serial.begin(115200);
dht.begin();
}void loop() {
int temperature = dht.readTemperature();
int humidity = dht.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" % RH");
delay(2000);
}
```
### Example 2: Wi-Fi Connected Temperature and Humidity MonitoringThis example demonstrates how to connect the ESP-01S module to a Wi-Fi network and send temperature and humidity readings to a remote server using the ESP8266 core library.
```c
#include <WiFi.h>
#include <DHT.h>#define DHT_PIN 2 // DHT11 sensor pin connected to ESP-01S pin 2
#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PASSWORD "your_wifi_password"
#define SERVER_URL "http://example.com/temperaturehumidity"DHT dht(DHT_PIN, DHT11);WiFiClient client;void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println("Initializing HTTP client...");
}void loop() {
int temperature = dht.readTemperature();
int humidity = dht.readHumidity();
String httpRequest = "GET " + String(SERVER_URL) + "?temperature=" + String(temperature) + "&humidity=" + String(humidity) + " HTTP/1.1
";
httpRequest += "Host: " + String(SERVER_URL) + "
";
httpRequest += "Connection: close
";
client.print(httpRequest);
delay(2000);
}
```
### Example 3: MQTT-Based Temperature and Humidity Monitoring (Optional)This example demonstrates how to connect the ESP-01S module to an MQTT broker and publish temperature and humidity readings as MQTT messages using the PubSubClient library.
```c
#include <WiFi.h>
#include <DHT.h>
#include <PubSubClient.h>#define DHT_PIN 2 // DHT11 sensor pin connected to ESP-01S pin 2
#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PASSWORD "your_wifi_password"
#define MQTT_BROKER "mqtt://example.com:1883"
#define MQTT_TOPIC "temperaturehumidity"DHT dht(DHT_PIN, DHT11);WiFiClient espClient;
PubSubClient client(espClient);void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println("Initializing MQTT client...");
client.setServer(MQTT_BROKER, 1883);
}void loop() {
int temperature = dht.readTemperature();
int humidity = dht.readHumidity();
char temperatureBuffer[10];
char humidityBuffer[10];
dtostrf(temperature, 6, 2, temperatureBuffer);
dtostrf(humidity, 6, 2, humidityBuffer);
client.publish(MQTT_TOPIC, ("Temperature: " + String(temperatureBuffer) + " C, Humidity: " + String(humidityBuffer) + " % RH").c_str());
delay(2000);
}
```
Note: In this example, you need to replace the placeholders with your actual Wi-Fi SSID, password, MQTT broker URL, and topic.