Temperature and Humidity display on OLED using Arduino UNO & DHT11 Sensor with Relay Control

During the course of this blog we will explore how to display temperature and humidity on a 0.96″ OLED display using Arduino and DHT11 temp/humidity sensor. We will control two relays through Arduino based on the temperature and humidity values.

We will be requiring:

  • Arduino UNO R3
  • 0.96″ OLED dispaly
  • DHT11 Sensor Module
  • 2 Channel 5V Relay Module
  • Power Breakout Board and Jumper Wires

DHT11 Temperature & Humidity Sensor

DHT11 is a compact digital temperature and humidity sensor quite popular among hobbyists and tinkerers. It has a 3 pin interface and uses a capacitive humidity sensor along with thermistor to give humidity and temperature values in the form of serial data on a digital pin. A pullup resistor and filtering capacitor should preferably be connected with sensor so we will use DHT11 module which has both onboard and makes the 3 interfacing pins available in the form of Arduino friendly headers. The range of DHT11 sensor is: for temperature : 0 – 50 deg C, for humidity: 20 – 90% RH.

The three pins are namely Vcc, GND and DATA. While interfacing it to a 5V microcontroller system such as Arduino we need to supply 5V DC across Vcc and GND and connect DATA pin to any digital I/O pin on Arduino.

To get temperature and humidity values from DHT11 we will be using below Adafruit library.


0.96″ OLED Display

In this project we have used a 0.96 inch OLED white display with resolution of 128X64 pixels.

OLED stands for Organic Light Emitting Diode which is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.

This small OLED dispaly based on SSD1306 driver is ideal for driving through small microcontroller such as Arduino. It has easy 4 pin I2C interface with 3.3V and 5V DC supply voltage compatibility.

The 4 pins are Vcc and GND for supply voltage and SDA & SCL for I2C interface. We will give 5V across voltage pins and connect Arduino I2C pins to OLED. I2C is a commonly used 2 wire communication protocol where different slaves having unique addresses can communicate to master over a two wire bus.

The OLED display has a resolution of 128X64 pixels and can display text, characters, designs, pattern and animation.

We will use following two Adafruit libraries to run our OLED through Arduino.



2 Channel 5V 10A Relay Module

The idea behind using relays in the project is to execute a control action when temperature and humidity go above or below a particular threshold value. They can be used to control light, fan, heater, cooler & dehumidifier etc.

The 2 channel 5V relay module we are using is an Arduino friendly board with two opto-isolated 5V relay rated at 10A – 230V. It has four wire interface with 5V supply voltage to be given across Vcc & GND. IN1 and IN2 are the two digital input pins to control relay 1 and 2 respectively. When a LOW signal is applied to the input the relay coil get energized and there is contact between COM & N/O. If the input is kept HIGH the relay will be in switch OFF condition with contact between COM & N/C. The energizing of relay coil can be visually identified through lighting of onboard LEDs.

Do the complete wiring as given in figure below. Connect Vcc and GND of all modules to 5V and GND of Arduino through power breakout board. Connect the DATA pin on DHT11 module to digital I/O pin no. 2 on Arduino. Connect SDA and SCL of OLED to Arduino. Connect relay inputs IN1 and IN2 to digital I/O pin no 8 and 9 on Arduino respectively.

2 thoughts on “Temperature and Humidity display on OLED using Arduino UNO & DHT11 Sensor with Relay Control

Leave a Reply

Your email address will not be published. Required fields are marked *