i2c OLED display on C1

Moderators: mdrjr, odroid

i2c OLED display on C1

Unread postby mattcamp » Thu Oct 01, 2015 6:14 am

Has anyone managed to get one of the little cheap 128x64 i2c OLED displays to work on a C1?

I've got this display: http://www.ebay.co.uk/itm/New-0-96-Inch ... 1869219453 which works fine on an Arduino.

I'm trying to drive it on my C1 using: https://github.com/stephen-mw/ssd1306-128x64-lib

I've got wiringPi2 installed ok on my C1 as per viewtopic.php?f=115&t=9394 but it seems that the sample files in the ssd1306 library require SPI, which I don't seem to have.

Code: Select all
root@bigsmall:~/ssd1306-128x64-lib/samples# python ./ssd1306_test.py
Traceback (most recent call last):
  File "./ssd1306_test.py", line 8, in <module>
    led = gaugette.ssd1306.SSD1306(reset_pin=RESET_PIN, dc_pin=DC_PIN)
  File "/usr/local/lib/python2.7/dist-packages/gaugette/ssd1306.py", line 114, in __init__
    self.spi.open(bus, device)
IOError: [Errno 2] No such file or directory


Code: Select all
root@bigsmall:~/ssd1306-128x64-lib/samples# gpio -v
gpio version: 2.30
Copyright (c) 2012-2014 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Hardkernel ODROID Details:
  Type: ODROID-C1/C1+, Revision: 1, Memory: 1024MB, Maker: Hardkernel


Code: Select all
root@bigsmall:~/ssd1306-128x64-lib/samples# gpio readall
 +------+-----+----------+------+- Model ODROID-C -+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |      |
 |      |     |    SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |      |
 |      |     |    SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |      |
 |   83 |   7 | GPIO. 83 |   IN | 1 |  7 || 8  | 0 | ALT5 | TxD1     |     |      |
 |      |     |       0v |      |   |  9 || 10 | 0 | ALT5 | RxD1     |     |      |
 |   88 |   0 | GPIO. 88 |   IN | 1 | 11 || 12 | 1 | IN   | GPIO. 87 | 1   |  87  |
 |  116 |   2 | GPIO.116 |   IN | 1 | 13 || 14 |   |      | 0v       |     |      |
 |  115 |   3 | GPIO.115 |   IN | 0 | 15 || 16 | 1 | IN   | GPIO.104 | 4   |  104 |
 |      |     |     3.3v |      |   | 17 || 18 | 1 | IN   | GPIO.102 | 5   |  102 |
 |  107 |  12 |     MOSI |   IN | 1 | 19 || 20 |   |      | 0v       |     |      |
 |  106 |  13 |     MISO |   IN | 1 | 21 || 22 | 1 | IN   | GPIO.103 | 6   |  103 |
 |  105 |  14 |     SCLK |   IN | 1 | 23 || 24 | 0 | IN   | CE0      | 10  |  117 |
 |      |     |       0v |      |   | 25 || 26 | 1 | IN   | GPIO.118 | 11  |  118 |
 |      |     |    SDA.2 | ALT5 | 0 | 27 || 28 | 0 | ALT5 | SCL.2    |     |      |
 |  101 |  21 | GPIO.101 |   IN | 1 | 29 || 30 |   |      | 0v       |     |      |
 |  100 |  22 | GPIO.100 |   IN | 1 | 31 || 32 | 1 | IN   | GPIO. 99 | 26  |  99  |
 |  108 |  23 | GPIO.108 |   IN | 0 | 33 || 34 |   |      | 0v       |     |      |
 |   97 |  24 | GPIO.97  |   IN | 1 | 35 || 36 | 1 | IN   | GPIO. 98 | 27  |  98  |
 |      |     |    AIN.1 | ALT5 | 0 | 37 || 38 | 0 | ALT5 | 1v8      |     |      |
 |      |     |       0v |      |   | 39 || 40 | 0 | ALT5 | AIN.0    |     |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+


