New Adafruit generic OLED display driver for Raspberry PI
-
-
Tom,
The link you provided (ie this one https://learn.adafruit.com/ssd1306-oled-displays-with-raspberry-pi-and-beaglebone-black/wiring) refers to pin name printed on PCB, mine the pin that I call
Pi P1 Header Pin
is the pin number of the connector P1, not the number printed on the PCB (which is the GPIO name) take a look on the connector
As You see Adafruit and mine are most of time the same (I refer to the P1 connector pin numbers in the circle in the previous image link).The only change For SPI, is that Adafruit connected RST to GPIO24 (P1 pin 18) and DC to GPIO23 (P1 pin 16) and mine is RST to GPIO25 (P1 pin 22) and DC to GPIO24 (P1 pin 18) so you just need to change these 2 ones in your wiring
- RST to GPIO25 (P1 pin 22)
- D/C GPIO24 (P1 pin 18)
And this should be working fine
PS : you can also keep Adafruit connection and change these 2 lines in the code
#define OLED_SPI_RESET RPI_V2_GPIO_P1_22 /* GPIO 25 pin 22 */ #define OLED_SPI_DC RPI_V2_GPIO_P1_18 /* GPIO 24 pin 18 */
by
#define OLED_SPI_RESET RPI_V2_GPIO_P1_18 /* GPIO 24 pin 18 */ #define OLED_SPI_DC RPI_V2_GPIO_P1_16 /* GPIO 23 pin 16 */
in the file ArduiPi_SSD1306.h
Charles
-
Ok. I changed the Raspberry Pi wiring back to Adafruit. I can run Adafruit's Python examples okay. I changed those 2 lines in 'ArduiPi_OLED_lib.h'. I 'sudo make' the library files, and 'sudo make' the example. When I run 'sudo ./oled_demo -o 1' nothing happens.
I put some 'printf' commands in the example for debugging, and it seems to lock up after it calls 'display.begin()'.
I can't find where the function display.begin() is so I can diagnose/debug it further.
-
I downloaded the older ArduiPi_SSD1306 and tried that, but same thing. Freezes after it runs 'display.begin()'. I changed the RESET and DC in the .h file as you mentioned. I don't understand why I can't access the display in C++, but Python works perfectly. I'm using a Raspberry Pi 2 if that makes a difference, and an SSD1306 1.3" 128x64 purchased from Adafruit.
-
Update: I setup my OLED in I2C mode and changed the address to 3D, and it worked. But I would still rather use SPI mode.
-
That's an interesting point, I did not tried on a PI V2, I have one at home, I need to test just in case, because the driver relies on old BCM2835 library that may be I need to update for PI V2, worth checking.
Good to know it works with I2C but I understand you prefer SPI, for sure it's so much faster.
-
Hi, Charles. Any progress with testing the library on a PI v2? Is the BCM2836 extremely different than the BCM2835?
-
Thank you for the detailed blog post. I followed your instructions and got 2 problems :
- there is no libi2c available, the only thing similar I've found is libi2c-dev so I installed that;
- I got error messages while trying to "sudo make" within the example folder, here is a photo showing the result.
http://i.imgur.com/MkWvXbC.jpg
Btw I am on a Pi B V2. One strange thing is that when I ran "sudo i2cdetect -y 1" there is nothing on the table. But while I tried to use Adafruit_SSD1306 library, the oled would respond (weirdly).
Thanks
-
the i2c smbus_ is a know problem
you just need to intall again lm-sensors package (even if correctly installed) then all shoud go fine. Something obvious I’d like to understand, but it seems to work.
look below how I resolved it.
root@pi03:~/github/ArduiPi_SSD1306/examples# make g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -lssd1306 ssd1306_demo.cpp -o ssd1306_demo /usr/local/lib/libssd1306.so: undefined reference to `i2c_smbus_write_i2c_block_data' /usr/local/lib/libssd1306.so: undefined reference to `i2c_smbus_write_byte_data' /usr/local/lib/libssd1306.so: undefined reference to `i2c_smbus_write_word_data' collect2: ld returned 1 exit status make: *** [ssd1306_demo] Error 1 root@pi03:~/github/ArduiPi_SSD1306/examples# dpkg --get-selections | grep i2c i2c-tools install libi2c-dev install root@pi03:~/github/ArduiPi_SSD1306/examples# dpkg --get-selections | grep lm lm-sensors install root@pi03:~/github/ArduiPi_SSD1306/examples# apt-get install lm-sensors Reading package lists... Done Building dependency tree Reading state information... Done lm-sensors is already the newest version. The following packages were automatically installed and are no longer required: libblas3gf liblapack3gf Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded. root@pi03:~/github/ArduiPi_SSD1306/examples# make clean rm -rf ssd1306_demo teleinfo-oled root@pi03:~/github/ArduiPi_SSD1306/examples# cd .. root@pi03:~/github/ArduiPi_SSD1306# make clean rm -rf *.o libssd1306.* /usr/local/lib/libssd1306.* root@pi03:~/github/ArduiPi_SSD1306# make g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Adafruit_SSD1306.cpp ./ArduiPi_SSD1306.h:51:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable] g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Adafruit_GFX.cpp ./ArduiPi_SSD1306.h:51:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable] gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c bcm2835.c g++ -shared -Wl,-soname,libssd1306.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o libssd1306.so.1.0 Adafruit_SSD1306.o Adafruit_GFX.o bcm2835.o [Install Library] [Install Headers] root@pi03:~/github/ArduiPi_SSD1306# cd examples/ root@pi03:~/github/ArduiPi_SSD1306/examples# make g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -lssd1306 ssd1306_demo.cpp -o ssd1306_demo g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -lssd1306 teleinfo-oled.cpp -o teleinfo-oled root@pi03:~/github/ArduiPi_SSD1306/examples#
For the i2cbus detection, nothing to do with my lib, i2cdetect is a tool distribued with your linux distro.
So to be sure I've just gone on my PI V2 to test
root@pi01(rw):~/ArduiPi_OLED/examples# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
root@pi01(rw):~/ArduiPi_OLED/examples# ./oled_demo -o 3 x: 9y: 0dy: 3 x: 30y: 0dy: 2 x: 111y: 0dy: 2 x: 81y: 0dy: 4 x: 41y: 0dy: 2 x: 85y: 0dy: 5
So @Mr_Tom yes it works on Pi V2 (at least in I2C mode) but should be the same for SPI; look below
-
I've got the lm-sensors module in there, and the make on examples worked.
But only still I can't get my Pi to recognize my oled screen, and I have another device on the i2c bus which works perfectly.
I just ordered another oled (a seeed 96*96) to see if that would work.Thank you for your detailed reply!
-
Meng,
Even if Seeed OLED will be seen, it won't work because it"s another driver in it (SSD1308) and I didn't port this one in the example code, something I wanted to do but never had time do do it.
By the way Seeed OLED 96x96 is the best OLED I ever saw, excellent display and gray level.
-
Meng
did you tried your non working OLED on an Arduino with I2CScan sketch just to see ? -
Hi, Charles,
I've tested my oled with I2CScan, and it wasn't detected... maybe a broken one. And I have another oled screen here which can be detected on Arduino, but not on Pi.
Here is a library by Seeed themselves : https://github.com/DexterInd/GrovePi/tree/master/Software/Python/grove_oled
I'll see if that would work once the oled screen arrives. Happy to know that it looks amazing. -
Meng,
yeah Seeed library works fine on Arduino, but not sure there is a port on Raspberry Pi -
This 96*96 oled screen is detected by my Pi and it is working with Seeed's own library, and it would also put out stuff while running your oled_demo.
Does your library has a manual? It doesn't looks like python when I peek into your library files... Sorry I am quite a beginner. Thank you.
I use my Pi to generate sound, and if I do oled operations within the same piece of .py file that does sound, any oled writing operations would block the sound. But if I open 2 terminal instances (I am using SSH), and run sound code on one, oled code on another, it wouldn't block the sound. So it is certainly not a CPU speed issue...
Why does this happen? And if I make my Pi running some python code at boot, how I can make the codes running like within multiple terminals?
Thank you!
-
I also try to run it on RPi2 with an SPI OLED 128x64 and ran into the same problem. The program freezes in display.begin(). What can be wrong?
-
Hi gbona,
Did you checked that your I2C oled is visible with i2cdetect ? If so does his I2C address is 0x3C ? -
Hi Charles. I am trying to use your library to drive a 128x64 SPI OLED display I got from the internet. It is advertised as being SSD1106 (which I assume means SH1106). I have hacked the CS detect line of your code to force it to use SPI instead of the default I2C (this display has no CS pin). I am getting something on the display, but quite garbled.
Here is a video of it running your OLED_demo. https://youtu.be/bETtabNliYc
Are these symptoms familiar to you. Any ideas of what might need tweaking.
Many thanks
Graham
-
@boik,
Strange, first time I see SPI oled without CS line, would you mind post a picture of the back ?You're right I forgot to add SPI option for SH1106 in oled_demo.
-
Hi Charles,
[IMG]http://i68.tinypic.com/6zwsjl.jpg[/IMG]
Heres a pic of it running the circle, square, triangle cross demo. Just displays the bottom 8 lines of the image but at the top of the OLED.
[IMG]http://i64.tinypic.com/2mhbn7k.jpg[/IMG]
Not sure if this forum accepts IMG tags?
Graham