#include "DHTesp.h"

const int DHT_PIN = 9;
DHTesp dhtSensor;

unsigned long lastMsg = 0;
float temp = 0;
float hum = 0;
int value = 0;


void setup() {
  pinMode(2, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}

void loop() {
  unsigned long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    TempAndHumidity  data = dhtSensor.getTempAndHumidity();

    String temp = String(data.temperature, 2);
    Serial.print("Temperature: ");
    Serial.println(temp);
    
    String hum = String(data.humidity, 1);
    Serial.print("Humidity: ");
    Serial.println(hum);
  }
}