Any ideas?
mattcamp
 
Posts: 2
Joined: Thu Oct 01, 2015 6:04 am
languages_spoken: english
ODROIDs: C1

Re: i2c OLED display on C1

Unread postby mattcamp » Thu Oct 01, 2015 7:08 am

Never mind, https://github.com/rm-hull/ssd1306 seems to work nicely!
mattcamp
 
Posts: 2
Joined: Thu Oct 01, 2015 6:04 am
languages_spoken: english
ODROIDs: C1

Re: i2c OLED display on C1

Unread postby odroid » Thu Oct 01, 2015 10:42 am

Good to know it works. Thank you for sharing.

I've added this item in the compatibity list.
viewtopic.php?f=115&t=8181&p=108203#p108203
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby cruzpe » Fri Jun 10, 2016 11:20 pm

Hi, just to let know that this also worked on the Odroid C2 board.

Thanks mattcamp!!
cruzpe
 
Posts: 14
Joined: Fri Jun 10, 2016 10:46 pm
languages_spoken: english
ODROIDs: C2

Re: i2c OLED display on C1

Unread postby eudoxos » Tue Dec 06, 2016 5:43 am

@cruzpe, which RPi.GPIO did you use with Odroid C2? I am struggling a bit. Thanks!
eudoxos
 
Posts: 21
Joined: Tue Sep 27, 2016 5:50 pm
languages_spoken: english german french italian czech
ODROIDs: C2

Re: i2c OLED display on C1

Unread postby dchang0 » Tue Jun 13, 2017 9:08 am

Sorry to threadjack (kinda).

Here's another SSD1306-based OLED 128x32 monochrome display I'm very interested in:

http://www.ebay.com/itm/0-91-inch-128-3 ... Ciid%253A1

It's a bit pricey at $9.99 since the OLED panel itself can be bought for under $2 and other complete breakout boards with the exact same display with headers pre-soldered are under $5,
BUT this board is attractive to us ODROIDers because it is arranged to fit neatly on the Raspberry Pi's GPIO headers (pins 1,3,5,7,9) with a female single-row header. Thus, it is easily installed without jumper wires or header adapters, etc.

It says in the github code that it uses a derivative of Adafruit's C++ library, which may be bad for us C1/C1+/C2 users due to this bug: https://github.com/rm-hull/luma.oled/issues/70 That's the same 128x32 display made by Adafruit that one of our forum members eudoxos (posted right before me) here apparently gave up on getting to work.

Adafruit has its own nicer version of the exact same display with a 2x3 female header and screw hole:

https://www.adafruit.com/product/3527

The price of $14.95 plus shipping is terribly high though.

These two displays SHOULD work with what you guys discovered in this thread because they all share the same SSD1306 chipset. If anyone confirms that either of these two displays I mentioned works, please post here.

I am also looking at these other $30 full color I2C OLED displays by DigOle:

http://www.ebay.com/itm/252722252294?_t ... EBIDX%3AIT

They seem to have their own codebase, and I cannot find in the tech specs whether they are SSD13##-based. If I go this route, I'll post whether they work here.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 8:38 am

I ended up buying this recently-released OLED display from Adafruit because it also comes with buttons, and I happen to need buttons for my project:

https://www.adafruit.com/product/3531

The joystick is a big plus. I might be able to write a standalone menu for graceful shutdowns. Press and hold all three buttons, menu comes up, use joystick to move through menu, press and hold button to initiate shutdown.

I am able to get it to display the Hello World and ssd1306 driver example using luma-oled here:

https://luma-oled.readthedocs.io/en/lat ... usage.html
https://github.com/rm-hull/luma.oled

I had to use a stacking male-female 2x20 header to get the Adafruit bonnet/pHat to clear the C1+ heatsink (it will not fit down far enough on the stock GPIO pins without this trick because the Adafruit bonnet has a short 2x20 female header underneath, not regular-height).

