Using a 0.96 inch OLED Display with Arduino Microcontroller

0.96" OLED Display
PDF24    Send article as PDF   
In this article I will show how to use the small 0.96 inch OLED display with an Arduino Microcontoller board to build a very basic Weather Station.

The 0.96 inch OLED display:

The OLED display is a very small display, the screen measures a mere 25mm x 14mm (0.98in x 0.55in). It is consists of 128 by 64 individual OLED pixels and has no need for a backlight. This OLED display is monochrome (white color), but there are other models with several colors available.

This display uses I2C communication. This means that it communicates with the Arduino using just 2 pins.

Pin wiring:

Wiring the OLED display to your Arduino is pretty straightforward:

  OLED Pin Wiring to Arduino Uno  
Vin 5V
GND GND
SCL A5
SDA A4

If you’re using other Arduino board rather than the “Uno“, chek out what are their SCL and SDA pins need to be.

  • Nano: SDA (A4); SCL(A5);
  • MEGA: SDA (20); SCL(21);
  • Leonardo: SDA (20); SCL(21);

Libraries:

To control the OLED display we need to use the “adafruit_GFX.h” library and the “adafruit_SSD1306.h” library.

Installing the adafruit_GFX library
  1. Click here to download the adafruit GFX library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get Adafruit-GFX-Library-master folder
  3. Rename your folder from Adafruit-GFX-Library-master to Adafruit_GFX_Library (you really need ro replace those “-” by “_”)
  4. Move the Adafruit_GFX_Library folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE
Installing the adafruit_SSD1306 library
  1. Click here to download the adafruit_SSD1306 library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get Adafruit-GFX-Library-master folder
  3. Rename your folder from Adafruit_SSD1306-master to Adafruit_SSD1306
  4. Move the Adafruit_SSD1306 folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE
Tips about writing text using these libraries

Here are some of the functions that handle the OLED display library, allowing the Arduino to write text or draw simple graphics.

  • display.clearDisplay() – all pixels are off
  • display.drawPixel(x,y, color) – plot a pixel in the x,y coordinates
  • display.setTextSize(n) – set the font size, supports sizes from 1 to 8
  • display.setCursor(x,y) – set the coordinates to start writing text
  • display.print(“message”) – print the characters at location x,y

Temperature and Humidity Monitoring with the OLED Display:

For this example we will display the temperature and humidity on the OLED display. The aim of this project is to become familiar with using the OLED display, in conjunction with the DHT11 temperature & humidity sensor, which will monitor the current Temperature and Humidity.

Parts required:

For this example you’ll need the following components:

Schematics:

Assemble all the Modules as in the schematic diagram below.

0.96" OLED Display Wiring

Code:

Make sure you’ve installed the necessary libraries to control the OLED display. You will also need to install the DHT library.

Installing the DHT sensor library
  1. Click here to download the DHT-sensor-library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get DHT-sensor-library-master folder
  3. Rename your folder from DHT-sensor-library-master toDHT_sensor_library (you really need ro replace those “-” by “_”)
  4. Move the DHT_sensor_library folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE
Upload the following code:

0.96 inch OLED Display Demo Code:

 

Demonstration:

Here is the OLED display in action, with the Arduino measuring its enviroment and displaying the data.

Weather Report

Previous Post
bmp180 barometricsensor

Introduction to using the BMP180 barometric sensor with Arduino

The BMP180 barometric sensor (model GY-68) in the following two images is a very small module with 10mm x 10.1mm (0.039in x 0.043in) footprint. This guide is also applicable for ... Read more

Next Post
WS2812B LED Strip

Using WS2812B Addressable RGB LED Strips with Arduinos

This article is about my experiments with the WS2812B LED strip, which is an addressable RGB LED strip. This information should also work with other similar LED strips, such as ... Read more

Short URL: http://tinyurl.com/gubbxap

Leave a Reply

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



Do NOT follow this link or you will be banned from the site!
error: Content is protected !!