Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    I2C OLED Screen Error

    Scheduled Pinned Locked Moved MicroPython
    ssd1306oleddisplayi2cmicropython
    7 Posts 4 Posters 608 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • shanefowler25S Offline
      shanefowler25
      last edited by

      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?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • T Offline
        tttadam
        last edited by

        what does i2c.scan() gives back?

        1 Reply Last reply Reply Quote 0
        • T Offline
          tttadam
          last edited by

          also what kind of oled panel do you use?

          1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @shanefowler25
            last edited by

            @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)
            ```.
            K 1 Reply Last reply Reply Quote 0
            • K Offline
              kjm @robert-hh
              last edited by

              @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.

              robert-hhR 1 Reply Last reply Reply Quote 0
              • shanefowler25S Offline
                shanefowler25
                last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @kjm
                  last edited by

                  @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.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom