From b09c8339ac3c7dfb802e7d123f7193ef3f7942fd Mon Sep 17 00:00:00 2001 From: David Montero Date: Sat, 23 May 2026 18:06:42 +0200 Subject: [PATCH] fix(examples): use hardware I2C (not SoftI2C) in smart-ui-eyes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/src/data/examples-100-days.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/data/examples-100-days.ts b/frontend/src/data/examples-100-days.ts index 7fdc5384..87c57b3b 100644 --- a/frontend/src/data/examples-100-days.ts +++ b/frontend/src/data/examples-100-days.ts @@ -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)