Free Nationwide Doorstep Delivery on orders over ₹499
← All 10 Projects•Advanced•75 mins

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.

Real-World Engineering Application

Urban meteorological stations, airport climate telemetry, smart city pollution monitoring networks.

Physics & Working Principle

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.

Key Learning Outcome:Understand RESTful APIs, HTTP headers, JSON serialization, and cloud data persistence.

Pin Connection & Wiring Table

Component Pin / TerminalMicrocontroller Pin (ESP32 / Arduino)Wiring Note
OLED SDAGPIO 21I2C Data
OLED SCLGPIO 22I2C Clock
DHT11 DATAGPIO 15Single-bus sensor line
All VCC3.3VPower supply rail
All GNDGNDGround rail

Step-by-Step Plug & Play Assembly

1

Connect OLED SDA to GPIO 21 and SCL to GPIO 22.

2

Connect DHT11 DATA to GPIO 15.

3

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
}
Code Logic Breakdown:

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

The local OLED screen displays large temperature and humidity readouts while telemetry packets are dispatched over Wi-Fi.
Troubleshooting Tips
  • •I2C not found: Scan I2C addresses (default is 0x3C or 0x3D). Verify SDA is on GPIO 21 and SCL on GPIO 22.
Electrical Safety Directives
  • •Keep sensor components dry and operate on standard 3.3V-5V DC.
Companion Resources

Related Book Chapter & Hardware Kit

Covered in depth within Chapter 10: Internet-Connected Devices. Build this easily with the IoT Innovator Kit.