Testing the small i2c OLED
SSD1306 128x64 display on Raspberry Pi
- more notes for backup and a bad memory -
-
These notes will be upgraded at random times
This first hack is WORKING but not yet tidy, , , ,
Objective - use the display
to follow the execution of a long program
(this just needs a simple display of large text)
This is the i2c
version (not my screen display - I
just show big text across the top)
# python
/home/pi/codelectron_projects/Rpi/OLED/start_again.py from luma.core.interface.serial import i2c from luma.core.render import canvas from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106 import time from PIL import ImageFont, ImageDraw serial = i2c(port=1, address=0x3C) device = ssd1306(serial, rotate=0) # Box and text rendered in portrait mode with canvas(device) as draw: font = ImageFont.truetype('/home/pi/luma.examples/examples/fonts/Volter__28Goldfish_29.ttf',20) draw.text((0, 0), "Start again", font=font, fill=255) time.sleep(2) |
Another page gives similar help -
https://www.raspberrypi-spy.co.uk/2018/04/i2c-oled-display-module-with-raspberry-pi/
I loaded all the
software on offer here and tested the examples
(There is
loads of room on a Pi SD card - I may have used parts of
SSD1306 code in some tests)
sudo apt install
-y git
Then clone the repository using the following command
:
git clone
https://github.com/adafruit/Adafruit_Python_SSD1306.git
Once that
completes navigate to the library’s directory :
cd Adafruit_Python_SSD1306
and install the
library for Python 2 :
sudo python setup.py install
and/or Python 3 :
sudo python3 setup.py install
CONCLUSION
The display is very small and with some fonts you need young eyes
A simple 16x2 display with i2c
driver may be better for text output!
Less
than £2 on eBay
Please email me if you want to swap notes