diff --git a/Domains/IoT/MiniProjects/DHT22+ESP32/circuit for DHT22+esp32.pdf b/Domains/IoT/MiniProjects/DHT22+ESP32/circuit for DHT22+esp32.pdf new file mode 100644 index 00000000..ebbb71c4 Binary files /dev/null and b/Domains/IoT/MiniProjects/DHT22+ESP32/circuit for DHT22+esp32.pdf differ diff --git a/Domains/IoT/MiniProjects/DHT22+ESP32/code.ino b/Domains/IoT/MiniProjects/DHT22+ESP32/code.ino new file mode 100644 index 00000000..703b59b1 --- /dev/null +++ b/Domains/IoT/MiniProjects/DHT22+ESP32/code.ino @@ -0,0 +1,52 @@ +#include +#define dataPin 4 +#define DHTTYPE DHT22 +#include +#define WIFI_SSID "Wokwi-GUEST" +#define WIFI_PASSWORD "" +#include "ThingSpeak.h" +#define myChannelNumber [Give your channel no u created at thing speak] +#define myWriteAPIKey ["Give your API key"] +unsigned long dataMillis = 0; +int data1; +WiFiClient client; +DHT dht(dataPin , DHTTYPE); + +void setup() { + Serial.begin(115200); + dht.begin(); + // put your setup code here, to run once: + WiFi.begin (WIFI_SSID,WIFI_PASSWORD); + ThingSpeak.begin(client); + + + Serial .print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("-"); + } +} + +void loop() { + data1 = dht.readTemperature(); + + + // put your main code here, to run repeatedly: + ThingSpeak.setField(1, data1); + if (millis() - dataMillis > 20000) + { + Serial.printf("data1 value: %.2f\n", data1); + + int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); + if ( x == 200){ + Serial.println("Channel update successful."); + } + else{ + Serial.println("Problem updating channel. HTTP error code " + String(x)); + } + } + + + delay(200); + +} diff --git a/Domains/IoT/MiniProjects/DHT22+ESP32/readme.md b/Domains/IoT/MiniProjects/DHT22+ESP32/readme.md new file mode 100644 index 00000000..9cb55e46 --- /dev/null +++ b/Domains/IoT/MiniProjects/DHT22+ESP32/readme.md @@ -0,0 +1,39 @@ +# 🌡️ DHT22 Temperature Monitoring with ESP32 & ThingSpeak + +This project connects a **DHT22 temperature sensor** to an **ESP32** and uploads real-time data to **ThingSpeak** over Wi-Fi. +You can visualize the temperature readings online in your ThingSpeak channel dashboard. + +--- + +## 🧠 Project Overview + +The **DHT22 sensor** measures the temperature, and the **ESP32** sends the readings to **ThingSpeak** via the internet every 20 seconds. +This setup is useful for IoT-based environmental monitoring, weather stations, or smart home systems. + +--- + +## ⚙️ Components Required + +- ESP32 board +- DHT22 Sensor +- Jumper Wires +- Breadboard +- Internet connection + +--- + +## 🔌 Circuit Connections + +| DHT22 Pin | ESP32 Pin | +|------------|------------| +| VCC | 3.3V | +| DATA | GPIO 4 | +| GND | GND | + +--- + +Author + +Shirsha Nag + +Contributor