Translated from Türkçe by AI ·
Don’t write it yourself in Python, the kernel already has a ready-made software I2C that does the bit-banging and correctly monitors clock stretching. That’s exactly why I moved the SCD30 over to it. /boot/config.txt (on Bookworm /boot/firmware/config.txt):
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=23,i2c_gpio_scl=24,i2c_gpio_delay_us=2
Reboot, and check that 0x61 shows up with i2cdetect -y 3. In the code, use SMBus(3) instead of SMBus(1). Move the sensor to GPIO 23/24, and put a 4.7k pull-up to 3.3V (the internal pull-ups on the hardware I2C pins aren’t there in this setup). If you have other sensors, they can stay on bus 1.
Also, do the reading according to the sensor’s “data ready” command (0x0202); if you read while the measurement isn’t ready, it also gives nonsense. If an error still happens now and then, retry once and skip that reading; don’t send anything for a skipped reading, the last value stays in Hermetry.
Python’da kendin yazma, çekirdekte zaten hazır bir yazılım I2C var, bit-bang’i o yapıyor ve clock stretching’i doğru izliyor. SCD30’u ben de tam bu yüzden ona taşıdım. /boot/config.txt (Bookworm’da /boot/firmware/config.txt):
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=23,i2c_gpio_scl=24,i2c_gpio_delay_us=2
Yeniden başlat, i2cdetect -y 3 ile 0x61’i gör. Kodda SMBus(1) yerine SMBus(3). Sensörü GPIO 23/24’e taşı, 3.3V’a 4.7k pull-up koy (donanım I2C pinlerindeki dahili pull-up’lar burada yok). Diğer sensörlerin varsa onlar bus 1’de kalabilir.
Bir de okumayı sensörün “data ready” komutuna (0x0202) göre yap, ölçüm hazır değilken okursan da saçmalıyor. Arada bir hata yine olursa bir kez tekrar dene, o okumayı atla; boş geçen okuma için bir şey gönderme, Hermetry’de son değer kalır.

