xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

How to connect to multiple SSD1306 OLED Displays using Raspberry Pi GPIO I2C PIN All In One

How to connect to multiple SSD1306 OLED Displays using Raspberry Pi GPIO I2C PIN All In One

如何使用 Raspberry Pi 的 GPIO I2C PIN 连接多个 SSD1306 OLED 显示器

串联 ???

  1. Raspberry Pi 只有一对 I2C 输出针脚, 故不可以 ❌

一对 I2C 输出针脚即使加跳线,串联了多个 SSD1306 OLED 显示屏,也无法分别控制每个显示屏;

最多也只能是多个显示屏显示完全一样的内容, 没有意义呀!

GPIO 2(SDA)
GPIO 3(SCL)

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html

  1. Raspberry Pi Pico 具有多对 I2C 输出针脚, 应该可以的 ❓

有多对 I2C 输出针脚, 理论上可以分别输出不同信号,可以分别控制不同的显示屏;

GPIO 2(SDA)
GPIO 3(SCL)

https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html

datasheets

BCM2837

https://www.raspberrypi.com/documentation/computers/processors.html#bcm2837

$ pinout
,--------------------------------.
| oooooooooooooooooooo J8     +====
| 1ooooooooooooooooooo        | USB
|                             +====
|      Pi Model 3B  V1.2         |
|      +----+                 +====
| |D|  |SoC |                 | USB
| |S|  |    |                 +====
| |I|  +----+                    |
|                   |C|     +======
|                   |S|     |   Net
| pwr        |HDMI| |I||A|  +======
`-| |--------|    |----|V|-------'

Revision           : a22082
SoC                : BCM2837
RAM                : 1GB
Storage            : MicroSD
USB ports          : 4 (of which 0 USB3)
Ethernet ports     : 1 (100Mbps max. speed)
Wi-fi              : True
Bluetooth          : True
Camera ports (CSI) : 1
Display ports (DSI): 1

J8:
   3V3  (1) (2)  5V    
 GPIO2  (3) (4)  5V    
 GPIO3  (5) (6)  GND   
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND   
GPIO22 (15) (16) GPIO23
   3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND   
 GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8 
   GND (25) (26) GPIO7 
 GPIO0 (27) (28) GPIO1 
 GPIO5 (29) (30) GND   
 GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND   
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21

For further information, please refer to https://pinout.xyz/

https://pinout.xyz/

image

https://datasheets.raspberrypi.com/bcm2837/bcm2837-peripherals.pdf

https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf

https://datasheets.raspberrypi.com/

The underlying architecture of the BCM2837 is identical to the BCM2836.
BCM2837 的底层架构与 BCM2836 相同。

BCM2836 ARM-local peripherals
BCM2836 ARM 本地外设

https://datasheets.raspberrypi.com/bcm2836/bcm2836-peripherals.pdf

Cortex-A53 MPCore Processor Technical Reference Manual
Cortex-A53 MPCore 处理器技术参考手册

https://developer.arm.com/documentation/ddi0500/latest/

demos

pi@raspberrypi:~/OLED_Stats $ 
$ cat stats.py
import time
import board
import busio
import digitalio

from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306

import subprocess

# Define the Reset Pin
oled_reset = digitalio.DigitalInOut(board.D4)

# Display Parameters
WIDTH = 128
HEIGHT = 64
BORDER = 5

# Display Refresh
LOOPTIME = 1.0

# Use for I2C.
i2c = board.I2C()
oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C, reset=oled_reset)

# Clear display.
oled.fill(0)
oled.show()

# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
image = Image.new("1", (oled.width, oled.height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a white background
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)

font = ImageFont.truetype('PixelOperator.ttf', 16)
#font = ImageFont.load_default()

while True:

    # Draw a black filled box to clear the image.
    draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)

    # Shell scripts for system monitoring from here :
    # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
    cmd = "hostname -I | cut -d\' \' -f1"
    IP = subprocess.check_output(cmd, shell = True )
    cmd = "top -bn1 | grep load | awk '{printf \"CPU: %.2f\", $(NF-2)}'"
    CPU = subprocess.check_output(cmd, shell = True )
    cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
    MemUsage = subprocess.check_output(cmd, shell = True )
    cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
    Disk = subprocess.check_output(cmd, shell = True )
    cmd = "vcgencmd measure_temp |cut -f 2 -d '='"
    Temp = subprocess.check_output(cmd, shell = True )

    # Pi Stats Display
    draw.text((0, 0), "IP: " + str(IP,'utf-8'), font=font, fill=255)
    draw.text((0, 16), str(CPU,'utf-8') + "LA", font=font, fill=255)
    draw.text((80, 16), str(Temp,'utf-8') , font=font, fill=255)
    draw.text((0, 32), str(MemUsage,'utf-8'), font=font, fill=255)
    draw.text((0, 48), str(Disk,'utf-8'), font=font, fill=255)

    # Display image
    oled.image(image)
    oled.show()
    time.sleep(LOOPTIME)

"""

# Created by: Michael Klements
# For Raspberry Pi Desktop Case with OLED Stats Display
# Base on Adafruit CircuitPython & SSD1306 Libraries

# Installation & Setup Instructions
# https://www.the-diy-life.com/add-an-oled-stats-display-to-raspberry-pi-os-bullseye/

"""

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

Raspberry Pi & 0.96 inch SSD1306 OLED display All In One

https://www.cnblogs.com/xgqfrms/p/17380248.html



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-05-08 11:56  xgqfrms  阅读(26)  评论(5编辑  收藏  举报