Skip to content
ssd1306 Command Line Tool for Raspberry Pi / Orange Pi
C Shell
Branch: master
Clone or download
Latest commit 16ada31 Apr 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fontx 20170221 Mar 21, 2017
README.md
fontx.c Fix compile warning Nov 28, 2018
fontx.h 20180523 May 22, 2018
oled.c Add CS Pin with SPI Feb 16, 2019
test.sh 20160419 Apr 19, 2017

README.md

ssd1306_rpi

ssd1306 Command Line Tool for Raspberry Pi / Orange Pi

You can operate from command line.
You can choose Hardware-SPI/Software-SPI/I2C Interface.

Command line parameters
+1 String : String for #1 line(with External Font)
+2 String : String for #2 line(with External Font)
+3 String : String for #3 line(with External Font)
+4 String : String for #4 line(with External Font)
+a String : String for #1 line(with Internal Font)
+b String : String for #2 line(with Internal Font)
+c String : String for #3 line(with Internal Font)
+d String : String for #4 line(with Internal Font)
-1 : delete #1 line
-2 : delete #2 line
-3 : delete #3 line
-4 : delete #4 line
+R n : Set inverse mode #n Line
-R n : Unset inverse mode #n Line
+U n : Set underline mode #n Line
-U n : Unset underline mode #n Line
+L : Scroll Up 1Line
-L : Scroll Down 1Line
P1 n : Set start colum n to line#1
P2 n : Set start colum n to line#2
P3 n : Set start colum n to line#3
P4 n : Set start colum n to line#4
r : remove all string
s : show display

You can use within script.
#!/bin/bash
./oled r
./oled +1 "ABCDEFG"
./oled +2 "abcdefg"
./oled +3 "1234567"
./oled +4 "Hello World!!"
sudo ./oled s


Wire connection for Hardware SPI

OLED RPi/OPi
Gnd -- Gnd
VCC -- 3.3V
DO -- SCLK(Pin#23)
DI -- MOSI(Pin#19)
RES -- GPIO2(Pin#3) (*)
DC -- GPIO4(Pin#7) (*)
CS -- CS0(Pin#24)

(*)You can change any pin.
#define RST 8 // You can change
#define DC 7 // You can change


Wire connection for Software SPI

OLED RPi/OPi
Gnd -- Gnd
VCC -- 3.3V
DO -- GPIO11(Pin#23) (*)
DI -- GPIO10(Pin#19) (*)
RES -- GPIO2(Pin#3) (*)
DC -- GPIO4(Pin#7) (*)
CS -- GPIO8(Pin#24) (*)

(*)You can change any pin.
#define MOSI 12 // You can change
#define SCLK 14 // You can change
#define RST 8 // You can change
#define DC 7 // You can change
#define CS 10 // You can change


Wire connection for I2C

OLED RPi/OPi
Gnd -- Gnd
VCC -- 3.3V
SCK -- SCL(Pin#5)
SDA -- SDA(Pin#3)

Install for Hardware SPI

git clone https://github.com/nopnop2002/ssd1306_rpi.git  
cd ssd1306_rpi/  
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSPI  
bash ./test.sh  

Install for Software SPI

git clone https://github.com/nopnop2002/ssd1306_rpi.git  
cd ssd1306_rpi/  
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSOFT_SPI  
bash ./test.sh  

Install for I2C (128X64)

git clone https://github.com/nopnop2002/ssd1306_rpi.git  
cd ssd1306_rpi/  
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C  
bash ./test.sh  

Install for I2C (128X32)

git clone https://github.com/nopnop2002/ssd1306_rpi.git  
cd ssd1306_rpi/  
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C -DX32   

The number of lines which can be indicated is only 2 lines.


Left : OrangePi + SPI Module
Right : RaspberryPi + I2C Module

oled-2


oled-1

oled-2

oled-4

Line1-2 : External Font
Line3-4 : Internal Font

oled-5


Set start colum

oled-6

oled-7


128 X 32 Module
oled-3


OrangePi ZERO Universal HAT + OLED

zero-hat-7

You can’t perform that action at this time.