S-0018: Difference between revisions

From 52Pi Wiki
Jump to navigation Jump to search
Line 193: Line 193:
<br style="clear:both;">
<br style="clear:both;">
===How to use OLED with Arduino===
===How to use OLED with Arduino===
* On Arduino IDE, Go to Tools >> Manage Libraries
* On Arduino IDE, Go to Tools >> Manage Libraries and search SSD1306 or just download the latest zip file from [ https://www.arduino.cc/reference/en/libraries/ssd1306/ ], or just download from: [ File:Ssd1306-1.8.3.zip ]
[[File:Arduinoide01.png|left|800px]]
<br style="clear:both;">
[[File:Arduinoide02.png|left|800px]]
<br style="clear:both;">
* If you download zip file from libraries URL, please install it before you use it.
Install it as following steps:<br>
[[File:Arduino03.png|left|800px]]
<br style="clear:both;">
[[File:Arduino04.png|left|800px]]
<br style="clear:both;">
when you coding, you can find it from sketch>> include libraries>> ssd1306
[[File:Arduino05.png|left|800px]]
<br style="clear:both;">
* Demo code: [ File:Clock.zip ]
Download this demo code and unzip it to desktop, and connect your Arduino to your laptop or PC, select the serial port to upload code.
For example:
[[File:Arduino06.png|left|800px]]
<br style="clear:both;">
Press CTRL+ R to verify or compile code, and press CTRL+U to upload code to your Arduino board.


===STM32===
===STM32===

Revision as of 17:30, 14 July 2022

Double Color 0.96 Inch OLED Display

Descriptions

SSD1315 is a single-chip CMOS OLED/PLED driver with controller for organic/polymer light emitting diode dot-matrix graphic display system. It consists of 128 segments and 64 commons. This IC is designed for Common Cathode type OLED/PLED panel.

SSD1315 displays data directly from its internal 128 x 64 bits Graphic Display Data RAM (GDDRAM). Data/Commands are sent from general MCU through the hardware selectable I2C Interface, 6800-/8080- series compatible Parallel Interface or Serial Peripheral Interface.

The 256 steps contrast control and oscillator which embedded in SSD1315 reduces the number of external components. SSD1315 is suitable for portable applications requiring a compact size and high output brightness, such as set-top box, car audio, wearable electronics, etc.

Features

  • Resolution: 128 x 64 dot matrix panel
  • Power supply 3.3V
  • Segment maximum source current: 240uA
  • Common maximum sink current: 30mA
  • Embedded 128 x 64 bit SRAM display buffer
  • Pin selectable MCU Interfaces:
  • 8 bits 6800/8080-series parallel Interface
  • 3/4 wire Serial Peripheral Interface
  • I2C Interface
  • Screen saving continuous scrolling function in both horizontal and vertical direction
  • Screen saving infinite content scrolling function
  • Internal or external IREF selection
  • Internal charge pump regulator
  • RAM write synchronization signal
  • Programmable Frame Rate and Multiplexing Ratio
  • Row Re-mapping and Column Re-mapping
  • Power On Reset (POR)
  • Dynamic Grayscale
  • On-Chip Oscillator
  • Chip layout for COG, COF
  • Wide range of operating temperature: -40°C to 85°C

Basic Specifications

Display Specifications

  • 1) Display Mode: Passive Matrix
  • 2) Display Color: Yellow and Blue
  • 3) Drive Duty: 1/64 Duty

Mechanical Specifications

  • 1) Outline Drawing: According to the annexed outline drawing
  • 2) Number of Pixels: 128x64
  • 3) Panel Size: 27.50x27.80x3.0 (mm)
  • 4) Active Area: 21.744x10.864 (mm)
  • 5) Pixel Pitch: 0.17x0.17 (mm)
  • 6) Pixel Size: 0.154x0.154 (mm)
  • 7) Weight: 6(g)
I2c20220714121611.png


Development Documentation

How to program it

Raspberry Pi

  • Connect OLED display to Raspberry Pi GPIO as following Chart:
OLED Raspberry Pi GPIO
GND GND
VCC 3.3V
SCL GPIO 3 (I2C1 SCL)
SDA GPIO 2 (I2C1 SDA)
  • Full GPIO position
800


NOTE: We assume you are using the official operating system provided by the Raspberry Pi.
  • Enable I2C function, open a terminal and typing:
 sudo raspi-config 
  • Navigate to interface options and i2c item, enable it.
I2c-enable1.png


I2c-enable2.png


I2c-enable3.png


I2c-enable4.png


  • Check if the OLED screen has been recognized.
 i2cdetect -y 1 
I2cdetect01.png


  • Install dependencies libraries:
sudo apt -y install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5
  • Grant privilleges to user `pi`
sudo usermod -a -G gpio,i2c pi
  • Download sample code from this repo:
git clone https://github.com/rm-hull/luma.examples.git
cd luma.examples/
  • Install the dependencies
sudo -H pip3 install -e .
  • Entering into example folder and test it.
cd examples/
vim mydemo.py 
  • Paste following code.
#!/usr/bin/python3

import os
import sys
import time
from demo_opts import get_device
from luma.core.render import canvas
from PIL import ImageFont
import psutil
import subprocess as sp


def greetings():
    return "GeeekPi HI-Tech"

def get_temp():
    temp = sp.getoutput("vcgencmd measure_temp")
    return "CPU Temp:%s" % temp

def get_cpu_percent():
    cpu_percent = psutil.cpu_percent(interval=2)
    return "CPU Percent: %.1f" % (cpu_percent)

def get_cpu_count():
    cpu_count = psutil.cpu_count()
    return "CPU Count: %s" % (cpu_count)

def get_ip():
    ip = sp.getoutput("hostname -I")
    return "IP: %s" % ip

def stats(device):
    # use system font
    font_path = '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf'
    font_size = ImageFont.truetype(font_path, 13)

    with canvas(device) as draw:
        draw.text((0, 0), greetings(), font=font_size, fill="white")
        if device.height >= 32:
            draw.text((0, 15), get_cpu_percent(), font=font_size, fill="white")

        if device.height >= 64:
            draw.text((0, 30), get_temp(), font=font_size, fill="white")
            try:
                draw.text((0, 45), get_ip(), font=font_size, fill="white")

            except KeyboardInterrupt:
                pass

device = get_device()

while True:
    stats(device)
    time.sleep(2)

  • Save it and Execute it:
sudo python3 mydemo.py & 
  • You should seen this screen on OLED
Oleddemo01.jpg


Raspberry Pi Pico

Arduino

1 x Arduino UNO or Arduino Mega 2560 or Arduino Other type. 1 x USB 2.0 Cable type A/B 1 x 0.96 inch OLED display 4 x Jumper wires (male to male) 1 x Breadboard

I2C 0.96 inch OLED display Pinout

  • GND Pin: should be connected to the ground of Arduino.
  • VCC Pin: is the power supply for the display which we connect the 5 volts or 3.3 volts pin on the Arduino.(Recommend connect to 3.3V)
  • SCL Pin: serial clock pin for I2C interface.
  • SDA Pin: serial data pin for I2C interface.
Connnecttion arduino.png


How to use OLED with Arduino

Arduinoide01.png


Arduinoide02.png


  • If you download zip file from libraries URL, please install it before you use it.

Install it as following steps:

Arduino03.png


Arduino04.png


when you coding, you can find it from sketch>> include libraries>> ssd1306

Arduino05.png


  • Demo code: [ File:Clock.zip ]

Download this demo code and unzip it to desktop, and connect your Arduino to your laptop or PC, select the serial port to upload code. For example:

Arduino06.png


Press CTRL+ R to verify or compile code, and press CTRL+U to upload code to your Arduino board.

STM32

51 Series

Package Includes

  • 1 x 0.96 inch OLED display kit

Keywords

  • 0.96 inch OLED display, double color 0.96 inch OLED display