/**
   ESP32 + DHT22 Example for Wokwi
   
   https://wokwi.com/arduino/projects/322410731508073042
*/

#include "DHTesp.h"

const int DHT_PIN = 15;
const int ledredPin = 19;
const int ledgreenPin = 18;
const int ledbluePin = 22;

DHTesp dhtSensor;

void setup() {
  Serial.begin(115200);
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
  pinMode(ledredPin, OUTPUT);
  pinMode(ledgreenPin, OUTPUT);
  pinMode(ledbluePin, OUTPUT);
}

void loop() {
  TempAndHumidity  data = dhtSensor.getTempAndHumidity();
  Serial.println("Temp: " + String(data.temperature, 2) + "°C");
  Serial.println("Humidity: " + String(data.humidity, 1) + "%");
  Serial.println("Cold!!");
  Serial.println("--------------------------------------------");
  ctrLEDRGB(0,0,255);
  delay(6000);

  data.temperature = (26.50);
  Serial.println("Temp: " + String(data.temperature, 2) + "°C");
  Serial.println("Humidity: " + String(data.humidity, 1) + "%");
  Serial.println("Warm!!");
  Serial.println("--------------------------------------------");
  ctrLEDRGB(255,109,0);
  delay(6000);

  data.temperature = (33.50);
  Serial.println("Temp: " + String(data.temperature, 2) + "°C");
  Serial.println("Humidity: " + String(data.humidity, 1) + "%");
  Serial.println("HOT!!");
  Serial.println("--------------------------------------------");
  ctrLEDRGB(255,0,0);
  delay(6000);
}

void ctrLEDRGB(int R, int G, int B){
  analogWrite(ledredPin,R);
  analogWrite(ledgreenPin,G);
  analogWrite(ledbluePin,B);
}