Pi 4'te BME280 ve bir ışık sensörü varken i2cdetect boş bir tablo gösteriyor
Yapay zekâ tarafından English dilinden çevrildi ·
Tamam, bu benim laboratuvar ortam izleme projem için (2. sınıf projesi). Pi 4, Raspberry Pi OS Bookworm, bir BME280 breakout ve bir VEML7700 lux breakout; ikisi de kendi regülatörleri olan Adafruit tarzı kartlar. Plan, Pi üzerinde Python ile ikisini de 30 saniyede bir okuyup Hermetry’ye yayınlamak. Hermetry tarafı zaten çalışıyor, sahte bir değerle test ettim ve kartımda görünüyor.Sensörler çalışmıyor. raspi-config’te I2C’yi etkinleştirdim, yeniden başlattım ve:
$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
...
70: -- -- -- -- -- -- -- --
Bağlantı: VIN pin 1’e (3.3 V), GND pin 6’ya, SDA GPIO 3’e, SCL GPIO 5’e. İkisi de breadboard üzerinde zincirleme bağlı. Jumper kabloları zaten değiştirdim. İki sensörün de bozuk olması mümkün mü? Fena sayılmayacak kadar ucuzdular.
ok so this is for my lab environment monitor (2nd year project). Pi 4, Raspberry Pi OS Bookworm, a BME280 breakout and a VEML7700 lux breakout, both Adafruit-style boards with their own regulators. The plan is Python on the Pi reading both every 30 s and publishing to Hermetry. The Hermetry side already works, I tested with a fake value and it shows up on my board.
The sensors don’t. I enabled I2C in raspi-config, rebooted, and:
$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
...
70: -- -- -- -- -- -- -- --
Wiring: VIN to pin 1 (3.3 V), GND to pin 6, SDA to GPIO 3, SCL to GPIO 5. Both boards daisy-chained on a breadboard. I’ve swapped jumper wires already. Is it possible both sensors are dead? They were cheap-ish.
Yapay zekâ tarafından English dilinden çevrildi ·
Neden bus 0 değil de bus 1? Bu komutlarla ilgili bunu hep merak etmişimdir
Why is it bus 1 and not 0? I always wondered that with these commands
Yapay zekâ tarafından English dilinden çevrildi ·
Bus 0, 27/28 numaralı pinlerdeki HAT ID EEPROM için ayrılmıştır. Bus 1 kullanıcıya aittir. Aoife, “GPIO 3” dediğinde fiziksel pin 3’ü mü yoksa BCM GPIO 3’ü mü kastediyorsun?
Bus 0 is reserved for the HAT ID EEPROM on pins 27/28. Bus 1 is the user one. Aoife, when you say “GPIO 3”, do you mean physical pin 3 or BCM GPIO 3?
Yapay zekâ tarafından English dilinden çevrildi ·
…Breakout kablomun üzerinde yazan numaralara göre ilerledim; bunların GPIO numaraları olduğunu düşünüyorum. Yani GPIO3 ve GPIO5?
…I went by the numbers printed on my breakout cable, which I think are GPIO numbers. So GPIO3 and GPIO5?
Yapay zekâ tarafından English dilinden çevrildi ·
Sorun tam olarak bu, ilk kurulumumda da aynı şeyi yapmıştım. I2C pinleri fiziksel pin 3 (BCM GPIO2, SDA) ve fiziksel pin 5 (BCM GPIO3, SCL). Sen SDA’yı aslında SCL olan GPIO3’e, SCL’yi ise fiziksel pin 29 olan ve hiç I2C olmayan GPIO5’e bağlamışsın. Bu yüzden veriyolunda yanıt veren bir cihaz yok ve boş tablo görüyorsun. Sensörlerin büyük ihtimalle sağlam.SDA’yı fiziksel pin 3’e, SCL’yi fiziksel pin 5’e taşı; o zaman BME280 için 0x77 (ya da SDO jumper’ına bağlı olarak 0x76) ve VEML7700 için 0x10 görmelisin. Pi’nin bu iki pinde zaten 1.8 kΩ pull-up dirençleri var ve breakout kartları da kendi dirençlerini ekliyor, o yüzden fazlasını ekleme.Okuma ve gönderme kısmı da kısa. Ben Adafruit CircuitPython sürücülerini ve paho’yu kullanıyorum:
import json, time, board, adafruit_bme280.basic as bme, adafruit_veml7700
import paho.mqtt.client as mqtt
i2c = board.I2C()
env = bme.Adafruit_BME280_I2C(i2c, address=0x77)
lux = adafruit_veml7700.VEML7700(i2c)
c = mqtt.Client(client_id="lab-env-01")
c.username_pw_set(TOKEN) # token as username, no password
c.tls_set()
c.connect(BROKER_HOST, 8883, 60)
c.loop_start()
while True:
msg = {"temp_c": round(env.temperature, 2), "rh": round(env.humidity, 1),
"pressure_hpa": round(env.pressure, 1), "lux": round(lux.lux, 1)}
c.publish("v1/telemetry", json.dumps(msg), qos=1)
time.sleep(30)
Düz bir nesne, bu yüzden Hermetry 30 saniyelik okumalar için alındığı zamanı damgalar, bu yeterli. Zaman damgası eklemek istersen payload kuralları burada: MQTT topics and payload reference.
That’s the problem, I did exactly the same thing on my first build. The I2C pins are physical pin 3 (that’s BCM GPIO2, SDA) and physical pin 5 (BCM GPIO3, SCL). You have SDA on GPIO3, which is actually SCL, and SCL on GPIO5, which is physical pin 29 and not I2C at all. So the bus has no device answering and you get the empty grid. The sensors are almost certainly fine.
Move SDA to physical pin 3 and SCL to physical pin 5, then you should see 0x77 (or 0x76, depends on the SDO jumper) for the BME280 and 0x10 for the VEML7700. The Pi has 1.8 kΩ pull-ups on those two pins already, and the breakouts add their own, so don’t add more.
Then reading and sending is short. I use the Adafruit CircuitPython drivers plus paho:
import json, time, board, adafruit_bme280.basic as bme, adafruit_veml7700
import paho.mqtt.client as mqtt
i2c = board.I2C()
env = bme.Adafruit_BME280_I2C(i2c, address=0x77)
lux = adafruit_veml7700.VEML7700(i2c)
c = mqtt.Client(client_id="lab-env-01")
c.username_pw_set(TOKEN) # token as username, no password
c.tls_set()
c.connect(BROKER_HOST, 8883, 60)
c.loop_start()
while True:
msg = {"temp_c": round(env.temperature, 2), "rh": round(env.humidity, 1),
"pressure_hpa": round(env.pressure, 1), "lux": round(lux.lux, 1)}
c.publish("v1/telemetry", json.dumps(msg), qos=1)
time.sleep(30)
Flat object, so Hermetry stamps it with the receive time, fine for 30 s readings. Payload rules are here if you want to add timestamps later: MQTT topics and payload reference.
Yapay zekâ tarafından English dilinden çevrildi ·
Evet, sorun buymuş 🤦 İki kabloyu yer değiştirdim ve her iki adres de gögöründü (0x10 ve 0x77). Betik ilk denemede çalıştı ve artık dört tuş kartımda. Öğrendiğim ders: fiziksel pin numaraları ile GPIO numaraları aynı şey değilmiş
yep that was it 🤦 moved two wires and both addresses popped up (0x10 and 0x77). Script ran first try and the four keys are on my board now. lesson learned: physical pin numbers and GPIO numbers are not the same thing
Yapay zekâ tarafından English dilinden çevrildi ·
Bus 0 açıklaman için teşekkürler Lee, şimdi mantığını anladım
thanks Lee for the bus 0 explanation, makes sense now
- 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.

