Circuit Diagram:
Digital Weather Station: Arduino UNO with DHT22 and I2C OLED Display
In this project, we design an environmental telemetry node using an Arduino UNO microcontroller. The system reads real-time ambient data streams from a high-precision DHT22 Sensor and processes the metrics to render responsive readouts on an SSD1306 128x64 I2C OLED display panel.
Data Acquisition & Display Architecture
The firmware samples physical changes from the digital data bus, executes structural error checks, and maps the output matrix directly to the I2C display interface:
Hardware Interconnection Pinout
Wire the physical modules together on your breadboard according to this accurate electrical bus routing index:
| Peripherals Layer | Module Pin Connection | Target Processing Pin (Arduino UNO) | Signal Bus Purpose |
|---|---|---|---|
| DHT22 Sensor | VCC Pin | 5V Power Rail | System Power Supply Line |
| DHT22 Sensor | SDA / DATA Pin | Digital Pin 2 | Single-wire Digital Stream Link |
| DHT22 Sensor | GND Pin | GND Power Rail | Common Circuit Ground Reference |
| SSD1306 OLED | VCC Pin | 5V Power Rail | Display Driver Logic VCC |
| SSD1306 OLED | GND Pin | GND Power Rail | Common Circuit Ground Reference |
| SSD1306 OLED | SCL Pin | Analog Pin A5 (or Ded. SCL) | I2C Synchronous Clock Line |
| SSD1306 OLED | SDA Pin | Analog Pin A4 (or Ded. SDA) | I2C Data Line Allocation Channel |
System Diagnostics Checklist
- I2C Hardware Mapping: Ensure your display responds correctly on address
0x3C. If your display remains blank during operation, verify that the SDA and SCL signal pins are not cross-wired. - Fault Intercept Protocol: If the sensor loses contact or power, the integrated
isnan()functions automatically trigger an error state on your display panel to safeguard real-time observation telemetry.
Source Firmware Application
Review the complete source code architecture structured inside this syntax highlighting panel with quick copy capabilities:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
// OLED Display Settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// DHT22 Settings
#define DHTPIN 2 // Connect DHT22 Data pin to Digital Pin 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
// Initialize DHT sensor
dht.begin();
// Initialize OLED (Retained from your program)
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.setTextColor(WHITE);
display.display();
}
void loop() {
// DHT22 requires a 2-second delay between readings for accuracy
delay(2000);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // Celsius
// Error handling: if sensor is disconnected or failing
if (isnan(humidity) || isnan(temperature)) {
display.clearDisplay();
display.setCursor(0, 10);
display.setTextSize(1);
display.println("Sensor Error!");
display.display();
return;
}
// Update Display
display.clearDisplay();
// Draw a simple border for a technical look
display.drawRect(0, 0, 128, 64, WHITE);
// Temperature Display
display.setTextSize(1);
display.setCursor(10, 10);
display.print("TEMPERATURE");
display.setTextSize(2);
display.setCursor(10, 22);
display.print(temperature, 1); // 1 decimal place
display.print(" C");
// Humidity Display
display.setTextSize(1);
display.setCursor(10, 42);
display.print("HUMIDITY");
display.setTextSize(2);
display.setCursor(10, 52);
display.print(humidity, 1);
display.print(" %");
display.display();
}
Interactive Project Environment
Launch the virtual hardware workspace below to interact with the project parameters, alter local values, and trace the processing execution lines directly within your browser:
Run the Project Simulation
Click the button below to test the active Arduino code layout and adjust environmental parameters in the live simulation environment.
🌐 Open Live Wokwi Simulation📺 PROJECT VIDEO DEMONSTRATION
Watch the step-by-step setup walkthrough and live hardware integration tests in action:

0 Comments