Silicon ChipUsing Electronic Modules – 1.3-inch monochrome OLED - September 2024 SILICON CHIP
  1. Contents
  2. Publisher's Letter: Hello from the other side of the planet
  3. Feature: Techno Talk - I don’t want to be a Norbert... by Max the Magnificent
  4. Feature: The Fox Report by Barry Fox
  5. Feature: Net Work by Alan Winstanley
  6. Subscriptions
  7. Project: Build Your Own Calibrated Microphones by Phil Prosser
  8. Feature: Using Electronic Modules – 1.3-inch monochrome OLED by Jim Rowe
  9. Project: Modern PIC Programming Adaptor by Nicholas Vinen
  10. Feature: Circuit Surgery by Ian Bell
  11. Back Issues
  12. Feature: Audio Out by Jake Rothman
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Project: Salad Bowl Speakers by Phil Prosser
  15. Feature: Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley
  16. Back Issues
  17. PartShop
  18. Market Centre
  19. Advertising Index
  20. Back Issues

This is only a preview of the September 2024 issue of Practical Electronics.

You can view 0 of the 80 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Articles in this series:
  • The Fox Report (July 2024)
  • The Fox Report (September 2024)
  • The Fox Report (October 2024)
  • The Fox Report (November 2024)
  • The Fox Report (December 2024)
  • The Fox Report (January 2025)
  • The Fox Report (February 2025)
  • The Fox Report (March 2025)
  • The Fox Report (April 2025)
  • The Fox Report (May 2025)
Articles in this series:
  • Win a Microchip Explorer 8 Development Kit (April 2024)
  • Net Work (May 2024)
  • Net Work (June 2024)
  • Net Work (July 2024)
  • Net Work (August 2024)
  • Net Work (September 2024)
  • Net Work (October 2024)
  • Net Work (November 2024)
  • Net Work (December 2024)
  • Net Work (January 2025)
  • Net Work (February 2025)
  • Net Work (March 2025)
  • Net Work (April 2025)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
Articles in this series:
  • Audio Out (January 2024)
  • Audio Out (February 2024)
  • AUDIO OUT (April 2024)
  • Audio Out (May 2024)
  • Audio Out (June 2024)
  • Audio Out (July 2024)
  • Audio Out (August 2024)
  • Audio Out (September 2024)
  • Audio Out (October 2024)
  • Audio Out (March 2025)
  • Audio Out (April 2025)
  • Audio Out (May 2025)
  • Audio Out (June 2025)
Articles in this series:
  • Max’s Cool Beans (April 2024)
  • Max’s Cool Beans (May 2024)
  • Max’s Cool Beans (June 2024)
  • Max’s Cool Beans (July 2024)
  • Max’s Cool Beans (August 2024)
  • Max’s Cool Beans (September 2024)
  • Max’s Cool Beans (October 2024)
  • Max’s Cool Beans (November 2024)
  • Max’s Cool Beans (December 2024)
Articles in this series:
  • Teach-In 2024 (April 2024)
  • Teach-In 2024 (May 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (June 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (July 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (August 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (September 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (October 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (November 2024)
How to use Electronic Modules Using Electronic Modules with Jim Rowe 1.3-inch (33mm) Monochrome OLED Display Small monochrome OLED display modules have become widely available at a low cost in the last few years. Typically these measure only about 35×33mm but offer a 128×64 pixel resolution in a few different colours, like white or blue. Their I2C serial interface means that popular microcontrollers can easily drive them. O LEDs (organic light-emitting diodes) are solid-state light-­ emitting devices like standard LEDs. But instead of using a regular semiconductor P-N junction to emit light when passing a current, an OLED uses a thin film of an organic compound. As a result, displays using OLEDs tend to be thinner, lighter and use significantly less energy than those using traditional LEDs. In the last 15 or so years, they have become widely used in smartphones, handheld gaming consoles and, more recently, colour TVs. Small monochrome OLED displays are also used extensively in portable electronic equipment, so they have dropped significantly in price. Among the most popular are the 1.3inch (33mm) modules, such as the one shown in the photos. We have already used these in a couple of projects, like the MultiStage Buck/Boost Charger Adaptor from October 2023. These are available from a wide range of online suppliers, including via eBay, AliExpress and Amazon. Prices vary over a pretty wide range, about £3 up to nearly £10 from overseas suppliers, not including postage or packing. They are also sold in the S ilicon Chip Online Shop for AU$15 + P&P (around £8), with catalog codes of SC5026 (blue display) and SC6511 (white display). These are not the smallest OLED modules available. Another common size is 0.96in or 24.4mm diagonal, with prices slightly lower than those for the 1.3in/33mm modules. These generally have the same display resolution; the smaller size means those Fig.1: the block diagram of the SH1106 and SSD1306 controllers that are typically used in both the 0.96in and 1.3in OLED modules. 26 Practical Electronics | September | 2024 1.3-inch, 128×64-pixel OLED Display pixels are smaller. We used these in a few recent projects, like the Advanced Test Tweezers (February & March 2024). There are also even smaller OLED modules, like those with a designated size of 0.49in/12.45mm. Those have a lower display resolution of 64×32 pixels. We used those in the original SMD Test Tweezers from the October 2022 issue. Inside the OLED modules The 1.3in OLED modules all use a single interface/controller and OLED driver IC, usually the SH1106 from Sino Wealth or the SSD1306 from Solomon Systech. The same controllers are used in the 0.96in modules. Fig.1 is a block diagram of the SH1106 and SSD1306 controllers. At upper left is the microcontroller (MCU) interface, which can be configured to interface with an MCU via an 8-bit 6800/8080-series parallel interface, a 3/4 wire SPI interface or an I2C serial interface. Most 1.3in and 0.96in OLED modules use the last option, I2C. Received display data is stored in the graphic display data RAM (the large block to the right of the interface), while commands are sent to the command decoder block at lower left. The display controller block at upper right uses the display data to drive the columns and segments of the OLED via the common and segment drivers shown at far right. The OLED has 64 common/column lines and 128 segment lines, matching the 128×64 pixel resolution. There are commands to update the display, turn the OLED display on or off, set the OLED addressing mode, set the column starting address, and adjust the OLED’s display contrast/ brightness (which also determines its operating current). The SH1106 and SSD1306 devices both come in very thin (0.3mm) SMD packages with over 260 contact pads. In the modules, they are mounted on the rear of the OLED screen itself. The module circuit Fig.2 is the circuit of a typical 1.3in monochrome OLED module based on the SH1106 device (those using the SSD1306 are very similar). The OLED is at upper right, with the SH1106 interface/display RAM/controller/ driver IC1 in the centre. The rest of the circuit (to the left of IC1) provides the module’s power supply and I2C input interface. Four-pin SIL header CON1 is used for both power input and the I2C interface. REG1 takes the incoming Vcc (typically around 5V) and steps it down to +3.3V to run both IC1 and the OLED. The +3.3V line also drives IC1’s reset circuit (it needs to be reset as soon as power is applied) and feeds the 4.7kW pullup resistors for the I2C interface lines, SCL and SDA. The SH1106 and the SSD1306 controllers can adopt an 8-bit I2C address of either 0x78 or 0x7A, depending on the voltage applied to the DC input at pin 15. If the pin is pulled to ground (in this case, via a 4.7kW resistor), the controller adopts the 0x78 address, while if the pin is pulled up to +3.3V, it responds to the 0x7A address. That lets you run two similar OLED modules on the same I2C interface. Most of the modules are set for the 0x78 address when you get them, but it is relatively easy to swap the 4.7kW Fig.2: the circuit diagram of the 1.3in OLED module with a SH1106 controller. The circuitry separate to the OLED matrix and controller is for providing power and the I2C interface. Practical Electronics | September | 2024 27 How to use Electronic Modules The rear of the 1.3in OLED module shown at twice actual size. resistor over to the ‘pullup’ position to change the address to 0x7A if needed. Some 1.3in OLED modules have a 7-pin interface header instead of the 4-pin header shown in Fig.2. These modules allow the use of the faster SPI interface instead of the I2C interface we’re focusing on here. Now let’s focus on what is involved in driving one of these modules from an MCU like an Arduino Uno or Micromite. Connecting it to an Arduino Connecting a 1.3in OLED module to an Arduino Uno is relatively straightforward, as you can see from Fig.3. The GND and Vcc pins connect to the GND and 3.3V pins on the Arduino, while the SCL and SDA pins con- nect to the Arduino’s A5 (SCL) and A4 (SDA) pins, respectively. If using an Arduino Mega 2560, the arrangement is similar, but the module’s SCL pin goes to pin 21 of the 2560 and the SDA pin to the 2560’s pin 20. As for software support, if you go to the Arduino website and look at the library listings for “Display” applications (pemag.au/link/abl7), you will find quite a few libraries to do this job: Adafruit SSD1306, GyverOLED, OLED SSD1306-SH1106, OLED Display VGY12864L-03, ss_oled, ssd1306, ssd1306xled and U8g2. Another site (www.lcdwiki.com) offers a library called “1.3inch_IIC_ OLED_Module_SKU:MC130VX”, together with some documentation and three example sketches. All of these depend on the library U8g2, which you can download as a zip file from https://github.com/olikraus/ The three example sketches demonstrate how to draw graphics, text strings and a BMP image on the OLED, so they’re pretty informative. Screens 1 to 5 show some of the displays I was able to produce using these sketches and a blue 1.3in OLED module. Connecting it to a Micromite Connecting one of the 1.3in OLED modules to a Micromite MCU is also quite easy. Fig.4 shows the connections needed for driving the OLED module from a Micromite Plus Explore 64 (August 2017). Connecting the module to a Micromite Mk2 or LCD Backpack V1/V2/ V3 would be almost the same, except the module’s SCL pin would be connected to pin 17 of the Micromite and the SDA pin to pin 18. As with an Arduino, you need to install some software to let the Micromite drive the OLED module. That isn’t quite as easy as with the Arduinos, as there is no widely available Micromite OLED driver software yet. Still, because I knew that some Silicon Chip readers would want to drive an OLED module from a Micromite, I decided to try writing an MMBasic program to go through the necessary steps. Luckily, fellow S ilicon C hip staff member Tim Blythman was able to offer some help, as he has done quite a bit of work with the smaller 0.96in OLED modules (which use the same SH1106 and SSD1306 chips) and is very familiar with the steps needed to drive them. Thanks to Tim’s help, despite losing some of my rapidly thinning grey hair, I was able to develop an MMBasic program that can drive one of these OLED modules from a Micromite. It demonstrates how text and simple graphics can be displayed on its screen. The program is called “OLED MODULE TEST Prog2.bas”, and the display it ◀ Fig.3 (left): you can use this diagram to help connect a 1.3in OLED module to an Arduino Uno or similar. Fig.4 (below): how to drive the OLED module via a Micromite Plus Explore 64. You can similarly connect it to a Micromite BackPack by connecting SCL to pin 17 and SDA to pin 18. 28 Practical Electronics | September | 2024 1.3-inch, 128×64-pixel OLED Display Screens 1-6 (left-to-right, top-to-bottom): example output produced by the various test programs we downloaded or created for use with the 1.3in (33mm) OLED module. Screen 6 at lower right is from our Micromite program. achieves is shown in Screen 6. It’s a pretty basic little program (no pun intended), and as it stands, it only demonstrates how the OLED module can display text and simple graphical symbols. It doesn’t let you type text in via the Micromite console and display it directly on the OLED; that would involve additional programming. That’s because the easiest way to drive these OLEDs is by setting the driver chip to Page Addressing Mode, which effectively divides the OLED screen into eight horizontal ‘pages’, each page consisting of 128 vertical segments eight pixels high. The pages are arranged vertically, with page 0 along the top of the screen, page 1 immediately below it and then the remaining pages descending until page 7 runs along the bottom of the screen, as shown on the left side of Fig.5. When the driver chip updates each page on the OLED (which it does one page at a time), it starts at the far left and displays the eight-pixel segments one after the other, moving from left to right. Each eight-pixel segment is sent in b0 to b7 order (‘LSB-first’), as shown on the righthand side of Fig.5. This Page Addressing Mode makes it not too difficult to display lines of text; all you need to do is work out the sequence of segment bytes required to show the character or symbol you want to display, then send that sequence to the OLED controller as a sequence of single bytes. For text, it’s easiest to have a line spacing of 8 pixels, meaning the characters are around 7 pixels tall and perhaps 4-5 pixels wide. To help you do this, I have worked out the byte sequences for the upper case and lower case text characters, plus the basic numerals (0 to 9) and a reasonable number of common symbols. These are listed in a second dummy MMBasic program called “OLED MODULE textchar strings. bas”, which you can download from the Silicon Chip website along with “OLED MODULE TEST Prog2.bas”. That should allow you to write a program that can display up to eight lines of text on the screen of one of these 1.3in OLED modules. Drawing detailed graphics on the OLED screen is a bit more involved but, as the demonstration program shows how to write pixels into the OLED’s display RAM, that should provide a starting point for more advanced graphics. A reader with more programming experience might accept the challenge of creating a full display driver for these OLEDs, possibly based on the PE starting point I have provided. Fig.5: Page Addressing Mode divides the OLED into eight sections as shown. This is the easiest way to drive the OLED. Practical Electronics | September | 2024 29