From 043753df160824c355b448d7efe751e8d8e4b9a2 Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 15 Mar 2023 02:47:49 +0100 Subject: [PATCH] Implement basic temperature and humidity sensor --- src/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b42e50d..3b6e1f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,20 @@ #include #include -void setup() { Serial.begin(9600); } +#define DHTTYPE DHT11 +#define DHTPIN 4 + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + dht.begin(); +} void loop() { - Serial.println("Sup dude"); - delay(1000); + char buffer[100]; + sprintf(buffer, "Temperature: %.2f °C Humidity: %.2f %%", + dht.readTemperature(), dht.readHumidity()); + Serial.println(buffer); + delay(60000); }