ssd1306 not working??

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
F6EEQ
Posts: 4
Joined: Sat Aug 28, 2021 12:01 pm

ssd1306 not working??

Post by F6EEQ » Sat Aug 28, 2021 1:38 pm

Hi,
I tried to use a ssd1306 OLED on an ESP8266 board.
Program is exactly as in the µPy reference, and I got an error.

i2c is previously defined as : i2c = I2C(scl=Pin(5), sda=Pin(4))

And in the following line there is an error...

display = ssd1306.SSD1306_I2C(128, 64, i2c)

Interpreter says there is an argument missing, but neither in the original ssd1306 library nor in the Quick reference I've seen more than these 3 arguments...

I'm relatively new to µPy, so I may have missed something!

Thanks for help

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ssd1306 not working??

Post by Roberthh » Sat Aug 28, 2021 1:54 pm

So you also used the ssd1306.py file from the MicroPython repository at https://github.com/micropython/micropyt ... ssd1306.py ?
What exactly is the error message?

F6EEQ
Posts: 4
Joined: Sat Aug 28, 2021 12:01 pm

Re: ssd1306 not working??

Post by F6EEQ » Sat Aug 28, 2021 2:23 pm

Hi Robert, and thanks for answer.

As far as I could cross check, yes, the library is the correct one.
I downloaded it directly from Thonny menu.

Here is the error I got:

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
TypeError: function missing 1 required positional arguments

Line 5 is the bold one in my previous post.

Just to be complete, the whole module, exactly as in the Quick reference...:

from machine import Pin, I2C
import ssd1306

i2c = I2C(scl=Pin(5), sda=Pin(4))
display = ssd1306.SSD1306_I2C(128, 64, i2c)

display.text('Hello World', 0, 0, 1)
display.show()

Gerard.

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ssd1306 not working??

Post by Roberthh » Sat Aug 28, 2021 2:28 pm

I do not trust Thonny on that respect. Try to load the code to the device und run it from to he REPL prompt.

F6EEQ
Posts: 4
Joined: Sat Aug 28, 2021 12:01 pm

Re: ssd1306 not working??

Post by F6EEQ » Sat Aug 28, 2021 2:36 pm

I got exactly the same error with µPycraft...

F6EEQ
Posts: 4
Joined: Sat Aug 28, 2021 12:01 pm

Re: ssd1306 not working??

Post by F6EEQ » Sat Aug 28, 2021 2:51 pm

I did copy, one line after the other in the REPL, and when it comes to the "display =..." I still get the same error message.

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ssd1306 not working??

Post by Roberthh » Sat Aug 28, 2021 3:42 pm

I tried the same on my ESP8266 here. I do not own a SSD1306, so I just ran it without a display.
I get as expected a ETIMEDOUT error on the attempt so send commands to the display. But the display is instantiated fine.
Which firmware version do you use?

femtopy
Posts: 7
Joined: Mon Jun 07, 2021 4:57 am

Re: ssd1306 not working??

Post by femtopy » Sun Aug 29, 2021 9:19 pm

You're missing the first parameter, which tells the class what type of board. Try the following:

i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000)

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ssd1306 not working??

Post by Roberthh » Mon Aug 30, 2021 6:19 am

@femtopy: The statement instantiation the I2C object is correct. The initial poster uses an ESP8266 board, which implements SoftI2C only. SoftI2C does not require an I2C id.

femtopy
Posts: 7
Joined: Mon Jun 07, 2021 4:57 am

Re: ssd1306 not working??

Post by femtopy » Mon Aug 30, 2021 8:48 am

I just tried his code on my Pico with SSD1306 using Thonny and the error is due to the missing id.

Post Reply