Strange behavior with Pyboard and ssd1306 display over I2C

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
theodox
Posts: 6
Joined: Sat Apr 13, 2019 11:55 pm

Strange behavior with Pyboard and ssd1306 display over I2C

Post by theodox » Sun Apr 14, 2019 12:33 am

I've been experimenting with a pyboard (running uPy 1.9.3) and a 128x32 OLED display controlled by an SSD1306. I used the 1.9.3 version of the ssd1306.py driver from the MicroPython github.

I've managed to connect to the display using I2C, and I can do some operations successfully. For example I can draw text to the screen or draw lines as I'd expect. However it seems like something goes off the rails if I try to do a fill or a blit to the display outside a certain range of pixels. Here's how I've been making the display object:

[code]
import ssd1306
from machine import I2C, Pin

def make_display():
sda = Pin.board.Y10
scl = Pin.board.Y9
bus = I2C (sda=sda, scl =scl)
display = ssd1306.SSD1306_I2C(128,32, bus)
[/code]

and here's something that works:

[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,7,7,1)
d.show()
# shows an 8-pixel rectangle in the upper left corner of the display
[/code]
However this does not work as expected:

[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,31,31,1)
d.show()
# should be a 32x32 block -- but the screen goes dark instead
[/code]

cycling poweroff() and poweron() calls will cause the larger rectangle to flicker visibly on the display for a moment, but then the display goes dark again. Once I'm in this mode I can't get the display to permanently reappear. Sometimes the

Somewhat related, the brightness of the display seems to diminish markedly if I'm using the entire addressable space: the 8x8 pixel block in my example above is nice and bright -- however if I do this:

[code]
d = make_display()
d.poweron()
d.rect (0,0,127,31,1)
d.show()
# 1-pixel line around display border
[/code]

The resulting image is so dim it's hard to make out in daylight.

I'm not clear where i could be off the rails here. Any suggestions for possible problems? I'm powering the OLED using the 3.3 out of the pyboard, which itself is 5v in from a USB (that i'm also using to control the board over a TTY). I tried rolling forward to the uPy 1.9.4 (the current github version) but that fails: the latest version of the SSD1306 driver inherits directly from FrameBuffer and my pyboard does not like that.

The hardware is here: https://vetco.net/products/0-91-128x32- ... ic-arduino

Online
User avatar
pythoncoder
Posts: 3452
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Strange behavior with Pyboard and ssd1306 display over I2C

Post by pythoncoder » Sun Apr 14, 2019 8:26 am

theodox wrote:
Sun Apr 14, 2019 12:33 am
... that fails: the latest version of the SSD1306 driver inherits directly from FrameBuffer and my pyboard does not like that...
The reason is that your Pyboard is running out of date firmware. I suggest you update to current (V1.10) firmware and use the current driver. At the very least it would make it easier for us to offer support and it might even fix the problem ;)
[EDIT]
That said, I've never seen dimming in my work on SSD1306 displays. Pixels are either on or off. So I'd also check the supply voltage and the integrity of the Gnd connection.
Peter Hinch

rhubarbdog
Posts: 166
Joined: Tue Nov 07, 2017 11:45 pm

Re: Strange behavior with Pyboard and ssd1306 display over I2C

Post by rhubarbdog » Sun Apr 14, 2019 8:27 am

Hi
I have an ssd1306 128x32 screen and all the programs you have given work.
I have added the missing line from snippet 1 `return display`
are you using this ssd1306.py
I downloaded it ages ago from another repo but it appears to have been accepted into the micropython repo. This is the version i have.

Your screen or pyboard is faulty. start with a new screen.

If you need some examples of putting text and graphics on the screen I can post code which I have previously downloaded, but no longer seems available on github

theodox
Posts: 6
Joined: Sat Apr 13, 2019 11:55 pm

Re: Strange behavior with Pyboard and ssd1306 display over I2C

Post by theodox » Sun Apr 14, 2019 5:31 pm

I picked up the breadboard to inspect the LED for damange -- no problems -- but when I accidentally dropped the breadboard a couple of inches to the ground the display returned in full brightness. I'm still not clear how a digital device could be so wonky with what must have been a touch connection -- but evidently it was not a software issue. Thanks for the help.

Of course, then I tried to get the same display connected to a Wipy3 -- but that's another story :(

ThomasChr
Posts: 113
Joined: Sat Nov 25, 2017 7:50 am

Re: Strange behavior with Pyboard and ssd1306 display over I2C

Post by ThomasChr » Mon Apr 15, 2019 5:08 am

I‘m not quite sure if dropping to the floor would have been my first suggestion, but glad it helped :-)

Post Reply