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.
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.
sudo apt-get update
sudo apt-get install -y python3-pip
sudo pip3 install adafruit-circuitpython-ssd1306
raspi-config
to enable the I2C interface on your Raspberry Pi.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
i2c = board.I2C()
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0) oled.show()
image = Image.new('1', (oled.width, oled.height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)
padding = -2 top = padding bottom = oled.height - padding
x = 0
font = ImageFont.load_default()
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
draw.text((x, top + 0), 'Hello World!', font=font, fill=255) draw.text((x, top + 20), 'Adafruit OLED', font=font, fill=255)
oled.image(image) oled.show()
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.