Canada
Asked — Edited

Setup OLED I2C Display With EZ-B V4

I need help with setting up an I2C OLED display with the EZ-B v4.  The display is connected to the EZ-B v4 based on my understanding of the pin outs on the EZ-B I2C slot as per the manual.  The display doesn't seem to light up (not sure if it should) and I have no idea which skill I use to enable sending of text and EZ-B display information to the display. The display uses an SSD1307 Driver and the only datasheet I can find online is attached but not sure if it's the correct one?   SSD1307.pdf


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a new tool that will help unleash your creativity with programming robots in just seconds!

PRO
Canada
#1  

Hello @gjohal,

There is no skill in ARC for that display but you should be able to write an I2C script to communicate with it. Those displays usually operate at 3.3V so you can connect directly to the EZ-Bv4 I2C ports using SDA, SCL, 3.3V and GND.

You can likely port some Arduino (wiring) code over to Python or Javascript in ARC to make it work.

Those types of OLED displays don't light up until you send them the correct commands to turn on a pixel.

The SSD1306 is the more common type of this kind of OLED display, you may find more support for it out there.

Canada
#2  

I will try doing that and may need some help depending on how it goes. I double checked the wiring and it's correct so good to know it normally doesn't show a welcome screen when power is supplied.

PRO
Synthiam
#3  

Use the JavaScript i2c commands. Look at the data sheet to see what commands to send.

You’ll use this command the most: https://synthiam.com/Support/javascript-api/I2C/write

Canada
#4  

Thanks DJ, I will try out this week and reply here with results and questions depending on how it goes.

Canada
#5  

I finally did some more testing and I am still unable to get the display to work.  I verified the datasheet I have is correct but I get errors when trying to send and commands in the console.  Here is the recommended Software Initialization that is recommended:

void Init_IC() { Write_Command(0xAE); //Set Display Off Write_Command(0xD5); //Display divide ratio/osc. freq. mode Write_Command(0xA1); Write_Command(0xA8); Write_Command(0x1F); Write_Command(0xD3); //Set Display Offset Write_Command(0x23); Write_Command(0x40); //Set Display Start Line Write_Command(0xA1); //Segment Remap Write_Command(0xC8); //Set COM Output Scan Direction Write_Command(0xDA); //Set SEG Pins Hardware Configuration Write_Command(0x12); Write_Command(0x81); //Contrast control Write_Command(0x40); Write_Command(0xD9); //Set pre-charge period Write_Command(0x51); Write_Command(0xDB); //Set VCOMH Write_Command(0x20); Write_Command(0xA4); Write_Command(0xA6); //Set Normal Display Write_Command(0xAF); //Set Display On }

I can't get this to work as the first line doesn't define the value for init_ic() and I can't find what that value should be.  I also tried just the I2C commands in different variations but still get errors:

Attempt 1 I2C.write(0111100,00, [ezbIndex]) print(hello world)I2C.

Result Line 2: Unexpected identifier Done (00:00:00.0509233)

Attempt 2 I2C.write(0111100,00, [ezbIndex]) print("hello world")I2C.

Result Line 2: Unexpected identifier Done (00:00:00.0039224)

Attempt 3 I2C.write(0111100,00, [ezbIndex]) I2C.print("hello world")

Result Execution Error Line 1 Col 0 - ezbIndex is not defined Done (00:00:00.0084271)

Attempt 4 I2C.print("hello world")

Result Execution Error Line 1 Col 0 - Object has no method 'print' Done (00:00:00.0116615)

I am unsure of what command I should be using first so any help would be great.  I can send all the datasheet files if needed.

PRO
Canada
#6  

As your error suggests, your EZB index is not defined. Instead of writing [ezbIndex] you need to have [0]. Where 0 represents the EZB number you are connecting to in the connection skill.

Canada
#7  

Thanks for the reply Jeremie.

I am not sure which number to use as I am connecting to the 1st I2C port for the display. I tried changing [ezbindex] to [1] and [3] or even [I1] or [i2c] but I just get a different error:

I2C.write(0111100,00,[1]) print(hello world)I2C.

Result Execution Error Line 1 Col 0 - No public methods with the specified arguments were found.

I2C.write(0111100,00,[i2c]) print(hello world)I2C.

Result Execution Error Line 1 Col 0 - i2c is not defined

I know the Digital ports are D0-D23, but what do I use for the I2C ports?

PRO
Canada
#8   — Edited

It seems that you are placing a binary value for the I2C address, use hex, and using square brackets around the EZB index which aren't needed. Normally you are connecting to the EZB index 0 in the connection skill, unless you are connecting to 1 or 3 purposefully, keep that in mind.

There is no javascript print command, rather you'll want to use writeString.

Here's a javascript code sample:

I2C.write(0x3C, 54, 0);
I2C.writeString(0x3C, "hello world");
Canada
#9  

I tried the sample code and I don't get an error but nothing is displayed on the the OLED display.  Is the next step to find the right Hex value to place the text or does the display need to be initialized first? SSD1307_1.4.pdf2.08-20812832LW.pdf  I have attached the Datasheet and reference file and on Page 22 it lists various commands with Hex values for Recommended Software Initialization but I'm not sure if I need to put those in using ARC or not.  Also guessing the commands might be different within ARC.

PRO
Synthiam
#10  

Is the red light on the ezb staying on after you send the command? Might not be connected correctly. Or wrong data is being sent

PRO
Canada
#11  

@gjohal I was just giving you an example that compiles. You will need to do the research in order to have the correct i2C address, send the correct initialization commands and the proper sequence and timing. You’ll also need to figure out if you have a short enough cable and strong enough pull up resistors. There is much work to be done with a new i2C display such as this if you want to get it working.

As suggested, if it were me I would have started with the more common SSD1306 Display, that way you have a ton of example code out there that you can work from and port over. That way you have a better idea of how these OLED displays work before using an uncommon one.

Canada
#12  

@DJSURES- I just see a blue main light and when I send the command, I see a small light flash that appears to be Red, then it goes off.

@Jeremie- Thanks for explaining and I will review the initialization commands and see if I can find the right commands to get it working.

PRO
Synthiam
#13  

If the red light flashes but doesn't stay on, that means the i2c device has received the command. That's a good thing because it's a command that has been accepted.

The challenge is going to be how the command is expected. You see, protocols like UART are serial and that means the commands can be sent and received in the order as expected. Multiple script commands (i.e. uart.write) can be separated in the script. However, when using i2c, the commands are generally expected by the receiver (slave) in the i2c write command. That's because the i2c is reset after each command. So, in order to write text that requires writing to the decimal address 54, the text would also need to be appended. And because of that, the ASCII text might have to be split into a decimal/hexadecimal array.

However, I doubt that is the case - but it's difficult for me to say because I don't have that device to test with. You're learning a lot and don't be discouraged. While we make it easy to send commands, the difficulty will be identifying what commands need to be sent.

Canada
#14  

Good to know and will try to work on this and send updates when I hopefully make some progress.