I used the installation instructions (the pip-related commands, skip the 3rd command apt-get purge python-pip) at the bottom of this page to do the install, then had to also install mock and pytest using pip.
https://luma-oled.readthedocs.io/en/latest/install.html

For whatever reason, after running the Hello World code the first time, I lost WiFi network access to the C1+. It hasn't happened again, but if it does, I'll report back here for caveat emptor. It might be too much current draw, though I have the dedicated barrel-connector AC adapter supplying 5V 2.0A.

EDIT: sample code caused disconnect of the Edimax WiFi dongle a second time. Not good. If this happens frequently enough, the bonnet will not be useful to me on a C1+. After about a minute the WiFi reconnects on its own and the system is accessible again. It does get sluggish every time after running and then quitting the Hello World example (if I quit before the WiFi disconnects).

Also, I need to get the buttons working. Probably will be via the C1+ WiringPi. I'm not sure how to address the buttons yet, since there appears to be only one device discovered by
Code: Select all
i2cdetect -y 1
My guess is that the #5 and #6 labels have something to do with how to address them.
Attachments
Adafruit128x64OLEDonC1Plus.jpg
Adafruit128x64OLEDonC1Plus.jpg (118.31 KiB) Viewed 221 times
Last edited by dchang0 on Wed Jun 28, 2017 3:46 pm, edited 2 times in total.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Wed Jun 28, 2017 10:43 am

Good to hear you made it work. :)

Can you check "dmesg" output when the WiFI disconnects?

Buttons/joystick could be accessible via GPIOs. Look at their schematics.
https://learn.adafruit.com/adafruit-128 ... /downloads
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 11:40 am

I suspect that the WiFi disconnecting is this known issue with Edimax WiFi USB adapters falling asleep.

https://raspberrypi.stackexchange.com/q ... tion#27748

I have removed the Adafruit OLED display and am still having the WiFi problem, so it is likely that the OLED display has nothing to do with it. Thus, I would tentatively say that the OLED works perfectly on my C1+. Once I have absolutely solved the WiFi issue and continue testing the OLED display, I'll report back.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 11:59 am

From Adafruit's source code on Github, the buttons are:

# Input pins:
L_pin = 27
R_pin = 23
C_pin = 4
U_pin = 17
D_pin = 22

A_pin = 5
B_pin = 6

https://github.com/adafruit/Adafruit_Py ... buttons.py

It appears that they use SPI for the buttons and I2C for the display. If true, that would explain why only one address shows up in the i2cdetect scan.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Wed Jun 28, 2017 12:18 pm

No. Those pins are directly connected the GPIOs not the SPI.
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 3:30 pm

Cool, thanks for the tip.

I confirm that my sluggish then cut-off WiFi was indeed the Edimax power save/sleep problem, so the Adafruit OLED 128x64 bonnet/pHat display is working fine.

Next, I'll figure out the buttons and post my results, after which you can add this device to the compatibility list.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 5:03 pm

I've installed the ODROID port of WiringPi2 for Python and am using this code:

Code: Select all
from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import wiringpi2 as wpi
import time

# rev.1 users set port=0
# substitute spi(device=0, port=0) below if using that interface
serial = i2c(port=1, address=0x3C)

# substitute ssd1331(...) or sh1106(...) below if using that device
device = ssd1306(serial)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 30), "Hello ODROID", fill="white")

INPUT = 0
PUD_UP = 2
L_pin = 27
R_pin = 23
C_pin = 4
U_pin = 17
D_pin = 22

A_pin = 5
B_pin = 6
buttons = [27, 23, 4, 22, 5, 6]

wpi.wiringPiSetup()

for x in buttons:
   wpi.pinMode(x, INPUT)
   wpi.pullUpDnControl(x, PUD_UP)
   wpi.digitalWrite(x, 0)

while True:
   time.sleep(0.05)

   for x in buttons:
      print wpi.digitalRead(x)

raw_input()


