Skip to content

Instantly share code, notes, and snippets.

@bkrajendra
Created May 10, 2026 06:01
Show Gist options
  • Select an option

  • Save bkrajendra/a8f847fc2b4803cae28d5992c6d24fce to your computer and use it in GitHub Desktop.

Select an option

Save bkrajendra/a8f847fc2b4803cae28d5992c6d24fce to your computer and use it in GitHub Desktop.
dht
#include <DHT.h>
#define DHTPIN 15
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float t = dht.readTemperature();
float h = dht.readHumidity();
if (isnan(t) || isnan(h)) {
Serial.println("Sensor error");
} else {
Serial.printf("T=%.1f°C RH=%.1f%%\n", t, h);
}
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment