Comments: Qwiic Micro OLED Hookup Guide

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • tomsax / about 6 years ago * / 2

    I am now talking to the OLED from a C/C++ program on the Raspberry Pi 3 B+.

    There is no data register, so you can skip that part of the initialization and just do the rest. Despite what the data sheet says, the OLED is 64x48, as stated in the product description. The DRAM buffer appears to be 128x64 (8 pages by 128 columns). The DRAM for the display starts on page 2 and column 32.

    Here are the key bits of code:

    #include <unistd.h>
    #include <wiringPiI2C.h>
    
    #define addrOLEDJumperOpen   0x3D
    #define addrOLEDJumperClosed 0x3C
    
    #define ctrlCommand 0x00
    #define ctrlData    0x40
    
    m_addrI2C = fJumperClosed ? addrOLEDJumperClosed : addrOLEDJumperOpen;
    
    m_fd = wiringPiI2CSetup(m_addrI2C);
    
    void OLED::SetPageAddress(uint8_t page)
    {
        Assert(0 <= page && page < cpageDisplayBuffer);
        page += 2;
        SendCommand(0xB0 + page);
    }
    
    void OLED::SetColumnAddress(uint8_t col)
    {
        Assert(0 <= col && col < ccolDisplayBuffer);
        col += 32;
        SendCommand(0x10 + (col>>4));
        SendCommand(0x00 + (col&0x0f));
    }
    
    void OLED::SendCommand(uint8_t cmd)
    {
        wiringPiI2CWriteReg8(m_fd, ctrlCommand, cmd);
    }
    
    void OLED::SendData(uint8_t b)
    {
        wiringPiI2CWriteReg8(m_fd, ctrlData, b);
    }
    

    • fourstix / about 6 years ago / 1

      I got mine to work with the Qwiic Hat and a Raspberry Pi 3 B+ using the luma.oled libraries. I followed this tutorial for basic information: http://codelectron.com/setup-oled-display-raspberry-pi-python/

      Just be aware that the display in the tutorial is a different i2c address and size. You'll need to modify the codelectron examples a little bit to run them on the Qwiic Micro OLED.

      I also installed the luma.examples from here https://github.com/rm-hull/luma.examples Using the command $ git clone https://github.com/rm-hull/luma.examples.git

      Those examples can take parameters for the dimensions and i2c address. Note that the params are double-dashed. So for example to run the analog clock example, I typed: $ cd luma.examples $ python clock.py --width 64 --height 48 --i2c-adress 0x03D

      and it worked as expected.

      Good luck to you!

  • fourstix / about 6 years ago / 1

    Just to follow up, here's a basic hello_world.py example using the luma.oled library to run the Qwiic Micro OLED on a Raspberry Pi 3:

    #!/usr/bin/env python
    
    from luma.core.interface.serial import i2c
    from luma.core.render import canvas
    from luma.oled.device import ssd1306
    
    # define device for Qwiic Micro OLED
    serial = i2c(port=1, address=0x3D)
    device = ssd1306(serial, width=64, height=48, rotate=0)
    
    
    def main():
          #repeat until Ctrl-C keyboard interrupt
          while True:
               with canvas(device) as draw:
                   draw.rectangle(device.bounding_box, outline="white", fill="black")
                   draw.text((10, 2), "Hello,", fill="white")
                   draw.text((10, 12), "World!", fill="white")
    
     if __name__ == "__main__":
         try:
              main()
         except KeyboardInterrupt:
              pass
    

  • tomsax / about 6 years ago / 1

    I got the Qwiic Micro OLED with a Raspberry Pi bundle, but the sample code here is for Arduino. Is there's a corresponding library and sample code for the Pi? I've read up on the wiringPi library and the SSD1306 data sheet, but I'm not having any luck getting it to work.


If you've found an issue with this tutorial content, please send us your feedback!