Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
52 changes: 52 additions & 0 deletions Domains/IoT/MiniProjects/DHT22+ESP32/code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <DHT.h>
#define dataPin 4
#define DHTTYPE DHT22
#include <WiFi.h>
#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);

}
39 changes: 39 additions & 0 deletions Domains/IoT/MiniProjects/DHT22+ESP32/readme.md
Original file line number Diff line number Diff line change
@@ -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
Loading