Difference between revisions of "1.3inch OLED HAT"

From Waveshare Wiki
Jump to: navigation, search
m (Text replacement - "{{#urlget:amazon|default}}=display" to "{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display")
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Infobox item|colorscheme=green
+
<div class="wiki-pages jet-green-color">
|img=[[File:1.3inch-OLED-HAT-1.jpg|300px|{{Amazon_nolink|default={{#urlget:amazon|default}}|url=link=https://www.waveshare.com/1.3inch-oled-hat.htm}} ]]
+
{{Infobox item|
 +
|img=[[File:1.3inch-OLED-HAT-1.jpg|300px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/1.3inch-oled-hat.htm}} ]]
 
|caption=13inch OLED HAT, SPI/I2C interfaces
 
|caption=13inch OLED HAT, SPI/I2C interfaces
 
|category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]],
 
|category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]],
Line 12: Line 13:
 
{{Product List|OLEDs / LCDs/OLED}}
 
{{Product List|OLEDs / LCDs/OLED}}
 
}}
 
}}
 +
=Overview=
 
== Introduction ==
 
== Introduction ==
 
1.3inch LCD HAT, SPI/I2C interfaces
 
1.3inch LCD HAT, SPI/I2C interfaces
 
+
{{1.3inch OLED HAT}}
{{Amazon|{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display
+
{{1.3inch OLED HAT rpi}}
|More = [https://www.waveshare.com/1.3inch-oled-hat.htm More]}}
+
{{1.3inch OLED HAT Jetson}}
==Resources==
+
=Resources=
 +
==Document==
 
*[https://www.waveshare.com/w/upload/4/46/1.3inch_OLED_HAT_User_Manual_EN.pdf User Manual]
 
*[https://www.waveshare.com/w/upload/4/46/1.3inch_OLED_HAT_User_Manual_EN.pdf User Manual]
 
*[[:File:1.3inch-OLED-HAT-Code.7z|Demo code]]
 
*[[:File:1.3inch-OLED-HAT-Code.7z|Demo code]]
 
*[[:File:1.3inch-OLED-HAL-Schematic.pdf|Schematic]]
 
*[[:File:1.3inch-OLED-HAL-Schematic.pdf|Schematic]]
  
== Datasheet ==
+
==Datasheet==
  
 
*[[:File:1.3inch-SH1106-OLED.pdf|1.3inch SH1106 OLED]]
 
*[[:File:1.3inch-SH1106-OLED.pdf|1.3inch SH1106 OLED]]
 
*[[:File:SH1106_V2.3.pdf | SH1106]]
 
*[[:File:SH1106_V2.3.pdf | SH1106]]
 +
 
==Relate Resources==
 
==Relate Resources==
 
*[https://github.com/PiSugar/pisugar-case-pihat-cap Pisugar case]
 
*[https://github.com/PiSugar/pisugar-case-pihat-cap Pisugar case]
 
*[https://github.com/dettus/oledtest Third-Party Demo codes]
 
*[https://github.com/dettus/oledtest Third-Party Demo codes]
==FAQ==
+
==Software==
 +
*[https://{{SERVERNAME}}/w/upload/7/78/LcmZimo.zip lcd ]
 +
*[https://{{SERVERNAME}}/w/upload/b/bd/Image2Lcd2.9.zip Image2Lcd]
 +
 
 +
=FAQ=
 +
{{0.95inch-RGB-OLED-FAQ}}
  
==Support==
 
 
{{Service00}}
 
{{Service00}}
 +
</div>

Latest revision as of 09:06, 20 July 2022

1.3inch OLED HAT
1.3inch-OLED-HAT-1.jpg

13inch OLED HAT, SPI/I2C interfaces
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Overview

Introduction

1.3inch LCD HAT, SPI/I2C interfaces

Specification

  • Driver: SH1106
  • Interface: 4-wire SPI, 3-wire SPI, I2C
  • Resolution: 128 x 64
  • Display Size: 1.3inch
  • Outline Dimension: 65mm x 30mm
  • Display color: blue
  • Visible Angle: >160°
  • Operating TEMP. (℃): -20~70
  • Storage TEMP. (℃): -30~80

Pin Function

PIN Function BCM Description
KEY1 P21 Button 1/GPIO
KEY2 P20 Button 2/GPIO
KEY3 P16 Button 3/GPIO
Joystick Up P6 Go Up
Joystick Down P19 Go Down
Joystick Left P5 Go Left
Joystick Right P26 Go Right
Joystick Press P13 Press Down
SCLK P11/SCLK SPI Clock input
MOSI P10/MOSI SPI Data input
SCL P3/SCL1 I2C Clock Input
SDA P2/SDA1 I2C Data Input
DC P24 Data/Command
CS P8/CE0 Chip Selection
RST P25 Reset

Hardware Configuration

The OLED module provides three drive interfaces: 3-wire SPI, 4-wire SPI and I2C interface. There are six resistors that can be soldered on the back of the module. The corresponding communication method is selected by the electronic selection, as shown in the figure:
1.3inch OLED HAT.png
The module uses a 4-wire SPI communication mode by default, that is, BS0, BS1, DC, CS, CLK, and DIN are connected to 0 by default (1 and 0 do not represent the level, but the welding method of connecting or connecting the resistance, the specific hardware link is as follows surface):
Note: The above picture is the welding on the hardware, the following table is the actual hardware connection

Communication Method BS1/BS0 CS DC DIN CLK
3-wire SPI 0/1 CS 1 MOSI SCLK
4-wire SPI 0/0 CS DC MOSI SCLK
I2C 1/0 0 1 SDA SCL

The specific hardware configuration is as follows:

  • Using 4-wire SPI:

That is, the factory program settings: BS0 and BS1 connect 0 to ground, CS connect 0 to CE0 (enable pin), D/C connect 0 to P24 (data/command pin) of Raspberry Pi, DIN to 0 is connected to Raspberry Pi MOSI, and CLK to 0 is connected to Raspberry Pi SCLK;

  • Using 3-wire SPI:

Connect BS0 to 1 to VCC, BS1 to 0 to connect to GND, CS to 0 to connect to Raspberry Pi CE0, D/C to 1 to connect to GND, DIN to 0 to connect to Raspberry Pi MOSI, CLK to 0 to connect to the tree Raspberry Pi SCLK;

  • Using I2C:

Connect BS0 to 0 to GND, BS1 to 1 to VCC (3.3V), CS to 1 to connect to GND, D/C to 1 to connect to GND, DIN to 1 to connect to Raspberry Pi SDA, CLK to 1 to connect to the tree Raspberry Pi SCL; when using I2C: the high and low states of DC can control the address of the slave device, here is connected to GND, then the 7-bit address of I2C is: 0x3C

Raspberry Pi

Enable SPI interface

  • Open terminal, use command to enter the configuration page
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes  to enable SPI interface

RPI open spi.png
Reboot Raspberry Pi:

sudo reboot

Please make sure that SPI interface was not used by other devices, and you can check it in /boot/config.txt.

Enable I2C Interface

  • Open the Raspberry Pi terminal and enter the following command to enter the configuration interface
sudo raspi-config
Select Interfacing Options -> I2C ->yes to start the i2C kernel driver

1.3inch OLED HAT rpi.png
and the reboot RPi

sudo reboot

Install Libraries

BCM2835

#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar zxvf bcm2835-1.71.tar.gz
cd bcm2835-1.71/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/

WiringPi

#Open the Raspberry Pi terminal and run the following command
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (earlier than before, you may not need to execute), you may need to upgrade:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear. If it does not appear, the installation is wrong

#Bullseye branch system use the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
# Run gpio -v and version 2.60 will appear. If it does not appear, it means that there is an installation error
  • python
#python2
sudo apt-get update
sudo apt-get install python-pip 
sudo pip install RPi.GPIO
sudo apt-get install python-smbus
sudo pip install spidev

#python3
sudo apt-get update
sudo apt-get install python3-pip 
sudo pip3 install RPi.GPIO
sudo apt-get install python3-smbus
sudo pip3 install spidev

Download Example

Run in the terminal of RPi:

sudo apt-get install p7zip-full
wget https://www.waveshare.com/w/upload/5/53/1.3inch-OLED-HAT-Code.7z
7z x 1.3inch-OLED-HAT-Code.7z -r -o.
sudo chmod 777 -R  1.3inch-OLED-HAT-Code
cd 1.3inch-OLED-HAT-Code/RaspberryPi/

Test Program

  • C
cd C
make clean
make
sudo ./main
  • python
#python2
cd python2
sudo python main.py
sudo python key_demo.py
#python3
cd python3
sudo python3 main.py
sudo python3 key_demo.py
  • For Raspberry Pi 4B and the system after raspbian_lite-2019-06-20, you need to set as follows, and the key can be input normally
sudo nano /boot/config.txt
#add:
gpio=6,19,5,26,13,21,20,16=pu

I2C Control

  • The 4-wire SPI used by default, if the hardware is modified to I2C, the program needs to be modified

C

Open C\obj\DEV_Config.h,change

#define USE_SPI 1
#define USE_IIC 0

To

#define USE_SPI 0
#define USE_IIC 1

and then execute again:

make clean
make
sudo ./main

python

Open python2/config.py, change:

Device_SPI = 1
Device_I2C = 0

To

Device_SPI = 0
Device_I2C = 1

and then execute again:

sudo python main.py

The same is true for python3

Jetson Nano

Install Libraries

  • Open the trminal and enter the following commands
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install Jetson.GPIO
sudo groupadd -f -r gpio
sudo usermod -a -G gpio your_user_name
sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

【Note】your_user_name is the username you use, such as waveshare

  • Install I2C
sudo apt-get install python-smbus
  • Install the image processing library:
sudo apt-get install python3-pil
sudo apt-get install python3-numpy

Download Program

sudo apt-get install p7zip
wget https://www.waveshare.com/w/upload/5/53/1.3inch-OLED-HAT-Code.7z
7z x 1.3inch-OLED-HAT-Code.7z
sudo chmod 777 -R  1.3inch-OLED-HAT-Code
cd 1.3inch-OLED-HAT-Code/JetsonNano/

Program Test

Due to the weak GPIO drive capability of JetsonNano, it can only be controlled using SPI

  • C
cd C
make clean
make
sudo ./main
  • python
#python2
cd python2
sudo python main.py
sudo python key_demo.py
#python3
cd python3
sudo python3 main.py
sudo python3 key_demo.py

Resources

Document

Datasheet

Relate Resources

Software

FAQ

 Answer:
The OLED module is used in a 3.3V system by default, but after more than 24 hours of burn-in test, it is found that it can also work normally in a 5V system.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
Under normal working conditions, generally 50,000 hours
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
At the operating voltage of 3.3V:

Working current of 0.95inch RGB OLED: about 38mA for full white display, about 4mA for full black display.
The working current of 0.96inch OLED is about 25mA when fully on, and 1.5mA when fully off.

Working current of 1.3inch OLED: about 29mA when fully on, 1.0mA when fully off.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
OLED has no backlight, and the display is self-illuminating. Only connect VCC and GND, the OLED will not light up.
Program control is required to brighten the OLED.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
1. Be careful not to connect the power supply in reverse.
2. The same picture cannot be displayed for a long time, otherwise it will produce afterimages and cause damage to the OLED.
{{{3}}}
{{{4}}}

{{{5}}}



Support

If you require technical support, please go to the Support page and open a ticket.