This is only a preview of the November 2024 issue of Silicon Chip. You can view 46 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Variable Speed Drive Mk2, Part 1":
Items relevant to "Surf Sound Simulator":
Items relevant to "JMP014 - Analog pace clock & stopwatch":
Items relevant to "JMP013 - Digital spirit level":
Items relevant to "FlexiDice":
Items relevant to "0.91-inch OLED Screen":
Articles in this series:
Items relevant to "3D Printer Filament Dryer, Part 2":
Purchase a printed copy of this issue for $13.00. |
Using Electronic Modules with Jim Rowe
0.91-inch monochrome
OLED screen
Small monochrome OLED display modules have
become widely available at a low cost in the last
few years. This one is just 37.5 × 11.5 × 4.5mm
but has a 128 × 32 pixel display that’s either white or blue.
With its I2C serial interface it can be easily driven by a microcontroller.
I
n the October 2023 issue, we
reviewed the ‘big brother’ of this
OLED module, with a display measuring 1.3 inches or 33mm diagonally. It had 128 × 64 pixels – twice
that of this module – along with an I2C
serial interface. We have used the 1.3inch module in several projects, like
the Multi-Stage Buck/Boost Charger
Adaptor (October 2022; siliconchip.
au/Article/15510).
We have also used smaller OLED
displays in various projects. For example, a 0.96in module with 128 × 64 pixels was used in these projects:
» LC Meter Mk3, November 2022:
siliconchip.au/Article/15543
» Q Meter, January 2023:
siliconchip.au/Article/15613
» Advanced Test Tweezers,
February & March 2023:
siliconchip.au/Series/396
And there’s an even smaller 0.49in
OLED display with 64 × 32 pixels that
we used in the:
» SMD Test Tweezers, October
2021/April 2022: siliconchip.
au/Article/15276
» Pocket Audio Oscillator,
September 2020: siliconchip.au/
Article/14563
The main difference between the
current module and all of those others
is that the ‘active area’ of its display
is wider but shorter: 22.4mm wide by
5.6mm high. Since it has 128 × 32 pixels, that means that it provides a display basically equivalent to the top or
bottom half of the 1.3in OLED module.
We obtained the module shown in
the photos from a supplier on AliExpress for ~$2. Another supplier
78
Silicon Chip
on AliExpress had it for ~$3, while
it was on eBay for ~$12. Closer to
home, Tempero Systems offer it for
~$7, while Core Electronics had a
very similar module available for ~$17
(siliconchip.au/link/abw3). All the
prices listed above are exclusive of
postage costs.
Inside these OLED modules
The 0.91in (23mm) OLED modules
all use a single interface/controller
and OLED driver IC, usually either
the SH1106 device from Sino Wealth
or the SSD1306 device from Solomon
Systech. The same controllers are also
used in many of the larger modules.
Fig.1 is a block diagram of the
SH1106 and the SSD1306 interface/
controllers. At upper left is the microcontroller (MCU) interface, which can
be configured to interface with an MCU
via an 8-bit 6800/8080 parallel interface, a 3- or 4-wire SPI interface or an
I2C serial interface. Most of the OLED
modules currently available use the
I2C interface, including the one we’re
looking at here.
Display data from the MCU is
stored in the Data RAM just to the
right of the interface block. The
SH1106 and SSD1306 controllers
both have around 1024 bytes of Data
RAM, enough for a 128 × 64 pixel display. Since the 0.91in OLED only has
32 rows, only half of the Data RAM
is used in this module.
The Display Controller block to the
right of the Data RAM takes data from
the RAM and displays it on the OLEDs
via the page and segment drivers at the
right-hand end of Fig.1.
The MCU can also send commands
to the controller, which pass from
the MCU interface to the Command
Decoder block below it in Fig.1. The
commands can be used to update
the display, turn it on or off, set its
addressing mode, set the column starting address and adjust the display
Fig.1: the block diagram of the SH1106 and SSD1306 OLED driver controller
ICs. The SSD1306 has a slightly bigger internal RAM, letting it store 132 x 64
pixels (four more pixels horizontally than the SH1106).
Australia's electronics magazine
siliconchip.com.au
Fig.2: a common circuit diagram for
the 0.91in OLED modules using an
SSD1306 controller.
contrast and brightness (the latter also
determining 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
directly on the rear of the OLED screen.
The module’s circuit
Fig.2 shows the circuit of a typical 0.91in monochrome OLED module based on the SSD1306 device. As
you can see, it’s very similar to that of
the 1.3in OLED module we looked at
in the October 2023 issue, although a
little simpler.
The circuitry to the left of the OLED
provides the power supply and assists
with the I2C interface. These components are all mounted on the rear
of the module’s PCB. Four-pin SIL
header CON1 at far left handles both
the power input and the I2C interface.
REG1 takes the incoming Vcc and
steps it down to +3.3V to run the OLED
and its controller. The +3.3V line is
also used to drive the controller’s reset
circuit (it needs to be reset as soon as
power is applied) and provides the
reference for the 4.7kW pull-up resistors used on the I2C interface lines,
SCL and SDA.
Before we move on to more practical things like driving one of the
modules from an MCU, Fig.3 shows
how the SH1106 and SSD1306 controllers save the display data in their
Data RAM, and how it is shown on the
OLED screen. This is achieved by setting them to what is described as Page
Addressing Mode.
In this mode, the OLED screen is
divided into eight horizontal ‘pages’,
where each page consists of 128 vertical segments eight pixels high. The
siliconchip.com.au
Fig.3: the SH1106 and SSD1306 controllers save their display data into
RAM using column-major order.
The OLED module’s PCB measures just 37.5mm
wide, 11.5mm tall and the module is only
4.5mm deep, making it ideal for compact
designs. You can see it at actual size in the
adjacent image.
Australia's electronics magazine
November 2024 79
Fig.4: how to connect
the 0.9in OLED module
to an Arduino Uno or
similar.
Fig.5: connecting the OLED module to a Micromite
Plus Explore 64 are just as simple as an Arduino.
If instead you’re operating the module with a
Micromite Mk2 or BackPack, then the SCL pin of
the module connects to pin 17 of the Micromite,
and the SDA pin connects to pin 18.
An example photo of the OLED module connected to a Micromite via a
breadboard.
The underside of the OLED module shown enlarged for clarity. All components
except for the screen are mounted to this side.
80
Silicon Chip
Australia's electronics magazine
pages are themselves arranged vertically, with page 0 along the top of the
screen, page 1 immediately below it
and the remaining pages descending.
With the 0.91in OLED module,
though, the pages and segments are
used rather differently. In this case,
only every second segment byte of
each page is used (segments 0, 2, 4 and
so on), and only four bits are used in
each segment byte (bit 0, bit 2, bit 4
and bit 6). These four data bits are then
used to display the four upper pixels
in that segment of the OLED.
The data for the lower four pixels
of that OLED segment come from the
next page in the controller’s RAM,
which is organised in the same way:
only every second segment is used,
and only the four bits are used in each
segment byte.
I think you’ll agree that this all
seems a bit weird, but that’s the way
data is organised in the 0.91in OLED
modules.
Now we can turn our attention to
what is involved in driving one of
these modules from an MCU like an
Arduino Uno or a Micromite.
Connecting it to an Arduino
Connecting the OLED module to an
Arduino Uno (or compatible) is quite
straightforward, as you can see from
Fig.4. The GND and Vcc pins connect
to the GND and 3.3V pins om the Arduino, while the SCL and SDA pins connect to the Arduino’s A5 (SCL) and A4
(SDA) pins, respectively.
You can also connect the OLED
module to an Arduino Uno R4 Minima, simply by connecting the module’s SCL pin to pin 17 of the Minima and the SDA pin to the Minima’s
pin 16.
As for software to drive the OLED
module, if you go to www.arduino.
cc and look at the library listings for
‘Display’ applications (siliconchip.au/
link/abw5), you will find quite a few
libraries intended to do this job.
The first one I found was Adafruit’s
SSD1306 library, with the latest version (V2.5.9) able to handle OLED displays with either 128 × 64 or 128 ×
32 pixels. It also relies on using their
GFX library.
The Adafruit library comes with
five example sketches, including
one called SSD1306_128x32_i2c.ino
– which is the one most suitable for
use with the 128 × 32 pixel OLED
module.
siliconchip.com.au
When you run this sketch, it gives you a series of graphics and text displays, including those shown in the article lead and at left. As you can see, the 128 × 32 OLED’s
display is quite small, but can display a useful amount of
information.
Connecting it to a Micromite
It’s also quite easy to connect the OLED module to a
Micromite MCU. Fig.5 shows the connections needed for a
Micromite Plus Explore 64 and, as you can see, they are just
as straightforward as driving the module from an Arduino.
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 also need some software. It turns
out that this isn’t quite as easy as with the Arduinos, as it’s
much harder to find any Micromite OLED driver software.
As I related in the October 2023 article, I could write an
MMBasic program to display text and simple graphics on
the 1.3in OLED module, with some much appreciated help
from fellow Silicon Chip staff member Tim Blythman. Since
the 0.91in OLED modules use the same SSD1306 controller,
I decided to try adapting that program to work with them.
But that approach didn’t work with the 0.91in module,
even when I tried quite a few modifications to the program
– the OLED’s display remained stubbornly dark. So once
again, I asked Tim for help (sorry, Tim). And as before, he
provided a lot of help.
Tim searched around The Back Shed (www.thebackshed.
com/forum) and found some valuable information I had
missed concerning MMBasic programming of the various
OLED modules.
He found a driver written by MMBasic programming
guru Peter Mather and soon came up with his own working
program by combining elements of Peter Mather’s driver
with a few ideas taken from my program for testing the
1.3in OLED module.
Tim sent me his new program by email, and when I tried
it out, I found it worked very well. So I added a few comments, plus code to display a full four lines of text instead
of the single line that Tim had provided. You can see the
display produced by this program at lower right.
The program is called “091in OLED TB version.bas”
and you can download it from siliconchip.au/Shop/6/454
As before, it’s a fairly simple program, and as it stands it
only demonstrates how to drive the OLED module to display text and very simple graphic symbols. It doesn’t let
you type text in via the Micromite console and display it
directly on the OLED, as that would involve a fair bit of
additional code.
Hopefully it will make it easy for those who want to display up to four lines of text and basic symbols on the screen
of one of the 0.91in OLED modules from a Micromite to do
so. I’d like to thank Tim Blythman for help in producing
this MMBasic program for the Micromite.
Useful links
• Interfacing the 0.91in OLED with an Arduino Uno:
siliconchip.au/link/abw6
• OLED breakouts: siliconchip.au/link/abw7
• LCDwiki MC091GX user manual: siliconchip.au/link/
abw8
SC
siliconchip.com.au
Australia's electronics magazine
November 2024 81
|