I2C OLED Screen Error
-
Hello all,
I am running into an issue when I am trying to display text on my oled display. My code is as follows:
from machine import I2C import ssd1306 i2c = I2C(0, pins=('P9','P10')) print(i2c.scan()) display = ssd1306.SSD1306_I2C(128,64,i2c,60) display.fill(0) display.text('Hello', 0, 0) display.text('from', 0, 16) display.text('MicroPython!', 0, 32) display.show()
I get an error on line 8 that says TypeError: object with buffer protocol required. I'm using the ssd1306 library and I'm not sure how to resolve this issue.
Has anyone else run into this issue before and if so how did you resolve it?
-
@kjm All versions have a usable I2C. The case here is a different one, I assume.
@shanefowler25 : Can you publish the full error message you got. It should be more than one line. The framebuffer module is included now. It sneaked in when Pycom moved to MicroPython core V1.11.
-
Thank you for the responses. I ended up using the library in the https://forum.pycom.io/topic/3900/object-with-buffer-protocol-required/2 post to help me resolve my issues.
-
@robert-hh said in I2C OLED Screen Error:
uses a i2c in write_data() a method called i2c.writevto(), which is not implemented in the Pycom firmware.Hey Robert does the 'Robertised' version of 1.20.1.r1 with adhoc wifi you did for me a few days back have usable I2C? I might revisit the serial oled idea again if it does.
-
@shanefowler25 This error comes up when a string, bytes or bytearray is expected, but something else is supplied. I do not see that in the code. Am I right that line 8 is:
display = ssd1306.SSD1306_I2C(128,64,i2c,60)
Besides that, I'm pretty sure that hsi driver won't work. I uses a i2c in write_data() a method called i2c.writevto(), which is not implemented in the Pycom firmware. You can rebuild that, or change write_data() into:
def write_data(self, buf): self.i2c.writeto(self.addr, b'\x40'+buf) ```.
-
also what kind of oled panel do you use?
-
what does i2c.scan() gives back?