Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit 128x64 OLED Bonnet: Examples, Pinouts, and Specs

Image of Adafruit 128x64 OLED BonnetDesign with Adafruit 128x64 OLED Bonnet in Cirkit Designer

Introduction

The Adafruit 128x64 OLED Bonnet is a compact display module specifically designed for the Raspberry Pi. This bonnet features a high-contrast, monochrome OLED display with a resolution of 128x64 pixels, providing a crisp visual output for your projects. It is an ideal choice for adding a small screen to display data, menus, or graphics. Common applications include handheld instruments, user interfaces for projects, and status display for IoT devices.

Explore Projects Built with Adafruit 128x64 OLED Bonnet

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO Based Pong Game with OLED Display and Pushbutton Controls: A project utilizing Adafruit 128x64 OLED Bonnet in a practical application
Arduino UNO Based Pong Game with OLED Display and Pushbutton Controls

This circuit features an Arduino UNO microcontroller connected to an OLED 128x64 I2C Monochrome Display for visual output and two pushbuttons for user input. The Arduino runs a Pong game, with the display showing the game and the pushbuttons used to control the paddle movement. The display is interfaced via I2C (SCL and SDA), and the pushbuttons are connected to digital pins D2 and D3 for input detection.

Open Project in Cirkit Designer
Image of Arduino UNO Controlled OLED Display with 9V Battery and Step-Down Converter: A project utilizing Adafruit 128x64 OLED Bonnet in a practical application
Arduino UNO Controlled OLED Display with 9V Battery and Step-Down Converter

This circuit features an Arduino UNO connected to a 128x64 OLED display via I2C communication lines (SDA and SCL), with the Arduino providing control signals to the display. A 9V battery powers the circuit through a 12v to 5v step-down power converter, which supplies a regulated 5V to both the Arduino and the OLED display. The embedded code on the Arduino is configured to blink an onboard LED with a 1-second interval.

Open Project in Cirkit Designer
Image of Arduino UNO with I2C OLED Display Interface: A project utilizing Adafruit 128x64 OLED Bonnet in a practical application
Arduino UNO with I2C OLED Display Interface

This circuit connects an Arduino UNO to a 128x64 OLED display using I2C communication protocol. The Arduino provides power to the display and communicates with it via the SDA and SCL lines connected to the A4 and A5 pins, respectively. The embedded code initializes the display and prints 'Hello, World!' on it.

Open Project in Cirkit Designer

Technical Specifications

Display Characteristics

Electrical Specifications

Physical Characteristics

Pin Configuration and Descriptions

Pin Number Name Description
1 3V3 Power supply (3.3V from Raspberry Pi)
2 5V Not connected
3 SDA I2C Data Line
4 5V Not connected
5 SCL I2C Clock Line
6 GND Ground connection

Note: The above table only lists the pins used by the OLED Bonnet. The bonnet uses more pins for mechanical stability, but they are not connected electrically.

Usage Instructions

Initial Setup

  1. Attach the Bonnet: Carefully align the pin headers of the OLED Bonnet with the GPIO header on the Raspberry Pi and press down to connect.
  2. Install Libraries: Install the necessary libraries for the OLED Bonnet by running the following commands in the terminal:
sudo apt-get update
sudo apt-get install -y python3-pip
sudo pip3 install adafruit-circuitpython-ssd1306
  1. Enable I2C Interface: Use raspi-config to enable the I2C interface on your Raspberry Pi.

Programming the Display

To use the display with Python, you can use the Adafruit SSD1306 library. Here's a simple example to get started:

import board
import digitalio
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306

# Create the I2C interface.
i2c = board.I2C()

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height. Change these
# if you have a different sized display.
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Clear the display.
oled.fill(0)
oled.show()

# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
image = Image.new('1', (oled.width, oled.height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a white filled box to clear the image.
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)

# Draw some shapes.
# First define some constants to allow easy resizing of shapes.
padding = -2
top = padding
bottom = oled.height - padding
# Move left to right keeping track of the current x position for drawing shapes.
x = 0

# Load a font.
font = ImageFont.load_default()

# Draw a black filled box to clear the image.
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)

# Write two lines of text.
draw.text((x, top + 0), 'Hello World!', font=font, fill=255)
draw.text((x, top + 20), 'Adafruit OLED', font=font, fill=255)

# Display image.
oled.image(image)
oled.show()

Best Practices

Troubleshooting and FAQs

Common Issues

FAQs

Q: Can I use this Bonnet with other single-board computers? A: The Adafruit 128x64 OLED Bonnet is designed for the Raspberry Pi GPIO layout. It may not be directly compatible with other boards without an adapter or modifications.

Q: How do I adjust the contrast or brightness of the display? A: The SSD1306 library provides functions to adjust the contrast. OLED displays do not have a backlight, so the brightness is controlled by the pixel's light intensity, which is related to the contrast setting.

Q: Is it possible to display images or complex graphics? A: Yes, the OLED Bonnet can display bitmap images and graphics. You can use the PIL library to draw complex shapes, text, and images.

For further assistance, refer to the Adafruit forums or the SSD1306 library documentation for more detailed information on using the OLED Bonnet.