It definitely succeeds at drawing on the screen. I am finding that the pin numbers that I swiped from Adafruit's source code for their bonnet are not correct. Either that, or the pin numbering mode selected by wpi.wiringPiSetup() is not correct.

With the above (default) pin numbers, only two buttons work: button B_pin = 22 (not 6) and button R_pin = 4 (not 23). U_pin = 17 generated an error, so I removed it from the array.

I guess I can just scan all the possible pin numbers and see which ones respond, unless this is dangerous somehow (permanent hardware damage). Thoughts/input?
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Wed Jun 28, 2017 5:14 pm

Nice to hear you've fixed WiFi issue.

Refer this link to know the WiringPi GPIO pin-map on C1.
http://odroid.com/dokuwiki/doku.php?id= ... connectors
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jun 28, 2017 5:20 pm

Found out the real pin numbers:

L = 2
R = 4
U = 0
D = 3
C = 7
A = 21
B = 22

So, I can confirm that the Adafruit 128x64 OLED Bonnet (pHat) for Raspberry Pi (prod. id 3531) absolutely works on the ODROID C1+ running Ubuntu 16.04 minimal with Luma.OLED's SSD1306 for the driver display and HardKernel's WiringPi2 for Python for the buttons. All the buttons work.

Here's the updated code:

Code: Select all
from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import wiringpi2 as wpi
import time

# rev.1 users set port=0
# substitute spi(device=0, port=0) below if using that interface
serial = i2c(port=1, address=0x3C)

# substitute ssd1331(...) or sh1106(...) below if using that device
device = ssd1306(serial)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 30), "Hello ODROID", fill="white")

INPUT = 0
PUD_UP = 2
L_pin = 2
R_pin = 4
C_pin = 7
U_pin = 0
D_pin = 3
A_pin = 21
B_pin = 22
buttons = [0, 2, 3, 4, 7, 21, 22]

wpi.wiringPiSetup()

for x in buttons:
   wpi.pinMode(x, INPUT)
   wpi.pullUpDnControl(x, PUD_UP)
   wpi.digitalWrite(x, 0)

while True:
   time.sleep(0.05)

   for x in buttons:
      print "x: %d state: %d" % (x, wpi.digitalRead(x))

dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Wed Jun 28, 2017 5:29 pm

Great!
Thank you for sharing the fully working source code. :D

I hope you can write an article for our Magazine.
viewtopic.php?f=74&t=2802
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby dchang0 » Thu Jun 29, 2017 4:11 am

I'm writing the article now. Let's hope it gets published!
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby dchang0 » Sun Jul 02, 2017 12:09 pm

I'm going to try out this Digole full-color OLED display:

http://digole.com/index.php?productID=1270

Based on high praise from some RPi users, I expect it to work very well on ODROIDs. Too bad there aren't any buttons, the pin order doesn't match the GPIO pins, and there is no easy mounting solution, but, hey, it's full color OLED!
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Mon Jul 03, 2017 10:51 am

Looks interesting and nice 160x128 resolution!
Are you considering the SPI interface?
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: i2c OLED display on C1

Unread postby dchang0 » Thu Jul 06, 2017 3:00 pm

Might as well play with the SPI interface too. I don't really have a need for this display (monochrome is fine, and I need the buttons on the Adafruit 3531), so it's really just a toy.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby dchang0 » Wed Jul 19, 2017 7:07 am

I received the Digole display and tested all three methods of communication: UART, SPI, and I2C, and they all work fine. Expect an article for ODROID Magazine to be published soon. UART was the least hassle by far.
dchang0
 
Posts: 60
Joined: Tue Dec 22, 2015 1:29 pm
languages_spoken: english
ODROIDs: C1+

Re: i2c OLED display on C1

Unread postby odroid » Wed Jul 19, 2017 10:39 am

Thank you for sharing the progress status. :)
User avatar
odroid
Site Admin
 
Posts: 23623
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 3 guests