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

    Using i2C SSD1306

    Scheduled Pinned Locked Moved WiPy 2&3
    i2c example
    6 Posts 4 Posters 1.3k 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.
    • J Offline
      jimmie
      last edited by jimmie

      I am learning how to use the new board. Debugging is a lot easier using an LCD so I am trying to use the attached code with an SSD1306 but I am getting the error below. I would appreciate finding out how to fix this or if there is a simple program showing how to use an I2C LCD that would be also great.

      Thanks in advance.

      Running c:\Users\ttc\Desktop\Pycom Code\main.py
      
      >>>
      >>>
      ♦Traceback (most recent call last):
        File "<stdin>", line 11, in <module>
        File "/flash/lib/ssd1306.py", line 117, in __init__
        File "/flash/lib/ssd1306.py", line 37, in __init__
        File "/flash/lib/ssd1306.py", line 62, in init_display
        File "/flash/lib/ssd1306.py", line 122, in write_cmd
      TypeError: argument has wrong type
      ♦>
      Pycom MicroPython 1.18.1.r1 [v1.8.6-849-b0520f1] on 2018-08-29; WiPy with ESP32
      Type "help()" for more information.
      >>>
      >>>
      

      0_1539808713383_main.py

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

        @jimmie looks like line 9 should start with:
        i2c = I2C(0, ........
        And then in the next line i2c instead of I2C has to be used.

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          jimmie @robert-hh
          last edited by jimmie

          @robert-hh

          Thank you @robert-hh .

          changed to the code below and it now works.

          i2c = I2C(0, I2C.MASTER, baudrate=100000, pins=("P9","P10"))
          oled = ssd1306.SSD1306_I2C(128, 32, i2c)
          
          B 1 Reply Last reply Reply Quote 0
          • B Offline
            brossingo @jimmie
            last edited by

            @jimmie hey, did you manage to make it work? Because when I launch a quite similar piece of code to display things on screen, I got the following mistake :

            Traceback (most recent call last):
            File "<stdin>", line 133, in <module>
            File "<stdin>", line 112, in init
            File "<stdin>", line 40, in init
            File "<stdin>", line 67, in init_display
            File "<stdin>", line 92, in show
            File "<stdin>", line 122, in write_data
            AttributeError: 'I2C' object has no attribute 'start'

            I use the ssd1306.py as described on this link : https://github.com/pycom/pycom-micropython-sigfox/blob/master/drivers/display/ssd1306.py.

            robert-hhR T 2 Replies Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @brossingo
              last edited by

              @brossingo Change the method write_data() in class class SSD1306_I2C(SSD1306) to:

                  def hw_write_data(self, buf):
                      self.i2c.writeto(self.addr, b'\x40'+buf)
              

              The code in that lib is for the micropython.org branch and was never ported.

              1 Reply Last reply Reply Quote 0
              • T Offline
                throwaway @brossingo
                last edited by

                @brossingo FWIW, I managed to get such a display running with the development release firmware (version 1.20rc4) in combination with the write_data() change that robert-hh mentioned. This newer release is required in order to be able to make use the framebuf class.

                Here's a post with my notes: https://forum.pycom.io/post/24819

                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