SSD1309 OLED display support

Not sure if this is a support request or a feature request:)

I have a OLED (2.42" inch 12864 OLED Display Module IIC I2C SPI Serial for Arduino – diymore)

Its SSD1309 and not 1306.
I wired it to I2C and tested with an arduino and the u8g2lib. It works fine.

I use the following
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

And pulls the reset pin low on arduino setup
pinMode( 5, OUTPUT); // RES Pin Display
digitalWrite( 5, LOW);
delay (500);
digitalWrite( 5, HIGH);

The raspberry also detects the display, but I get nothing on the display

Any idea on what I could check or change to get it working, or is it simply not compatible?

Here is the settings I use in mycodo

This particular LCD is not currently supported by Mycodo. However, you got me thinking, why do LCDs have their own configuration page rather than being Functions? If they were Functions, users can create and import their own to add support for new LCDs and functionality. It would also make it easier to add new LCDs in general because it would follow the single-file module model that Functions currently operate under. I’m going to attempt a proof-of-concept with your SSD1309 and attempt to make a custom Function that you can import on the Configure → Custom Functions page.

I made some serious progress with getting displays to work as Functions. Here are some images of a simple 16x2 I2C LCD that was the first I ported since I had it on hand to test. I also developed an SSD1309 Module, attached below. In order to use this new module, you will need to get the yet-to-be released code by upgrading to master. Import the module on the Configure → Custom Functions page, then add it on the Setup → Function page. When testing, enable the Function option Log Level: Debug and watch the Daemon Log for any relevant lines if there happen to be any issues. Also let me know how it displays, if it does work. I sort of just guessed with the spacing of text.

SSD1309 Function Test Module 01: (17.7 KB)

This SSD1309 module is using the luma.oled library.

1 Like

Thx. That was fast!

I think I got it installed, but still no shining letters. I have attached the daemon log.

I could imagine this would mean something
2021-04-11 20:03:59,365 - ERROR - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - initialize_variables() Exception: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File “/var/mycodo-root/mycodo/controllers/”, line 79, in run
File “/home/pi/Mycodo/mycodo/functions/custom_functions/”, line 328, in initialize_variables
from luma.core.render import canvas
File “/var/mycodo-root/env/lib/python3.7/site-packages/luma/core/”, line 5, in
from PIL import Image, ImageDraw
File “/var/mycodo-root/env/lib/python3.7/site-packages/PIL/”, line 94, in
from . import _imaging as core

I forgot to include some dependencies. Can you run these commands, restart the Pi, and try again?

~/Mycodo/env/bin/pip install Pillow==8.1.2
sudo apt-get install libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5

According to the log I think it should work

2021-04-11 20:59:00,511 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Displaying: {0: '', 1: 'Text', 2: '', 3: '', 4: '', 5: '', 6: '', 7: '2021-04-11 20:59:00'}
2021-04-11 20:59:10,439 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 0, Channel: 0
2021-04-11 20:59:10,503 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 1, Channel: 1
2021-04-11 20:59:10,505 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 2, Channel: 2
2021-04-11 20:59:10,505 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 3, Channel: 3
2021-04-11 20:59:10,505 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 4, Channel: 4
2021-04-11 20:59:10,505 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 5, Channel: 5
2021-04-11 20:59:10,506 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 6, Channel: 6
2021-04-11 20:59:10,506 - DEBUG - mycodo.functions.lcd_ssd1309_i2c_01_64389f39 - Current Line: 7, Channel: 7

Im just not getting anything on the screen. I can see its at the 0x3c address, so im pretty sure its connected correctly. It might be that it just doesnt play nicely with the pi, it wasnt super expensive.
Which one would you recommend, if this one cant work?

Reset is connected to pin 7. Here is my config.

We’ll get it working. This is the development process. We keep running the code, fix any errors we encounter until it finally works. We’ve just begun to have the code actually executed to interact with the display.

Currently the Reset Pin option does not do anything. Does pulling RST low activate the display? You mentioned RST earlier but didn’t indicate if it was necessary for the display to operate.

Here’s another module to test (Test 02). It adds a delay after rendering the screen in case the function ending causes the screen to clear. RST is still not used, so please try pulling low/high to see if it has an effect while the Function is activated. (18.1 KB)

This is a new test module (Test 03) that includes colorization because it may be displaying text but it may be the same color as the background. This creates a black background and colors the text white. As before, test with RST pulled low/high while the Function is active. (18.3 KB)

Ill give them a try.

I got the display working using the luma.oled library. I followed they install guide and fired up one of the demos with the -d ssd1309. So I know now the display is working correctly.
I didnt specify the reset pin in the demo (its at pin 7), so I guess it should work with the reset pin being cycled.

Success, I tested the 03.

There is a white frame around the screen that collides with the outer lines + the last line is colliding with the second last, but other than that it looks fine.

I would delete the frame and move the last line down 2 pixel. Maybe also “unbold” the font. For instance, when it display “NONE” (Timestamp or mesurement missing) its unreadable.

The missing part in the bottom screen is photo glitch.

1 Like

I managed to fix it myself. I guess thats the advantage of splitting it into a seperate file.

There is a lot of update going on, i.e. the display is flickering very fast (you can see the camera captured the image mid update of the last line). Not a big issue really. Maybe its perceived this way, because its clearing the screen between updates. Dont know:)

Can you share your changes? I’m eventually going to add this to the built-in Functions, so I’d like it to be the best it can be. I assume you just removed the border and maybe changed the spacing?

There’s something I was testing in 02 and 03, which was a 5 second delay after drawing the screen. If this is unnecessary, I’d like to remove it, but we need to determine if it has an effect. So, if you have a Period of 10 seconds, does the display show for 5 seconds and then go blank for 5 seconds or is it on the entire 10 seconds?

As for the flickering, I’m not sure what would be causing that. It didn’t flicker when used with the arduino?

Its consistently on for the whole cycle and just updates every 10 second. I saw there was a Delay(5) in the code and actually played around with it because I though it was 5ms and it was causing the flickering. But it didnt seem to have an effect. Maybe if you set the update cycle time to 1 sec it would have an influence.

Basically all I did was change the spacing for the last line adding 2 px and outcommented the frame function. I’ll share it when I get back to another PC. Maybe its time for me to learn the hole github forking thing:)

The display Function only updates the display once every set Period. So, there’s something else going on unrelated to Mycodo or how it draws the display. I don’t own this display, so I can’t investigate the flickering myself.

Perhaps you have the RST pin connected to the Pi and you have not pulled this pin high or low and its floating is causing the flickering. Try disconnecting the RST pin.

I committed the SSD1309 Display Function a few days ago and it’ll be available in the next release.