This code is discontinued - Check out our newer tutorial at - https://learn.adafruit.com/monochrome-oled-breakouts/python-wiring
Raspberry Pi
You can hook up an OLED to the Raspberry Pi using either the Pi's I2C or SPI interface. If your OLED supports both I2C and SPI, make sure to check how the solder jumpers are configured to expose the right interface.
In general, I2C uses fewer pins but is slower. SPI is way fast, but requires a bunch extra pins. Choose your adventure based on your needs!
I2C
To use the Pi with an I2C display wire it up as follows:
NOTE: Make sure to enable I2C on your Pi before wiring it up!
- Connect display ground to Raspberry Pi ground (black wire).
- Connect display VIN to Raspberry Pi 3.3 volt (red wire).
- Connect display RST to Raspberry Pi GPIO 24 (blue wire). You can alternatively use any free digital GPIO pin for the reset pin.
- Connect display SCL to Raspberry Pi SCL (purple wire).
- Connect display SDA to Raspberry Pi SDA (orange wire).
SPI
To use the Pi with an SPI display, wire it up as follows:- Connect display ground to Raspberry Pi ground (black wire).
- Connect display VIN to Raspberry Pi 3.3 volt (red wire).
- Connect display CS to Raspberry Pi CE0 (yellow wire).
- Connect display RST to Raspberry Pi GPIO 24 (blue wire). You can alternatively use any free digital GPIO pin for the reset pin.
- Connect display DC to Raspberry Pi GPIO 23 (cyan wire). You can alternatively use any free digital GPIO pin for the DC pin.
- Connect display CLK to Raspberry Pi SCLK (orange wire).
- Connect display Data to Raspberry Pi MOSI (purple wire).
Using hardware SPI is great for getting the fastest response from the display, however if you need more flexibility with pin usage you can use a software-based SPI implementation with any 5 free digital GPIO pins. See the example code usage on the next page for more information about configuring software SPI.
BeagleBone Black
Just like with the Raspberry Pi, you can use an OLED display with the BeagleBone Black over either the SPI or I2C interface.I2C
To use the BeagleBone Black with an I2C display, wire it up as follows:- Connect display ground to BeagleBone Black ground (black wire).
- Connect display VIN to BeagleBone Black 3.3 volt (red wire).
- Connect display RST to BeagleBone Black P9_12 (blue wire). You can alternatively use any free digital GPIO pin for the reset pin.
- Connect display SCL to BeagleBone Black I2C2_SCL pin P9_19 (purple wire).
- Connect display SDA to BeagleBone Black I2C2_SDA pin P9_20 (orange wire).
SPI
To use the BeagleBone Black with an SPI display, wire it up as follows:- Connect display ground to BeagleBone Black ground (black wire).
- Connect display VIN to BeagleBone Black 3.3 volt power (red wire).
- Connect display CS to BeagleBone Black SPI0_CS0 pin P9_17 (yellow wire).
- Connect display RST to BeagleBone Black P9_12 (blue wire). You can alternatively use any free digital GPIO pin for the reset pin.
- Connect display DC to BeagleBone Black P9_15 (cyan wire). You can alternatively use any free digital GPIO pin for the DC pin.
- Connect display CLK to BeagleBone Black SPI0_SCLK pin P9_22 (orange wire).
- Connect display Data to BeagleBone Black SPI0_D1 pin P9_18 (purple wire).
With the BeagleBone Black connected to your computer over USB, open the USB mass storage drive named 'boot' and edit the file uEnv.txt on the drive. Add the following line to the file:
optargs=capemgr.enable_partno=BB-SPIDEV0
NOTE: Be careful editing the uEnv.txt file on Windows, as changing the line endings can cause your BeagleBone Black not to boot and require an OS reinstall! The safest option is to connect to the BeagleBone Black in a command window and follow the steps at the end of this page to mount and edit uEnv.txt on the BeagleBone Black.
Reboot your device and you should see the files /dev/spidev1.0 and /dev/spidev1.1 now exist.
Text editor powered by tinymce.