OLED (ssd1306 128x64) via i2c

Post Reply
crayfellow
Posts: 17
Joined: Tue Nov 03, 2015 9:36 am
languages_spoken: english
ODROIDs: XU4
Contact:

OLED (ssd1306 128x64) via i2c

Unread post by crayfellow » Sun Jan 17, 2016 7:39 am

Hi all!

I am using a 128x64px OLED (like this) with ssd1306 driver which has a simple 4-pin i2c interface: VCC, GND, SCL, SDA) with an Odroid XU4.

I currently have VCC and GND wired to 30-pin GPIO pins 1 and 2, SCL wired to pin 14 and SDA wired to pin 16. I believe I'm somewhat on the right track because ''i2cdetect 3" gives me:

Code: Select all

     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: -- -- -- -- -- -- -- --   
Which shows an i2c device at address 0x3c, which is where I expected it.

My application is C++, and I haven't found a C++ example or driver for the ssd1306 that uses i2c. So I am porting Adafruit_SSD1306. All I've done is update the references to i2c with calls to wiringPi i2c functions, like so:

Code: Select all

    wiringPiSetup();
    // ...
    int fd,ret;
    fd = wiringPiI2CSetup(_i2caddr);
    ret = wiringPiI2CWrite(fd, control);
    ret = wiringPiI2CWrite(fd, c);
I must still be missing something, as the screen is not displaying anything when I interact with it. Any ideas? Thanks!

crashoverride
Posts: 4181
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by crashoverride » Sun Jan 17, 2016 1:26 pm

The XU3/4 use 1.8V on the GPIO connector:
http://odroid.com/dokuwiki/doku.php?id= ... dware_gpio
All signals on expansion headers are 1.8V except PWRON signal.
You will need a level shifter to operate the device and prevent damage to the XU3/4.

From the product page of the OLED display:
Support wide voltage: 3.3V-5V DC

crayfellow
Posts: 17
Joined: Tue Nov 03, 2015 9:36 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by crayfellow » Mon Jan 18, 2016 9:55 am

crashoverride wrote: You will need a level shifter to operate the device and prevent damage to the XU3/4.
Support wide voltage: 3.3V-5V DC
Right, thanks. I've got 10k resistors tied to Vcc. For what it's worth, I am getting a proper file descriptor for wiringPiI2CSetup, and no error code for wiringPiI2CWrite. If I unplug SCL/SDA I see error codes.

The issue is that I get nothing on the display. Anyone else have this display working via i2c and wiringPi on an XU?

crayfellow
Posts: 17
Joined: Tue Nov 03, 2015 9:36 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by crayfellow » Tue Jan 19, 2016 5:41 am

I ended up stripping out wiringPi and using raw calls to i2c-dev.h functions. That worked great! I'd like to understand why wiringPi didn't work, but don't have time to poke at it any further since what I have is working.

If I get a chance I will clean up the code and post for others looking to use these displays with Odroid, and will leave this thread for reference.

cheers!

Tpimp
Posts: 355
Joined: Thu Jul 16, 2015 5:57 am
languages_spoken: english
ODROIDs: U3, C1+, XU4
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by Tpimp » Tue Jan 19, 2016 6:26 am

Please do. I have one but have not had time to play with it yet. I'd love to give your code a try.

lsc1117
Posts: 97
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by lsc1117 » Tue Jan 19, 2016 5:26 pm

Hello, crayfellow

I don't think that your source code would be wrong.

Please refer to the below source code.

https://github.com/john1117/WEATHER-BOA ... r/wiringPi

We could use the WiringPi I2C API with our WEATHER-BOARD successfuly.
http://odroid.com/dokuwiki/doku.php?id= ... d#wiringpi

crayfellow
Posts: 17
Joined: Tue Nov 03, 2015 9:36 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by crayfellow » Fri Jan 22, 2016 9:28 am

Tpimp wrote:Please do. I have one but have not had time to play with it yet. I'd love to give your code a try.
will do! Shouldn't be long, works nicely now.

Indranil Sarkar
Posts: 39
Joined: Tue Apr 24, 2018 1:14 pm
languages_spoken: english
ODROIDs: ODROID-XU4
Contact:

Re: OLED (ssd1306 128x64) via i2c

Unread post by Indranil Sarkar » Sat Jan 12, 2019 1:47 am

crayfellow wrote:
Tue Jan 19, 2016 5:41 am
I ended up stripping out wiringPi and using raw calls to i2c-dev.h functions. That worked great! I'd like to understand why wiringPi didn't work, but don't have time to poke at it any further since what I have is working.

If I get a chance I will clean up the code and post for others looking to use these displays with Odroid, and will leave this thread for reference.

cheers!
could you please post it, I am also in the same situation, it would be a big aid for me...
TIA

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests