1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

20x2 I2C OLED character display and XBMC = nothing (solved)

Fri Sep 12, 2014 2:02 pm

Hello

I am trying to get my 20x2 OLED display to work with xbmc and lcdproc.

purpose is to show what xbmc is doing on the display.

So far only thing I have found is that i2cdetect show my device at address: 3c

But the display is black as night, nothing..

I tried this tutorial: http://www.raspberrypi.org/forums/viewt ... 35&t=63412 (mainly to install LCDd and LCDproc)

and I am now thinking that maybe the US2066 controller is not even close to HD44780 compatibility,
or that I have made an error connecting the display pins.

This is the display I have:
http://www.buydisplay.com/default/i2c-2 ... w-on-black

I connected the display pins as the The Serial I2C Reference Example said to do in this file:
http://www.buydisplay.com/download/inte ... facing.pdf
Serial data input to SDA, and serial clock to SCL on the Pi..
I tried without the 4,7k resistors, with the resistors and nothing, since this is an OLED, it has no backlight to display, so unless it shows any character, I cannot even verify if it is broken.

There is a i2c demo code, maybe that could help to check if display works, but I dont know how to use that with RPi

Something maybe connected wrong, but i don't understand what.
Do i need to connect the reset display pin to rpi? how will I tell the pi how to use it?

Thanks in advance
Last edited by 1958 on Fri Sep 12, 2014 3:31 pm, edited 1 time in total.
The Raspberry Pi has much potential, if only I would know how to use it..

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: 20x2 I2C OLED character display and XBMC = nothing

Fri Sep 12, 2014 2:47 pm

Hi and welcome to the forum.
In order to use my tutorial, the hardware needs to match the software configuration.
Check that the I2C expander is wired like this, otherwise it will not work :

Code: Select all

pinout is as follows: PCF8574 - HD44780
   P0 - LCD11 - D4
   P1 - LCD12 - D5
   P2 - LCD13 - D6
   P3 - LCD14 - D7
   P4 - LCD4  - RS
   P5 - LCD5  - R/W
   P6 - LCD6  - E
   P7 - LCD15 - LED BACKLIGHT
Hope this helps,
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Fri Sep 12, 2014 3:08 pm

Hi,

I added after your post that I tried the tutorial to get LCDd and LCDproc installed.

The er-oled2002-1 module has no expander, because it has i2c connection,
I have enabled i2c mode with the onboard SMD jumpers.

I have no PCF8574 expander.
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Fri Sep 12, 2014 5:08 pm

You need proper initializing code to get your display working.
Take look at example code: http://www.buydisplay.com/download/demo ... moCode.txt

Code: Select all

void LCD_initialize(void)
{
	 RES=0;
	 Delay(200);
	 RES=1;
	 Delay(200);

	 Start();
	 SentByte(Write_Address); //slave addresses with write
	 SentByte(0x80);			//Continuation bit  command
	 SentByte(0x2a);  			//RE=1
... etc

Now grab my code:
https://github.com/0xFACE/RPi-OLED-Disp ... er/init.py
and put the proper values for your display.

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Fri Sep 12, 2014 5:49 pm

At first look both controllers US2066/SSD1311 seems to be compatible.
Try my python code to test.

Check my github repo. I patched LCDd daemon to work with my display.
I use this one.
Image

Hope my code will work for yours.

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sat Sep 13, 2014 4:04 pm

Now I truly regret not ordering the same display as you have 0xFF, but the 20x2 version.. half price for my display got mee alot of extra work.. maybe I just order the 2002 oled from same type that you have if this doesnt seem to start working..

Well,
Got the write_byte_data values from the sample code, and changed some lines positions to match the order in sample code,
Well as you may notice I have no clue what I am doing, and no luck getting the display to show anything,
I changed the LCDd.conf to match the one 0xFF shared and changed only displaysize to 20x2.

Here is the initoled.py code that I am trying to run:

Code: Select all

#!/usr/bin/python
import smbus
import time
bus = smbus.SMBus(0)
address = 0x3C
bus.write_byte_data(address,0x80,0x2A)	# // **** Set "RE"=1<--->00101010B
bus.write_byte_data(address,0x80,0x71) # Function Selection A [71h] (IS = X, RE = 1, SD=0), 2bajty
bus.write_byte_data(address,0xc0,0x00) # 0x5C set Vdd
bus.write_byte_data(address,0x80,0x28)
bus.write_byte_data(address,0x80,0x08) #// **** Set Sleep Mode On
bus.write_byte_data(address,0x80,0x2A) #// **** Set "RE"=1 00101010B
bus.write_byte_data(address,0x80,0x79) #// **** Set "SD"=1 01111001B
bus.write_byte_data(address,0x80,0xD5) # Set Display Clock Divide Ratio/ Oscillator Frequency (D5h
bus.write_byte_data(address,0x80,0x70)
bus.write_byte_data(address,0x80,0x78) #// **** Set "SD"=0
bus.write_byte_data(address,0x80,0x08) #// **** Set Dispmode, 5-dot, 3 or 4 line(0x09), 1 or 2 line(0x08)
bus.write_byte_data(address,0x80,0x06) #// **** Set Com31-->Com0 Seg0-->Seg99
#// **** Select Character ROM *** //
bus.write_byte_data(address,0x80,0x72) #// **** Set ROM
bus.write_byte_data(address,0xc0,0x01) #// **** Set ROM A and 8 CGRAM
#**** Entering Set OLED Characterization
bus.write_byte_data(address,0x80,0x2A) #// **** Set "RE"=1
bus.write_byte_data(address,0x80,0x79) #// **** Set "SD"=1
#// **** CGROM/CGRAM Management*** //
bus.write_byte_data(address,0x80,0xDA) #// **** Set Seg Pins HW Config
bus.write_byte_data(address,0x80,0x10)
bus.write_byte_data(address,0x80,0xDC) #// **** Set Segment Low Voltage and GPIO
bus.write_byte_data(address,0x80,0x00)
bus.write_byte_data(address,0x80,0x81) #// **** Set Contrast
bus.write_byte_data(address,0x80,0x8F)
bus.write_byte_data(address,0x80,0xD9) #// **** Set Phase lenght
bus.write_byte_data(address,0x80,0xF1)
bus.write_byte_data(address,0x80,0xDB) #// **** Set VCOM deselect level
bus.write_byte_data(address,0x80,0x30) #// **** VCC x 0.83

bus.write_byte_data(address,0x80,0x78) #// **** Exiting Set OLED Characterization

bus.write_byte_data(address,0x80,0x28) #// **** Set "IS"=0 , "RE" =0 //28
bus.write_byte_data(address,0x80,0x01)
bus.write_byte_data(address,0x80,0x80) #// **** Set DDRAM Address to 0x80 (line 1 start)
time.sleep (0.1)
bus.write_byte_data(address,0x80,0x0C) #// **** Turn on Display
bus.write_i2c_block_data(address,0x40,[32,32,ord('i'),ord('n'),ord('i'),ord('t'),ord('.'),ord('.')])
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sat Sep 13, 2014 4:56 pm

Is your python code working without error ?
Double check init values. Check if display needs some "sleep" instructions during init.
Power down your display for while between tests.

Switch off LCDd daemon and leave related stuff for later. First of all, get working python init code.
I spent a lot of time to find some documentation and working code for my display.
But now it's working without problem and believe me, looks faaaaaar better than any other LCD display.

User avatar
joan
Posts: 14480
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 20x2 I2C OLED character display and XBMC = nothing

Sat Sep 13, 2014 5:38 pm

Which I2C bus is your OLED on? If it's bus 1 you need to set SMBus(1) rather than SMBus(0) in the code.

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = working

Sun Sep 14, 2014 5:30 pm

Image
Thank you 0xFF and joan !!!

I double checked the init file, changed the bus to 1. Ran it and voila. It is alive :)

Thank you so so much

The code I posted earlier is now verfied as working init code for:
ER-OLEDM2002-1 20x2 OLED DISPLAY

Just change the bus to match where the display is connected :roll:

The display needs the RESET pin pulled low unless it will not show in i2cdetect, or work.
{first low then high then 0.1s pause before init, did code for GPIO6 to do this} //EDIT 15.9.2014
(shows once about every 4times when checked)

http://www.buydisplay.com/download/ic/US2066.pdf
page 17 / 5.7 Power ON and OFF Sequence when LV I/O mode is chosen
Last edited by 1958 on Thu Jan 15, 2015 10:36 am, edited 3 times in total.
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sun Sep 14, 2014 5:35 pm

Nice screen ;-)

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sun Sep 14, 2014 5:50 pm

0xFF wrote:Nice screen ;-)
:mrgreen: I think so too
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sun Sep 14, 2014 6:16 pm

For fun with XBMC, you need to download lcdproc sources from http://www.lcdproc.org/ and patch hd44780-i2c.c file
like I did here: https://github.com/0xFACE/RPi-OLED-Disp ... 4780-i2c.c

I'm not good coder, so it is just dirty hack for hdd44780-i2c driver.

Build sources, copy hd44780.so file to /usr/lib/lcdproc (overwrite original file) , setup /etc/LCDd.conf and .xbmc/userdataLCD.xml, install lcdproc plugin for xbmc.
Now start your favorite music/video and enjoy your brand new display ;-)

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sun Sep 14, 2014 7:06 pm

0xFF wrote:For fun with XBMC, you need to download lcdproc sources from http://www.lcdproc.org/ and patch hd44780-i2c.c file
like I did here: https://github.com/0xFACE/RPi-OLED-Disp ... 4780-i2c.c

I'm not good coder, so it is just dirty hack for hdd44780-i2c driver.

Build sources, copy hd44780.so file to /usr/lib/lcdproc (overwrite original file) , setup /etc/LCDd.conf and .xbmc/userdataLCD.xml, install lcdproc plugin for xbmc.
Now start your favorite music/video and enjoy your brand new display ;-)
Oh, thanks, I will try to get it running next week. Was just about to ask whats next,
does it matter that I have lcdproc plugin all ready installed?
Can I just overwrite the hd44780.so with patched version and set userdataLCD.xml and LCDd.conf to match my display?
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Sun Sep 14, 2014 9:04 pm

1958 wrote:
Oh, thanks, I will try to get it running next week. Was just about to ask whats next,
does it matter that I have lcdproc plugin all ready installed?
No, that's no problem.
1958 wrote: Can I just overwrite the hd44780.so with patched version and set userdataLCD.xml and LCDd.conf to match my display?
Should be fine.

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Mon Sep 15, 2014 5:53 pm

Here is what i got after overwriting the hd44780.so file with new one..

Code: Select all

[email protected] ~ $ LCDd
Could not open driver module /usr/lib/lcdproc/hd44780.so: /usr/lib/lcdproc/hd44780.so: wrong ELF class: ELFCLASS64
Driver [hd44780] binding failed
Could not load driver hd44780
There is no output driver
Critical error while initializing, abort.
It seems I messed the driver, or did not manage to build it correctly..
on the working init file I used address 0xc0 as the second byte to write... /as the example code advised

Code: Select all

bus.write_byte_data(address,0x80,0x71) # Function Selection A [71h] (IS = X, RE = 1, SD=0), 2bajty
bus.write_byte_data(address,0xc0,0x00) # 0x00 set Vdd
when editing the hd44780i2c.c code I used data[2] for the second byte to write, maybe this is the error?

Code: Select all

data[1] = 0x71; 	//# Function Selection A  [71h] (IS = X, RE = 1, SD=0;, 2bajty
	i2c_out(p, data);
	data[2] = 0x00;  // 0x00 set Vdd
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Mon Sep 15, 2014 6:15 pm

No idea. Was the driver cross-compiled on 64bit system?

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = nothing

Mon Sep 15, 2014 7:12 pm

0xFF wrote:No idea. Was the driver cross-compiled on 64bit system?
Oops, I did compile the driver on my desktop.. will do it again with the pi tomorrow.. :)
The Raspberry Pi has much potential, if only I would know how to use it..

1958
Posts: 9
Joined: Fri Sep 12, 2014 1:31 pm
Location: Finland

Re: 20x2 I2C OLED character display and XBMC = WORKING!

Tue Sep 16, 2014 5:27 pm

Image

Here we go, I build the driver with pi and overwrite the hd44780.so and now it works like it should :)

Thank you very much for your help :ugeek:
The Raspberry Pi has much potential, if only I would know how to use it..

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Tue Sep 16, 2014 5:45 pm

Great. Good to see yet another device working with RPi ;-)

Gluck
Posts: 3
Joined: Wed Oct 15, 2014 5:45 pm

Re: 20x2 I2C OLED character display and XBMC = nothing

Wed Oct 15, 2014 6:11 pm

0xFF
Thanks for rewriting library for 20x2 I2C OLED.

I'm trying to rewrite you code to work with almost the same but 20x4 i2c OLED Op204i.
I'm change the init string like in sample from wide.hk
It is start working, but with issue.
When I try to send

Code: Select all

Hello="12345678901234567890"
Hello="09876543210987654321"
Hello="ABCDEFGHIJKLMNOPQRST"
Hello="abcdefghijklmnopqrst"
On screen i see

Code: Select all

12345678901234567890
MNOPQRSTIJKL
09876543210987654321
mnopqrstijkl
So there is wrong line sequence 1,3,2,4
3nd and 4th line is cuted and after L/l the line is start from begin of line.

I have try find where is in hd44780-i2c.c part with line adresses(offsets).
In arduino code I need to change array with row offsets.

