We do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry Pi.
SSD1306 - 128 x 64 display.
SSD1306 - 96 x 16 display.
Main parameters for the displays:
Pieces we use in this guide:
I2C Tools
To install the I2CTools you use the following command:
sudo apt-get install i2c-tools
You need to enable the i2c bus in the Raspberry PI settings, which you can do in the Raspberry Pi user interface.
Wiring up the display:
SSD1306 | Raspberry PI cobbler |
---|---|
VDD | 3.3 V |
GND | GND |
SCK | SCL (Physical pin 5) |
SDA | SDA (Physical pin 3) |
If you need more information about the GPIO headers on Raspberry Pi or other boards then click bellow.
Raspberry Pi Pin guideOrange Pi One Pin guideOrange Pi Pin guide for most H3 modelsOrange Pi Zero 3 Pin guideOrange Pi 5 Plus Pin guideRock 64 Pin guideSanity tests in console:
After you have connected everything and made sure that wiringPI, i2ctools are installed that I2C is enabled in the Raspberry PI settings, then we are ready to do sanity tests in console, or you can run the I2C example project that comes with the I2C Plugin.
If doing it in console then you would issue command like this:
sudo i2cdetect -y 1
This should show our device at 0x3C most likely. Or if you use the example project that comes with the I2C plugin then you click Get adapters and then select the adapter and then click Scan the selected adapter this should get you 60, which converted to Hex is 0x3C, same as the i2cdetect returns.
The example project that comes with the I2C Plugin, which can help you scan for the device address.If you can see your display on address 0x3C (or 60 dec) then you are ready to start coding.
Internal RAM buffer of the display:
SSD1306 has 8 pages and 128 columns. Each page has 8 lines making the total RAM of the SSD1306 be always 128 x 64 even if you have smaller display. While larger display would not be possible for this type of display.
The Xojo code:
For the Xojo code we needed to make driver for this display as well as Font system to be able to write some letters because this is a dot based display and not character based display.
We supply several fonts with this, which you can add tokens to as needed. Not all the fonts are stored in same way, some are constructed stored vertically in bytes while others horizontally.
5 x 8 - Stored vertically in bytes in memory.
6 x 8 - Stored horizontally in bytes in memory.
7 x 10 - Stored horizontally in bytes in memory.
11 x 18 - Stored horizontally in bytes in memory.
16 x 26 - Stored horizontally in bytes in memory.
We created a class called SSD1306_1BIT which is the main hub to use the display
The class can also draw Mono tone bitmaps to the LCD. We do that by using RawBitmap class from the Einhugur TypeLib plugin which is free plugin. Because of this then the class has dependency for TypeLib.
The test Xojo project had window like this
Here the Draw Xojo Logo button has been pressed and its drawn in local debug context on the window as well as on the screen as seen on the picture to the right.
Here the Write text with larger font button has been pressed and its drawn in local debug context on the window as well as on the screen as seen on the picture to the right.
I was also able to get the 96 x 16 display to work:
This screen was to small to display the whole message that was fed to it.
You can find this example code at Example code for GPIO guides.
I got this also to work on H3 based Orange Pi running Armbian.
To get things to work on H3 based Orange Pi I had to: