Views: 222 Author: Tina Publish Time: 2025-06-19 Origin: Site
Content Menu
● Understanding the SH1106 OLED Screen
● Hardware Specifications and Pinout
● Wiring the SH1106 OLED to Microcontrollers
>> Connecting to Arduino (I2C)
>> Connecting to Raspberry Pi (I2C)
● Setting Up the Software Environment
>> Arduino
● Initializing and Testing the Display
>> Arduino
>> Raspberry Pi
● Displaying Text, Numbers, and Graphics
>> Text Display
>> Drawing Lines, Rectangles, and Circles
● Drawing Images and Animations
>> Animations
● Advanced Features: Scrolling, Contrast, and Power Modes
>> Scrolling
>> Power Modes
● Troubleshooting Common Issues
>> 1. What is the default I2C address for SH1106 OLED screens?
>> 2. Can I use the SH1106 OLED with both Arduino and Raspberry Pi?
>> 3. How do I display custom images on the SH1106 OLED?
>> 4. Why is my SH1106 OLED screen blank or flickering?
>> 5. How can I improve the display contrast or reduce power consumption?
OLED displays have become a staple in modern electronics projects due to their crisp visuals, low power consumption, and versatility. Among the various OLED controllers, the SH1106 stands out for its widespread use in 1.3-inch 128x64 pixel screens. Whether you are building a DIY gadget, upgrading a Raspberry Pi project, or adding a display to your Arduino, mastering the SH1106 OLED screen opens up a world of creative possibilities.
This in-depth guide will walk you through everything you need to know about using the SH1106 OLED screen. From understanding its hardware features to wiring, coding, displaying text, graphics, and troubleshooting, this article aims to be your definitive resource. Throughout the article, you will find illustrative diagrams, code snippets, and detailed explanations to enhance your learning experience.
The SH1106 is a single-chip CMOS OLED/PLED driver with a controller, designed for monochrome dot-matrix graphic displays. It supports resolutions up to 132x64 pixels and is commonly found in 1.3-inch displays with a 128x64 pixel active area. The SH1106 offers multiple interface options, including I2C, 3-wire SPI, and 4-wire SPI, making it compatible with a wide range of microcontrollers and single-board computers.
One key distinction between the SH1106 and similar controllers like the SSD1306 is the slightly larger internal memory addressing of the SH1106, which accounts for 132 columns even though only 128 are visible on the screen. This difference means that some libraries designed for SSD1306 may not work perfectly with SH1106 without modification.
The SH1106's internal architecture allows for efficient control of the OLED pixels, enabling high contrast and fast refresh rates. Its monochrome nature means it displays pixels as either on or off, which simplifies rendering but also requires creative use of dithering or animation for more complex visuals.
Key Features:
- Display Size: 1.3 inches
- Resolution: 128x64 pixels (active area)
- Controller: SH1106
- Interface: I2C (default), 3-wire SPI, 4-wire SPI
- Operating Voltage: 3.3V to 5V (check your module)
- Viewing Angle: >160°
- Colors: Monochrome (typically blue, white, or yellow)
- Operating Temperature: -20°C to 70°C
Pinout Diagram:
Below is a typical pinout for an SH1106 OLED module using I2C:
Pin | Function | Description |
---|---|---|
GND | Ground | Connect to microcontroller GND |
VCC | Power Supply | 3.3V or 5V depending on module |
SCL | I2C Clock | Serial clock line |
SDA | I2C Data | Serial data line |
For SPI mode, additional pins like CS (Chip Select), DC (Data/Command), and RES (Reset) are used. Always refer to your specific module's datasheet for exact pin labeling.
The physical layout of the pins may vary between manufacturers, so it is crucial to verify the pin functions before wiring. Some modules also include a reset pin or allow switching between I2C and SPI via solder jumpers or pins.
The most common and straightforward way to connect the SH1106 OLED to an Arduino is via the I2C interface. This method uses only four wires, simplifying connections and reducing pin usage.
1. Connect GND on the OLED module to the Arduino GND pin.
2. Connect VCC on the OLED to the Arduino 3.3V or 5V pin, depending on your module's voltage requirements.
3. Connect SCL on the OLED to the Arduino's SCL pin (A5 on Uno/Nano).
4. Connect SDA on the OLED to the Arduino's SDA pin (A4 on Uno/Nano).
Ensure that your Arduino board supports I2C on these pins or use the dedicated I2C pins on boards like the Arduino Mega or Leonardo.
For Raspberry Pi, the SH1106 OLED can be connected via the Pi's I2C interface:
1. Connect GND on the OLED to any GND pin on the Pi.
2. Connect VCC to the Pi's 3.3V pin (do not use 5V unless the OLED module supports it).
3. Connect SCL to the Pi's SCL pin (GPIO 3).
4. Connect SDA to the Pi's SDA pin (GPIO 2).
Before running your code, enable I2C on the Raspberry Pi via `raspi-config` and install necessary libraries.
If your SH1106 module supports SPI, wiring will involve additional pins:
- CS (Chip Select): Selects the device for SPI communication.
- DC (Data/Command): Switches between sending data or commands.
- RES (Reset): Resets the display.
Connect these pins to available GPIOs on your microcontroller and configure your software accordingly.
To work with the SH1106 OLED on Arduino, you need to install a compatible library. The U8g2 library is highly recommended because it supports SH1106 displays and offers a wide range of fonts and graphics functions.
- Open the Arduino IDE.
- Go to Sketch > Include Library > Manage Libraries.
- Search for U8g2 and install it.
Once installed, include the library in your sketch and initialize the display with the correct constructor for SH1106.
After wiring and setting up the software, the next step is to initialize the display and perform a simple test to confirm everything works.
Begin by initializing the display in your `setup()` function. Then, clear the display buffer, set a font, and write a simple message to the screen. Finally, send the buffer to the display to render the content.
Using Python, initialize the device object and create a drawing canvas. Write text or draw shapes on the canvas, which will be rendered on the OLED screen.
This initial test confirms that your wiring is correct, the display is functional, and your software environment is properly configured.
Displaying text on the SH1106 involves selecting a font, positioning the cursor, and writing the string. The U8g2 library for Arduino and the luma.oled library for Python both support multiple fonts, including scalable and fixed-width fonts.
You can display static messages or dynamically update text, such as sensor readings or status updates. Positioning is controlled by pixel coordinates, allowing precise placement anywhere on the screen.
Numbers are typically converted to strings before display. This allows you to format decimal places, add units, or concatenate with other text. For example, displaying temperature readings or time values is straightforward.
The SH1106 supports basic graphic primitives. You can draw lines, rectangles (filled or outlined), circles, and other shapes. These are useful for creating custom UI elements like progress bars, frames, or icons.
Using these primitives combined with text allows you to build rich interfaces despite the monochrome display.
To display images, convert your graphics to monochrome bitmaps. This can be done using image editing software or online converters that output arrays of bytes representing pixel data.
Once converted, include the bitmap array in your code and use the display library's bitmap drawing functions to render the image.
Animating on the SH1106 involves updating the display buffer repeatedly with new frames. Since the display is monochrome and has limited resolution, animations are typically simple, such as blinking icons, moving bars, or frame-by-frame sprite animations.
Keep animations smooth by controlling the update rate and minimizing the amount of data sent per frame.
The SH1106 controller supports hardware scrolling in horizontal and vertical directions. This can be used to create marquee text effects or to scroll through menus.
Scrolling commands are available in the controller's instruction set and can be accessed via libraries or direct command sending.
Adjusting the contrast helps optimize visibility under different lighting conditions. Higher contrast improves readability but may increase power consumption.
Use library functions to set contrast levels dynamically based on ambient light or user preference.
The SH1106 supports sleep and wake modes to conserve power. When the display is not needed, putting it to sleep reduces current draw significantly.
Implementing power management is essential for battery-powered projects to extend operating time.
- Blank Screen: Double-check wiring, ensure the power supply is adequate, and verify the I2C address.
- Garbled or Partial Display: Confirm that you are using the correct library for SH1106 and not SSD1306. Also, check for loose connections.
- No Response: Make sure the display is not in sleep mode and that your microcontroller pins match your code configuration.
- Flickering: This can be caused by unstable power or incorrect initialization sequences. Use capacitors on power lines if necessary.
Thoroughly testing each step from wiring to code helps isolate issues quickly.
The SH1106 OLED screen is a versatile and powerful display solution for hobbyists and professionals alike. With its flexible interface options, crisp visuals, and robust library support, integrating it into your projects is straightforward. By following the steps outlined in this guide—covering hardware setup, software configuration, and advanced features—you can unlock the full potential of your SH1106 OLED display.
Whether you aim to display sensor data, graphics, or animations, the SH1106 offers reliable performance and creative flexibility. Experiment with different fonts, images, and effects to create engaging user interfaces for your electronics projects.
The default I2C address for most SH1106 OLED modules is 0x3C. Some modules may use 0x3D; always check your module's datasheet or test both addresses if you encounter issues.
Yes, the SH1106 OLED is compatible with both Arduino and Raspberry Pi platforms. You need to use the appropriate libraries for each platform and ensure correct wiring for I2C or SPI communication.
Convert your image to a monochrome bitmap (1-bit per pixel) using an image editor or online tool. Save the bitmap as a byte array in your code and use the display library's bitmap function to render it.
Common causes include incorrect wiring, insufficient power, wrong I2C address, or using a library designed for a different controller (such as SSD1306). Double-check your connections and library selection.
Use the display library's contrast adjustment function to set optimal contrast. To save power, enable sleep mode when the display is not in use, and reduce screen updates to the minimum necessary.
This article explores whether LCD display watches are more durable than smartwatches, comparing their construction, resistance to damage, battery life, and real-world performance. LCD display watches excel in shock resistance and longevity, while smartwatches offer advanced features but require more maintenance.
LCD display touch screens are widely used in smartphones, tablets, industrial controls, medical devices, vehicles, education, gaming, and smart homes. Their intuitive, versatile, and durable design makes them ideal for a broad range of applications, enhancing user experience and operational efficiency.
A 7 segment LCD display can show all numbers and a limited set of letters, making it ideal for simple numeric and basic text displays in clocks, meters, and consumer electronics. Its low power use and high visibility are key advantages, but its ability to display complex text is restricted.
This article explores why an LCD display monochrome is often preferred over color screens in various applications. It covers the technology behind monochrome LCDs, their advantages in power consumption, cost, readability, and durability, and compares them with color displays. The article also highlights common use cases, practical considerations, and future trends for choosing monochrome LCDs.
Apple's Mini LED screens look like OLED because of advanced local dimming, high brightness, and precise color calibration. This technology delivers deep blacks, vibrant colors, and high contrast, closely resembling OLED while avoiding its drawbacks. Mini LED is Apple's bridge to the future of displays.
This comprehensive guide explores which Lenovo laptops feature OLED screens, detailing their key features, benefits, and ideal use cases. It covers the Yoga, ThinkPad, IdeaPad, and Legion series, provides visual and feature showcases, and answers common questions to help you choose the perfect Lenovo OLED laptop.
Apple is preparing to launch an iPad Mini with an OLED screen, expected around 2026. This new model will feature a Samsung-made OLED panel, offering deeper blacks, brighter colors, and improved efficiency, though it may lack some high-end features found in the iPad Pro.
This article explores which display technology—LCD or OLED—holds up better to screen burn-in. It covers the science, real-world evidence, prevention tips, and user experiences, helping readers make an informed choice for their next display purchase.
This article explores which display technology—LCD or OLED—is more prone to screen burn-in. It explains the science, compares real-world experiences, and offers prevention tips. OLED is more susceptible to permanent burn-in, while LCD burn-in is rare and often reversible.
Light bleeding, or backlight bleed, is a common issue in LCD screens where light leaks from the edges or corners, causing uneven brightness. This article explores causes, diagnosis, DIY and professional fixes, and prevention tips for bleeding LCD displays, helping users restore optimal screen quality.
This article provides a comprehensive guide to the icons found in an electric bike LCD display manual, explaining their meanings, functions, and how to use them. It includes visual aids, video tutorials, troubleshooting tips, and advanced customization options to help riders confidently operate their e-bikes.
Transflective LCD displays blend transmissive and reflective technologies, providing outstanding visibility in all lighting conditions. Used in wearables, automotive, industrial, and outdoor devices, they offer energy efficiency and adaptability, making them vital for modern portable and rugged electronics.
This comprehensive guide explores the best LCD displays for DIY electric bikes, covering key features, types, top models, installation steps, troubleshooting, and expert tips. Learn how to select, install, and maintain the perfect electric bike LCD display for an optimal riding experience.
This article explores the inner workings of the monochrome LCD display, covering its structure, operation, types, and applications. Through diagrams and videos, it explains why these displays remain essential in modern electronics due to their efficiency, clarity, and reliability.
This in-depth guide explores which Arduino board is best for driving OLED screens, comparing popular models, providing wiring diagrams, programming tips, and project ideas. With detailed explanations and troubleshooting advice, it equips makers at all levels to confidently use OLEDs in their Arduino projects.
This guide explores the best 2-in-1 laptops with OLED screens in 2025, detailing their advantages, top models, and key considerations for buyers. It also answers common questions and compares leading devices to help you make an informed purchase.
This article is a comprehensive guide on where to buy a flexible OLED screen, covering the technology, advantages, applications, leading suppliers, buying tips, and maintenance advice. It also answers common questions and provides a step-by-step approach for buyers.
This article explores the nit value of Samsung OLED screens, detailing how brightness is measured, the latest advancements in OLED technology, and why high nit values are crucial for modern displays. It covers how Samsung achieves industry-leading brightness, compares OLED with other technologies, and answers key questions about display performance and user experience.
This article explores the origins, development, and impact of the first OLED screen, detailing the scientific breakthroughs, key inventors, and technological advances that shaped OLED into a leading display technology. It also addresses common questions and future prospects for OLED.
A reflective LCD display uses ambient light and a reflective layer to create visible images without a backlight, resulting in ultra-low power consumption and exceptional sunlight readability. It is ideal for outdoor and portable devices, with ongoing innovations bringing color and video capabilities to this technology.