Code: Select all

 void OLedI2C::cursPos(uint8_t col, uint8_t row)
 {
 int row_offsets[] = { 0x00, 0x20, 0x40, 0x60 };
 sendCommand(0x80 | (col + row_offsets[row]));
But i can't find such things in hd44780-i2c.c.

Sorry for my english and coding skills :)

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: 20x2 I2C OLED character display and XBMC = nothing

Wed Oct 15, 2014 7:28 pm

Is your display size correct ?

Code: Select all

# 
Specifies the size of the LCD.
# In case of multiple combined displays, this should be the total size.
Size=20x4
Try setting:

Code: Select all

ExtendedMode=yes

Gluck
Posts: 3
Joined: Wed Oct 15, 2014 5:45 pm

Re: 20x2 I2C OLED character display and XBMC = nothing

Thu Oct 16, 2014 8:07 am

0xFF wrote:Try setting:

Code: Select all

ExtendedMode=yes
Wow! :) Works like a charm.
So, RTFM :)

Thank you!

tenex
Posts: 1
Joined: Fri Nov 21, 2014 6:36 pm

Re: 20x2 I2C OLED character display and XBMC = nothing

Fri Nov 21, 2014 6:48 pm

1958 - I have exactly the same display. Since you've managed to make it work, can you please post a description of your solution? Otherwise I will have to gather the information that is scattered among several sites, with a good chance I make a stupid mistake somewhere on my way :-)

What I mean is:
- wiring (GPIO pin -> display pin)
- BS0-2 configuration at the display
- a compiled hd44780.so for Pi for download
- any other configuration steps needed.

Thanks in advance!

solaar1974
Posts: 5
Joined: Wed Dec 17, 2014 7:26 pm

Re: 20x2 I2C OLED character display and XBMC = nothing (solv

Wed Dec 17, 2014 8:00 pm

I need HELP :o
Last edited by solaar1974 on Wed Dec 17, 2014 10:40 pm, edited 1 time in total.

solaar1974
Posts: 5
Joined: Wed Dec 17, 2014 7:26 pm

Re: 20x2 I2C OLED character display and XBMC = nothing (solv

Wed Dec 17, 2014 10:37 pm

I have the same problem with a similar display ER-OLEDM1602-4, only in Volumio in Raspberry PI.
By factory interfacing manual
Image
to connect wires like this:
OLED (pin)<=====================(pin) P1

VDD (2)<-----------------------------------------(1) +3,3V

VSS (1)<------------------------------------------(6) GND
DB7 (3)<------------------------------------------(6) GND
DB6 (4)<------------------------------------------(6) GND
DB5 (5)<------------------------------------------(6) GND
DB4 (6)<------------------------------------------(6) GND
DB3 (7)<------------------------------------------(6) GND
RD/E (11)<---------------------------------------(6) GND
WR,R/W (12)<----------------------------------(6) GND
D/C,SA0 (13)<----------------------------------(6) GND
CS (15)<-----------------------------------------(6) GND

DB2 (8)<-----------------------------------------(3) GPIO2 (SDA1_I2C)
DB1 (9)<-----------------------------------------(3) GPIO2 (SDA1_I2C)
DB0 (10)<---------------------------------------(5) GPIO3 (SCL1_I2C)

RESET (14)<-----------------------------------(26) GPIO7 (SPI0_CE1_N) ???

Without capacitors & resistors.

SMD jumpers BS2-BS1-BS0 (0-1-0) in I2C
Image
Launched: sudo python /home/pi/init.py
Works.
Image
But I need to see information from lcdproc & mpdlcd (artist & title songs).
Replace original hd44780-i2c.c & LCDd.conf on files to user 0xFF:
https://github.com/0xFACE/RPi-OLED-Display-SSD1311
Started in terminal:
sudo /etc/init.d/LCDd restart
sudo mpdlcd --no-syslog &

[email protected]:~$ sudo /etc/init.d/LCDd restart
Restarting LCDd: LCDd.
[email protected]:~$ sudo mpdlcd --no-syslog &
[1] 18051
[email protected]:~$ INFO mpdlcd.lcdrunner LCD screen is 16x2
INFO mpdlcd.lcdrunner MPD screen added to lcdproc.
INFO mpdlcd.mpdwrapper Connecting to MPD server at localhost:6600
INFO mpd Calling MPD connect('localhost', 6600, timeout=None)
INFO mpdlcd.lcdrunner Starting update loop.

Display don't work ! :(((((

Much to ask users of the 1958 and 0xFF put to access the modified file hd44780.so , it can cause. Maybe somewhere I made a mistake, correct me, please. Thank U.

Return to “Troubleshooting”