Exp 2 (Ii)
Exp 2 (Ii)
: 2 (ii)
Aim: To interface OLED with Arduino and write a program to print temperature and humidity
readings on it.
Component Required:
Sl No Components Quantity
1 Arduino UNO 1
2 DHT11 Temperature sensor 1
3 USB cable for Arduino UNO 1
4 Connecting wires --
5 OLED Display 128×64, SSD1306 I2C 1
Circuit Connection:
Theory :
The SSD1306 OLED I2C 128X64 OLED
Specification of OLED
Display module is a small
monochrome organic light- Size 0.96 inch
emitting diode (OLED) display
that is controlled through an Terminals 4
I2C interface. It has a display
resolution of 128×64 pixels, Pixels 128×64
and the SSD1306 is the
controller chip that manages the display. It’s Communication I2C only
commonly used for display purposes in various
electronics projects and is compact low power, VCC 3.3V-5V
and easily readable in low light conditions.
Operating Temperature -40℃ to +80℃
To control the OLED display you need the adafruit_SSD1306.h and the adafruit_GFX.h libraries.
Follow the next instructions to install those libraries.
1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries.
The Library Manager should open.
2. Type “SSD1306” in the search box and install the SSD1306 library from Adafruit.
3. Click install button to install library
4. If ask click on install all button to install library dependencies
5. After installing the SSD1306 library from Adafruit, type “GFX” in the search box and
install the library.
6. If ask click on install all button to install library dependencies
7. After installing the libraries, restart your Arduino IDE
8. Find the Adafruit_SSD1306.h file in the Arduino Library folder. Generally, it is
located at Documents\Arduino\libraries on windows systems. There you will find the
Adafruit_SSD1306.h file inside the Adafruit_SSD1306 folder.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
String displayString;
void setup() {
Serial.begin(9600);
void loop() {
float humi = dht.readHumidity(); // read humidity
float tempC = dht.readTemperature(); // read temperature