🌑️ Room Temperature & Humidity Monitor Using Arduino, OLED & DHT Sensor

by Jhuman in Circuits > Arduino

5 Views, 0 Favorites, 0 Comments

🌑️ Room Temperature & Humidity Monitor Using Arduino, OLED & DHT Sensor

Snapshot.PNG

This Instructables guide shows you how to build a Room Temperature and Humidity Monitor Device using Arduino, a DHT sensor, and a 0.96” OLED display. This is a perfect beginner-friendly project for learning sensors, displays, and real-time environmental monitoring.

Supplies

Electronic Parts

  1. Arduino Uno / Nano
  2. DHT11 Temperature & Humidity Sensor
  3. 0.96" OLED Display (SSD1306, I2C)
  4. Jumper wires
  5. Breadboard
  6. USB cable

What You Will Make

In this project, you will make a compact digital device that:

  1. Measures room temperature (Β°C)
  2. Measures humidity (%)
  3. Displays values clearly on an OLED screen
  4. Updates readings automatically every few seconds

This project is ideal for:

  1. Home room monitoring
  2. Electronics beginners
  3. School & college projects
  4. DIY & STEM learning


Understanding the Circuit

Screenshot 2026-01-03 195209.png

Discover Easy, Affordable, and Reliable PCB manufacturing with JLCPCB!Register to get $70 New customer coupons:https://jlcpcb.com/?from=EST Special Deal: Get a $30 coupon for JLCPCB premium 6-layer PCBs: https://jlcpcb.com/6-layer-pcb?from=getcoupon


πŸ”Œ Power Connections

  1. Arduino provides 5V power to both the OLED and DHT sensor
  2. All GND pins must be connected together


πŸ–₯️ OLED Display (SSD1306 – I2C)

The OLED display shows temperature and humidity data.

Connections:

  1. VCC β†’ 5V
  2. GND β†’ GND
  3. SDA β†’ SDA (A4 on Uno/Nano)
  4. SCL β†’ SCL (A5 on Uno/Nano)


Why I2C OLED?

  1. Uses only 2 data wires
  2. Saves Arduino pins
  3. Fast communication


🌑️ DHT11 Sensor Connection

The DHT sensor measures temperature and humidity digitally.

Connections:

  1. VCC β†’ 5V
  2. GND β†’ GND
  3. DATA β†’ Digital Pin D2

The sensor internally sends calibrated digital data, so no ADC conversion is needed.


This setup reads temperature and humidity data using a DHT11 sensor and displays it on an OLED screen, all controlled by an Arduino Uno.


βš™οΈ Arduino Uno

β€’ Acts as the central controller

β€’ Reads data from DHT11 via digital pin 2

β€’ Sends display commands to OLED via I2C (A4/A5)


🧠 How It Works

1. Arduino powers up and initializes both the DHT11 and OLED.

2. It reads temperature and humidity from the DHT11.

3. It formats the data and sends it to the OLED screen.

4. The OLED displays the values in real-time.




Install Required Libraries

Open Arduino IDE β†’ Library Manager and install:

  1. Adafruit GFX Library
  2. Adafruit SSD1306 Library
  3. Adafruit Unified Sensor
  4. DHT Sensor Library

These libraries simplify OLED graphics and DHT sensor communication.

Upload the Arduino Code

  1. Connect Arduino to PC
  2. Select correct Board and COM Port
  3. Upload the provided code
  4. OLED screen should turn ON after upload

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <Adafruit_Sensor.h>

#include <DHT.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels


// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);


#define DHTPIN 2 // Digital pin connected to the DHT sensor


// Uncomment the type of sensor in use:

#define DHTTYPE DHT11 // DHT 11

//#define DHTTYPE DHT22 // DHT 22 (AM2302)

//#define DHTTYPE DHT21 // DHT 21 (AM2301)


DHT dht(DHTPIN, DHTTYPE);


void setup() {

Serial.begin(115200);


dht.begin();


if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

Serial.println(F("SSD1306 allocation failed"));

for(;;);

}

delay(2000);

display.clearDisplay();

display.setTextColor(WHITE);

}


void loop() {

delay(5000);


//read temperature and humidity

float t = dht.readTemperature();

float h = dht.readHumidity();

if (isnan(h) || isnan(t)) {

Serial.println("Failed to read from DHT sensor!");

}


//clear display

display.clearDisplay();


// display temperature

display.setTextSize(1);

display.setCursor(0,0);

display.print("Temperature: ");

display.setTextSize(2);

display.setCursor(0,10);

display.print(t);

display.print(" ");

display.setTextSize(1);

display.cp437(true);

display.write(167);

display.setTextSize(2);

display.print("C");

// display humidity

display.setTextSize(1);

display.setCursor(0, 35);

display.print("Humidity: ");

display.setTextSize(2);

display.setCursor(0, 45);

display.print(h);

display.print(" %");

display.display();

}


Arduino Code Explanation

πŸ“š Library Section

The code starts by including required libraries for I2C, OLED graphics, and the DHT sensor.

  1. Wire.h β†’ I2C communication
  2. Adafruit_GFX.h β†’ Graphics functions
  3. Adafruit_SSD1306.h β†’ OLED driver
  4. Adafruit_Sensor.h β†’ Unified sensor support
  5. DHT.h β†’ DHT sensor handling


πŸ–₯️ OLED Configuration

The OLED resolution is defined as 128Γ—64 pixels. An OLED object is created using I2C communication with address 0x3C.


🌑️ DHT Sensor Setup

  1. DHT sensor data pin is connected to digital pin 2
  2. Sensor type is defined as DHT11
  3. dht.begin() initializes the sensor


βš™οΈ setup() Function

Inside setup():

  1. Serial communication starts for debugging
  2. DHT sensor initializes
  3. OLED display initializes
  4. Display is cleared and text color set to WHITE

If OLED initialization fails, the program stops to prevent errors.


πŸ” loop() Function Logic

  1. Program waits 5 seconds between readings
  2. Reads temperature and humidity values
  3. Checks for sensor reading errors
  4. Clears the OLED display
  5. Prints temperature in Β°C
  6. Prints humidity in percentage (%)
  7. Refreshes the OLED display

This loop runs continuously, updating data in real time.

Final Output

Screenshot 2026-01-03 211259.png

You now have a working Room Temperature & Humidity Monitor πŸ“Ÿ

  1. Clear OLED display
  2. Accurate readings
  3. Compact design


Possible Upgrades

🌑️ Use DHT22 for better accuracy

πŸ“Š Add min/max temperature memory

πŸ”” Add buzzer for alert

πŸ”‹ Add battery power

πŸ“Ά Add WiFi (ESP8266 / ESP32)

Conclusion

This project demonstrates how to combine sensors and displays with Arduino to create a practical monitoring device. It’s simple, educational, and easily expandable.

Perfect for beginners and makers who want to learn real-world Arduino applications.