Her yeniden başlatmadan sonra sensör servisim /dev/i2c-1 bulunamadığı için çöküyor
Yapay zekâ tarafından English dilinden çevrildi ·
Bir otelde tesis yöneticisiyim; teknik odamıza BME280 sensörlü bir Pi 4 kurdum. Bir Python betiği sensörü okuyup Hermetry’ye yayımlıyor ve systemd servisi olarak çalışıyor. Pi yeniden başlatılana kadar çalışıyor, ardından servis şu hatayla sonlanıyor:
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
sensor.service: Main process exited, code=exited, status=1/FAILURE
SSH ile bağlanıp sudo modprobe i2c-dev komutunu çalıştırdıktan ve servisi yeniden başlattıktan sonra sistem bir sonraki yeniden başlatmaya kadar çalışıyor. Pazar günü elektrik kesintisi yaşadık ve kart yalnızca eski değerleri gösterdiği için kimse bir gün boyunca fark etmedi.
Facility manager at a hotel, I set up a Pi 4 with a BME280 in our plant room. A Python script reads it and publishes to Hermetry, running as a systemd service. It works until the Pi reboots, then the service dies with:
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
sensor.service: Main process exited, code=exited, status=1/FAILURE
If I SSH in and run sudo modprobe i2c-dev then restart the service, it works until the next reboot. We had a power cut on Sunday and nobody noticed for a day because the board just showed old values.
Yapay zekâ tarafından English dilinden çevrildi ·
raspi-config içinde I2C’yi etkinleştirdiniz mi? Bu, açılışta yüklenmesini sağlamalıdır.
Did you enable I2C in raspi-config? That should load it at boot.
Yapay zekâ tarafından English dilinden çevrildi ·
Yaptım ve emin olmak için /boot/config.txt dosyasına dtparam=i2c_arm=on satırını da kendim ekledim.
I did, and I also added dtparam=i2c_arm=on to /boot/config.txt myself to be sure.
Yapay zekâ tarafından English dilinden çevrildi ·
Belki modülün yüklenmesi için betiğin başına time.sleep(30) eklemeyi deneyebilirsin?
maybe put time.sleep(30) at the start of the script so the module has time to load?
Yapay zekâ tarafından English dilinden çevrildi ·
Hangi işletim sistemi sürümü? Bookworm ise sorun budur: artık dosya /boot/firmware/config.txt, /boot/config.txt ise artık okunmuyor (içinde bunu belirten bir not var). Satırın, kimsenin okumadığı bir dosyada duruyor; ayrıca daha sonra değiştirdiğin başka bir şey raspi-config ayarını geri almış olabilir.Ben şunu yapardım:
# /boot/firmware/config.txt
dtparam=i2c_arm=on
# load the char device at boot
echo i2c-dev | sudo tee /etc/modules-load.d/i2c.conf
Servisin tek seferde çökmek yerine yavaş başlatmayı atlatmasını da sağla:
[Service]
Restart=on-failure
RestartSec=10
Rahul, bir bekleme çoğu gün işe yarar, ama Restart= bunu ve başka her başlatma yarışını kapsar.Elektrik kesintisinden sonraki eski değerlere gelince: sensörün profiline bir çevrimdışı alarmı ekle. Böylece ölü bir Pi, normal görünen bir grafik yerine sana bir alarm verir.
Which OS release? If it’s Bookworm, that’s your bug: the file is /boot/firmware/config.txt now, and /boot/config.txt is not read anymore (there’s a note in it saying so). Your line is in a file nobody reads, and raspi-config may have been undone by something else you changed later.
What I’d do:
# /boot/firmware/config.txt
dtparam=i2c_arm=on
# load the char device at boot
echo i2c-dev | sudo tee /etc/modules-load.d/i2c.conf
And make the service survive a slow start instead of dying once:
[Service]
Restart=on-failure
RestartSec=10
Rahul, a sleep would work most days, but Restart= covers this and any other startup race.
About the old values after the power cut: add an offline alarm on the sensor’s profile. Then a dead Pi gets you an alarm instead of a chart that looks normal.
Yapay zekâ tarafından English dilinden çevrildi ·
raspi-config neden her iki dosyayı da yazmıyor? Kolay bir tuzak gibi görünüyor.
Why does raspi-config not just write both files? Seems like an easy trap.
Yapay zekâ tarafından English dilinden çevrildi ·
Megan, tam isabet. Bookworm, ve benim satırım eski /boot/config.txt dosyasındaydı; dosyanın başında taşındığını belirten bir yorum var, bunu hiç görmemiştim. Doğru dosyayı düzelttim, modules-load satırını ve Restart=on-failure ekledim, fişi iki kez çektim, her iki seferde de sorunsuz açıldı. Çevrimdışı alarmı da kuruldu.
Megan, spot on. Bookworm, and my line was in the old /boot/config.txt, which has a comment at the top saying it moved, never saw it. Fixed the right file, added the modules-load line and Restart=on-failure, pulled the plug twice, came up fine both times. Offline alarm is set too.
Yapay zekâ tarafından English dilinden çevrildi ·
Marcus, raspi-config doğru olanı yazıyor. Yanlış yerde olan, Emily’nin kendi elle yaptığı düzenlemeydi.
Marcus, raspi-config does write the right one. Emily’s own manual edit was the one in the wrong place.
- Bu konuyu yanıtlamak için giriş yapmış olmalısınız.
Sohbete katılın
Soru sormak ve yanıtlamak, yararlı gönderileri beğenmek ve sorununuzu çözen yanıtı işaretlemek için oturum açın. Her katkı puan ve seviye kazandırır.

