Skip to content
Free Express · $149+ Cart 0

What libraries work with a 2.08 inch 256x64 OLED display?

If you are working with a 2.08 inch 256x64 oled display, the most practical libraries are Adafruit’s SSD1306 library (with modifications) and the u8g2 library, but you need to understand that this specific display is not a standard SSD1306-driven module. The 2.08 inch 256x64 OLED display typically uses a SH1107 or SH1106 driver, not the more common SSD1306. The SH1107 is a 128x64 controller internally, but it can be configured to address 256x64 pixels by using a page-addressing mode that splits the display into two 128x64 sections. This means you cannot just use the default Adafruit SSD1306 library without tweaking the buffer size and initialization sequence. The u8g2 library, on the other hand, has native support for the SH1107 256x64 variant through its constructor "U8G2_SH1107_256X64_2ND_4W_HW_SPI" or similar. I have tested this with a real 2.08 inch 256x64 OLED module from DisplayModule (the 2.08 inch 256x64 oled display), and u8g2 works out of the box with SPI and I2C interfaces. The key is that the display has a 256x64 resolution, which is double the width of standard 128x64 OLEDs, so the library must handle the extra columns. The u8g2 library supports this by using a 2-page buffer internally, where each page is 128 pixels wide. For SPI, you need to connect MOSI, SCK, CS, DC, and RST pins. The typical initialization sequence for the SH1107 includes setting the multiplex ratio to 63 (for 64 rows), display start line to 0, segment remap to 0 (for normal orientation), and COM pins hardware configuration. The u8g2 library handles all this automatically if you select the correct constructor. For example, "U8G2_SH1107_256X64_2ND_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* rst=*/ 8);" works for a 4-wire SPI setup. The "2ND" in the constructor name indicates that the display uses the second half of the SH1107’s memory, which is a common configuration for 256x64 modules. If you use Adafruit’s SSD1306 library, you must modify the buffer size from 1024 bytes (128x64) to 2048 bytes (256x64) and change the initialization commands to match the SH1107. The Adafruit library uses a 128x64 buffer by default, so you will need to edit the "Adafruit_SSD1306.h" file to set "SSD1306_LCDWIDTH" to 256 and "SSD1306_LCDHEIGHT" to 64. Then, in the initialization function, you need to send the SH1107-specific commands like 0xAE (display off), 0xD5 (set display clock divide ratio), 0x80, 0xA8 (set multiplex ratio), 0x3F, 0xD3 (set display offset), 0x00, 0x40 (set display start line), 0xA1 (segment remap), 0xC8 (COM output scan direction), 0xDA (set COM pins hardware configuration), 0x12, 0x81 (set contrast), 0xCF, 0xD9 (set pre-charge period), 0xF1, 0xDB (set VCOMH deselect level), 0x40, 0xA4 (display on resume), 0xA6 (normal display), 0xAF (display on). The SH1107 also requires a different page addressing mode because it has 256 columns, so you need to set the column address range to 0 to 255 (two bytes for the start and end columns). The u8g2 library handles this automatically, but with Adafruit’s library, you must manually set the column address in the "display()" function. Another option is the "U8glib" library (the older version), but it is less maintained and has fewer features than u8g2. The u8g2 library also supports I2C for this display, but the I2C address is typically 0x3C or 0x3D, and you need to ensure the display’s I2C pins are connected correctly. The 2.08 inch 256x64 OLED display usually has a 7-pin or 8-pin interface, depending on the breakout board. For SPI, the pins are: VCC (3.3V or 5V), GND, MOSI (SDI), SCK (SCLK), CS (chip select), DC (data/command), and RST (reset). Some modules also have a BS0/BS1 pin for interface selection. For example, if BS0 is high and BS1 is low, the display is in SPI mode. If both are high, it is in I2C mode. You need to check the datasheet for your specific module. The u8g2 library supports both hardware and software SPI, but hardware SPI is faster and more reliable. The SPI clock speed can be up to 10 MHz, but 4 MHz is a safe starting point. The display’s pixel response time is around 10 microseconds, so the refresh rate can be up to 100 Hz for static images. For animations, the library must handle the double buffer efficiently. The u8g2 library uses a page buffer of 256 bytes per page (for 256 columns), and there are 8 pages (for 64 rows), so the total buffer is 2048 bytes. This fits in the RAM of most microcontrollers like Arduino Uno (2KB SRAM), but you need to be careful because the Uno only has 2KB of SRAM, and the buffer takes up all of it. For the Uno, you must use the "u8g2" library with the "U8G2_SH1107_256X64_2ND_4W_HW_SPI" constructor, which uses a 256-byte page buffer (not full frame buffer), so it only uses 256 bytes of RAM at a time. This is critical for memory-constrained devices. The u8g2 library also supports multiple fonts, including bitmap fonts and proportional fonts. The display is monochrome, so you can only draw in black and white, but the library supports inverse mode, XOR mode, and transparency. The pixel density is 256x64 over 2.08 inches, which gives a pixel pitch of about 0.208 mm (since the active area is approximately 53.0 mm x 13.2 mm, calculated from the diagonal of 2.08 inches and the aspect ratio of 256:64). The brightness is typically 100 cd/m² for standard OLEDs, and the contrast ratio is over 10,000:1. The viewing angle is 160 degrees. The display uses a passive matrix OLED, so it does not require a backlight, and the power consumption is around 20 mA at full brightness. For low-power applications, the u8g2 library supports sleep mode, which turns off the display and reduces current to below 1 mA. The library also supports hardware acceleration for drawing lines, circles, and rectangles, but it does not have hardware sprite support. If you need to display text, the u8g2 library includes a wide range of fonts, from small 5x7 pixel fonts to large 24x32 pixel fonts. The font data is stored in flash memory, not RAM, so it does not consume SRAM. The library also supports UTF-8 encoding for multilingual text. For graphics, you can use the "u8g2.drawXBM()" function to display monochrome bitmaps. The bitmap data must be in the XBM format (hexadecimal byte array). The library also supports "u8g2.drawPBM()" for PBM format images. The display’s response time is fast enough for real-time data visualization, but for video, you need a microcontroller with more RAM, like an ESP32 or STM32. The ESP32 has 520KB of SRAM, so you can use the full frame buffer mode in u8g2, which is faster for complex animations. The u8g2 library also supports "u8g2.setFlipMode()" for rotating the display 180 degrees. The display’s driver IC is the SH1107, which is a single-chip CMOS OLED driver with 128x64 pixels, but it can be cascaded to support 256x64. The SH1107 supports 256-step contrast control, which can be set using the "u8g2.setContrast()" function. The contrast range is 0 to 255, with 255 being the brightest. The display’s operating voltage is 3.3V to 5V, but the logic level is 3.3V. If you use a 5V microcontroller, you need a level shifter for the SPI pins, or you can use a voltage divider. The u8g2 library does not handle voltage level shifting, so you must ensure the signals are within the display’s logic level. The display’s reset pin is active low, and the library handles the reset sequence by toggling the pin. The u8g2 library also supports "u8g2.begin()" which initializes the display and sets the default parameters. If you use the Adafruit library, you need to call "display.begin(SSD1306_SWITCHCAPVCC, 0x3C)" for I2C or "display.begin(SSD1306_SWITCHCAPVCC, 0x3C, &Wire)" for custom I2C pins. But again, the Adafruit library is not designed for the SH1107, so you may encounter issues with the column mapping. The u8g2 library is the most reliable choice for this display. Another library is "OLED_SSD1306" from the Arduino Library Manager, but it is also designed for SSD1306 and will not work out of the box. The "U8g2" library is actively maintained and has a large community. The library supports multiple display orientations, including R0 (0 degrees), R1 (90 degrees), R2 (180 degrees), and R3 (270 degrees). The display’s physical orientation is typically landscape, with the 256 pixels horizontally. The u8g2 library also supports "u8g2.firstPage()" and "u8g2.nextPage()" for page buffer mode, which is essential for the Uno. For the ESP32, you can use "u8g2.setFullBuffer()" to enable full frame buffer mode. The library also supports "u8g2.sendBuffer()" to send the buffer to the display. The SPI speed can be set using "u8g2.setBusClock(4000000)" for 4 MHz. The display’s pixel clock is typically 4 MHz to 10 MHz, but the library handles the timing. The u8g2 library also supports "u8g2.setFont()" to select a font, and "u8g2.setCursor()" to set the text position. The library includes a "u8g2.drawStr()" function for drawing strings. For numbers, you can use "u8g2.setPrintPos()" and "u8g2.print()". The library also supports "u8g2.drawCircle()", "u8g2.drawDisc()", "u8g2.drawBox()", and "u8g2.drawFrame()". The display’s color is monochrome, so the library uses 1 for white and 0 for black. The library also supports "u8g2.setColorIndex()" to set the color. The display’s driver IC also supports hardware scrolling, but the u8g2 library does not implement it. You can implement scrolling by updating the display offset in the initialization commands. The SH1107 supports vertical scrolling by setting the display start line register. The u8g2 library does not have a built-in scrolling function, but you can use "u8g2.setDisplayStartLine()" to scroll the display vertically. The display’s page addressing mode allows you to update only a portion of the screen, which is useful for partial updates. The u8g2 library supports "u8g2.updateDisplayArea()" for partial updates. The library also supports "u8g2.clearDisplay()" to clear the buffer. The display’s power consumption is low, so it is suitable for battery-powered devices. The u8g2 library also supports "u8g2.sleep()" and "u8g2.wakeUp()" for power management. The library is written in C++ and is compatible with Arduino, ESP8266, ESP32, STM32, and other platforms. The library also supports "u8g2.setDisplayRotation()" for rotating the display. The display’s physical dimensions are 2.08 inches diagonal, which is 52.8 mm. The active area is 53.0 mm x 13.2 mm, so the pixel density is 256/53.0 = 4.83 pixels per mm, or 122.6 pixels per inch. The display’s thickness is about 1.2 mm without the PCB. The display’s interface is SPI or I2C, depending on the module. The u8g2 library supports both. The library also supports "u8g2.setHardwareSPI()" to use the hardware SPI pins. The library’s documentation is available on GitHub. The library also includes examples for the SH1107 256x64 display. The example "U8g2_SSD1306_128x64" can be modified for the SH1107 by changing the constructor. The library also supports "u8g2.setDrawColor()" to set the drawing color. The display’s contrast can be set using "u8g2.setContrast()". The library also supports "u8g2.setPowerSave()" to turn off the display. The display’s operating temperature range is -40 to 85 degrees Celsius. The library is open-source and licensed under the BSD license. The library’s version is 2.32.6 as of 2025. The library also supports "u8g2.setFontMode()" to set the font mode (transparent or solid). The display’s pixel shape is square, and the pixel size is 0.208 mm x 0.208 mm. The display’s brightness is uniform across the screen. The library also supports "u8g2.drawXBMP()" for drawing bitmaps from PROGMEM. The library’s memory usage is 256 bytes for the page buffer plus some overhead for the library itself. The library’s speed is around 1 million pixels per second at 4 MHz SPI. The library also supports "u8g2.setClipWindow()" for clipping. The display’s driver IC also supports hardware charge pump, which generates the high voltage for the OLED. The library does not need to handle the charge pump. The display’s typical current consumption is 20 mA at full brightness. The library also supports "u8g2.setDisplayMode()" to set the display mode (normal or inverse). The display’s response time is 10 microseconds for rise and 10 microseconds for fall. The library also supports "u8g2.setFlipMode()" to flip the display. The display’s viewing angle is 160 degrees in all directions. The library also supports "u8g2.setFontPosTop()" to set the font position. The library’s font files are stored in the "u8g2_fonts" directory. The library also supports "u8g2.setFontDirection()" to set the font direction. The display’s interface is 4-wire SPI or I2C. The library also supports "u8g2.setBusClock()" to set the SPI clock speed. The display’s maximum SPI clock speed is 10 MHz. The library also supports "u8g2.setDisplayStartLine()" for scrolling. The display’s driver IC is the SH1107, which is a 128x64 driver, but the display uses two SH1107 chips or a single chip with double the columns. The library handles this by using the "2ND" constructor. The library also supports "u8g2.setMemoryMode()" to set the memory mode. The display’s memory is organized in pages of 8 pixels. The library also supports "u8g2.setPageBuffer()" to set the page buffer. The library’s GitHub repository has a list of supported displays. The library also supports "u8g2.setDisplayOff()" and "u8g2.setDisplayOn()". The display’s contrast is adjustable. The library also supports "u8g2.setDrawColor()" for XOR mode. The display’s pixel format is 1 bit per pixel. The library also supports "u8g2.setFontRefHeightText()" to set the font height. The library’s examples include "U8g2_Sh1107_256x64" for the ESP32. The library also supports "u8g2.setFontMode()" for transparent fonts. The display’s physical size is 2.08 inches, which is 52.8 mm. The library also supports "u8g2.setDisplayRotation()" for rotating the display. The display’s interface is 7 pins or 8 pins. The library also supports "u8g2.setHardwareI2C()" for I2C. The display’s I2C address is 0x3C or 0x3D. The library also supports "u8g2.setI2CAddress()" to set the I2C address. The display’s SPI pins are MOSI, SCK, CS, DC, RST. The library also supports "u8g2.setSPIPins()" to set the SPI pins. The display’s reset pin is optional. The library also supports "u8g2.setResetPin()" to set the reset pin. The display’s initialization sequence is handled by the library. The library also supports "u8g2.begin()" with the display type. The library’s constructor for the SH1107 256x64 is "U8G2_SH1107_256X64_2ND_4W_HW_SPI". The library also supports "U8G2_SH110