I want to use the ESP32-S2 with CircuitPython and 5x 0.96inch OLED I2C displays. It's working fine, but only with 2 displays.
When I assign "i2c3" or more, I'm getting an error. When I keep only "i2c1 and i2c2" or "i2c4 and i2c5" for example, it's working fine again.
But never more than 2 displays at the time.
CODE:
import time
import os
import board
import busio
import adafruit_ssd1306
from numbers import *
WIDTH = 128
HEIGHT = 64
CENTER_X = int(WIDTH/2)
CENTER_Y = int(HEIGHT/2)
SDA1 = board.IO41
SCL1 = board.IO42
SDA2 = board.IO39
SCL2 = board.IO40
SDA3 = board.IO37
SCL3 = board.IO38
SDA4 = board.IO35
SCL4 = board.IO36
SDA5 = board.IO33
SCL5 = board.IO34
i2c1 = busio.I2C(SCL1, SDA1)
i2c2 = busio.I2C(SCL2, SDA2)
i2c3 = busio.I2C(SCL3, SDA3)
i2c4 = busio.I2C(SCL4, SDA4)
i2c5 = busio.I2C(SCL5, SDA5)
#if(i2c1.try_lock()):
print("i2c1.scan(): " + str(i2c1.scan()))
i2c1.unlock()
display1 = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c1)
display2 = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c2)
display3 = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c3)
display4 = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c4)
display5 = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c5)
display1.fill(0) # Clear the display
display2.fill(0) # Clear the display
display3.fill(0) # Clear the display
display4.fill(0) # Clear the display
display5.fill(0) # Clear the display
for y, row in enumerate(ZERO):
for x, c in enumerate(row):
display5.pixel(x + 0, y + 0, c)
for y, row in enumerate(ONE):
for x, c in enumerate(row):
display5.pixel(x + 76, y + 0, c)
display5.show()
OUTPUT:
Traceback (most recent call last):
File "code.py", line 31, in <module>
ValueError: All I2C peripherals are in use
How can I fix that?