/**
IoT Ecosystem Exercise for Temperature & Huminity Monitoring System for Wokwi
- Sensor: DHT22
- Actuators: LED, LCD
- Computing: ESP32
- Connectivity: WiFi, I2C, HTTP
- IoT Platform: ThingSpeak https://thingspeak.com/
*/
#include "DHTesp.h"
//**TODO***//
// Include the required libraries
// GPIOs
//*************Sensors
const int DHT_PIN = 15; // Pin number to which the DHT22 sensor is connected
//*************Actuators
//**TODO***//
// Define your actuators (led)
// CONNECTIVITY
//*************I2C connection
//**TODO***//
// Define I2C for LCD
//*************WiFi connection
//**TODO***//
//Define WiFi credentials required for connecting to a public gateway. (Check https://docs.wokwi.com/guides/esp32-wifi)
//************* ThingSpeak connection
//**TODO***//
//Define the parameters for connecting to the ThingSpeak IoT platform (Googlee to find how to do it!)
//*************Objects creation & variables definition
DHTesp dhtSensor; // Create an instance of the DHTesp library
//**TODO***//
// Create the required objects
void setup() {
Serial.begin(115200); // Initialize the serial communication at a baud rate of 115200
dhtSensor.setup(DHT_PIN, DHTesp::DHT22); // Initialize the DHT22 sensor
//**TODO***//
// Pin configuration
// Create a LCD initialization
// Create a WiFi Connection initialization
// Create a ThinkSpeak Connection initialization
}
void loop() {
// Reading from DHT22 sensor
TempAndHumidity data = dhtSensor.getTempAndHumidity(); // Read temperature and humidity from the DHT22 sensor
// Storing current temperature & huminity values
float temp = data.temperature;
float hum = data.humidity;
// Printing values in the serial monitor
Serial.println("Temp: " + String(data.temperature, 2) + "°C"); // Print the temperature value with 2 decimal places
Serial.println("Humidity: " + String(data.humidity, 1) + "%"); // Print the humidity value with 1 decimal place
//**TODO***//
// --Logic to activate an alert using an LED actuator if the temperature surpasses the threshold of 40°C or if the humidity falls below the 20% threshold.
// --Logic to display the current temperature and humidity values on the LCD screen.
// --Logic to update sensor readings on ThingSpeak at regular intervals.
delay(10000); // Delay for 10 seconds
}