Cloud-Connected IoT Weather Station
Publish live temperature and humidity metrics from ESP32 to an IoT cloud broker or HTTP API dashboard in real time.
Urban meteorological stations, airport climate telemetry, smart city pollution monitoring networks.
ESP32 gathers telemetry from DHT11, formats the payload as JSON, and transmits an HTTP POST or MQTT packet over Wi-Fi to a cloud backend for visual time-series graphing.
Pin Connection & Wiring Table
| Component Pin / Terminal | Microcontroller Pin (ESP32 / Arduino) | Wiring Note |
|---|---|---|
| OLED SDA | GPIO 21 | I2C Data |
| OLED SCL | GPIO 22 | I2C Clock |
| DHT11 DATA | GPIO 15 | Single-bus sensor line |
| All VCC | 3.3V | Power supply rail |
| All GND | GND | Ground rail |
Step-by-Step Plug & Play Assembly
Connect OLED SDA to GPIO 21 and SCL to GPIO 22.
Connect DHT11 DATA to GPIO 15.
Configure Wi-Fi SSID and target cloud endpoint in source code.
Complete Tested Source Code
// NovaCircuit Project 8: IoT Weather Station with OLED & Cloud
#include <WiFi.h>
#include <HTTPClient.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
#define DHTPIN 15
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
void setup() {
Serial.begin(115200);
dht.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("
Connected to Cloud Gateway");
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (!isnan(h) && !isnan(t)) {
// Render to Local OLED Display
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.println("NovaCircuit IoT Weather");
display.drawLine(0, 10, 128, 10, WHITE);
display.setTextSize(2);
display.setCursor(0, 20);
display.print(t, 1); display.println(" C");
display.setCursor(0, 42);
display.print(h, 0); display.println(" % RH");
display.display();
// Transmit telemetry to Cloud via HTTP
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("https://api.novacircuits.in/telemetry/demo"); // Example endpoint
http.addHeader("Content-Type", "application/json");
String payload = "{\"temperature\":" + String(t) + ",\"humidity\":" + String(h) + "}";
int httpCode = http.POST(payload);
http.end();
}
}
delay(10000); // Send updates every 10 seconds
}Combines I2C bus display output with cloud HTTP POST requests. The ESP32 formats collected metrics into structured JSON payloads for streaming analytics.
Expected Physical Output
- •I2C not found: Scan I2C addresses (default is 0x3C or 0x3D). Verify SDA is on GPIO 21 and SCL on GPIO 22.
- •Keep sensor components dry and operate on standard 3.3V-5V DC.
Related Book Chapter & Hardware Kit
Covered in depth within Chapter 10: Internet-Connected Devices. Build this easily with the IoT Innovator Kit.