- #include <DHT.h>
- #define DHTPIN 7 // Digital pin connected to the DHT sensor
- #define DHTTYPE DHT11 // DHT 11
- DHT dht(DHTPIN, DHTTYPE);
- void setup() {
- Serial.begin(9600);
- dht.begin(); // Initialize DHT sensor
- }
- void loop() {
- delay(2000); // Wait for 2 seconds
- float h = dht.readHumidity(); // Read humidity
- float t = dht.readTemperature(); // Read temperature in Celsius
- if (isnan(h) || isnan(t)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- Serial.print("Humidity: ");
- Serial.print(h);
- Serial.print("% - Temperature: ");
- Serial.print(t);
- Serial.println("°C");
- }
[text] lick
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: