fix(examples): use hardware I2C (not SoftI2C) in smart-ui-eyes

OSError: [Errno 19] ENODEV at ssd1306.SSD1306_I2C(...) on
100d-esp32-oled-smart-ui-eyes-animation-time-and-weather-micropython.

MicroPython SoftI2C bit-bangs GPIO directly. Velxio's ESP32 QEMU
bridge listens on the emulated I2C peripheral (registers slaves like
0x3C wokwi-ssd1306 against it) and doesn't decode bit-banged GPIO
toggles as I2C frames, so the OLED never sees any writes and
i2c.writeto() returns ENODEV on first use.

machine.I2C(0, ...) routes through the hardware I2C peripheral that
QEMU emulates, the registered slave receives the bytes, the OLED
panel updates. Same code path the other working SSD1306 MicroPython
examples on this repo already use.

API surface is identical to SoftI2C — only the constructor differs —
so the rest of the user sketch needs zero changes.
This commit is contained in:
David Montero 2026-05-23 18:06:42 +02:00
parent 76f6cd9a37
commit b09c8339ac
1 changed files with 8 additions and 4 deletions

View File

@ -1946,23 +1946,27 @@ while True:
boardType: "esp32",
languageMode: 'micropython',
files: [
{ name: "main.py", content: `from machine import Pin, SoftI2C
{ name: "main.py", content: `from machine import Pin, I2C
import ssd1306
from time import sleep, localtime, time
import network, ntptime
import urequests as requests
import urandom as random
import urandom as random
# ================= CONFIG =================
SSID = "ssid"
PASSWORD = "pass"
# IST Offset: 5 hours 30 mins = (5*3600 + 30*60) = 19800 seconds
UTC_OFFSET = 19800
UTC_OFFSET = 19800
OWM_API_KEY = "key"
CITY = "city"
# ================= HARDWARE =================
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
# Hardware I2C (peripheral 0) SoftI2C bit-bangs GPIO and the Velxio
# ESP32 QEMU bridge can't route GPIO toggles back to the wokwi-ssd1306
# slave registered at 0x3C, so write_cmd fails with ENODEV. Hardware
# I2C goes through the emulated I2C controller and reaches the slave.
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
touch_next = Pin(14, Pin.IN)