i2cdetect zeigt ein leeres Raster mit BME280 und Lichtsensor an meinem Pi 4
Von English mit KI übersetzt ·
Also, das ist für mein Labor-Umgebungsmonitoring (Projekt im 2. Studienjahr). Pi 4, Raspberry Pi OS Bookworm, ein BME280-Breakout und ein VEML7700-Lux-Breakout, beide Adafruit-artige Platinen mit eigenen Spannungsreglern. Der Plan ist, dass Python auf dem Pi beide alle 30 s ausliest und an Hermetry sendet. Die Hermetry-Seite funktioniert bereits, ich habe mit einem Testwert getestet und er erscheint auf meinem Board.Die Sensoren nicht. Ich habe I2C in raspi-config aktiviert, neu gestartet und:
$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
...
70: -- -- -- -- -- -- -- --
Verkabelung: VIN an Pin 1 (3,3 V), GND an Pin 6, SDA an GPIO 3, SCL an GPIO 5. Beide Boards sind auf einem Breadboard hintereinandergeschaltet. Die Jumperkabel habe ich schon getauscht. Ist es möglich, dass beide Sensoren defekt sind? Sie waren nicht gerade teuer.
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.
Von English mit KI übersetzt ·
Warum ist es Bus 1 und nicht 0? Das habe ich mich bei diesen Befehlen immer schon gefragt
Why is it bus 1 and not 0? I always wondered that with these commands
Von English mit KI übersetzt ·
Bus 0 ist für das HAT-ID-EEPROM an den Pins 27/28 reserviert. Bus 1 ist der Benutzerbus. Aoife, meinst du mit „GPIO 3“ den physischen Pin 3 oder BCM GPIO 3?
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?
Von English mit KI übersetzt ·
…Ich habe mich nach den Nummern gerichtet, die auf meinem Breakout-Kabel aufgedruckt sind, und ich glaube, das sind GPIO-Nummern. Also GPIO3 und GPIO5?
…I went by the numbers printed on my breakout cable, which I think are GPIO numbers. So GPIO3 and GPIO5?
Von English mit KI übersetzt ·
Genau das ist das Problem, ich habe bei meinem ersten Aufbau exakt dasselbe gemacht. Die I2C-Pins sind physischer Pin 3 (das ist BCM GPIO2, SDA) und physischer Pin 5 (BCM GPIO3, SCL). Du hast SDA an GPIO3 angeschlossen, das in Wirklichkeit SCL ist, und SCL an GPIO5, das physischer Pin 29 ist und überhaupt nicht I2C. Deshalb antwortet auf dem Bus kein Gerät und du bekommst das leere Raster. Die Sensoren sind mit ziemlicher Sicherheit in Ordnung.Verschiebe SDA auf physischen Pin 3 und SCL auf physischen Pin 5, dann solltest du 0x77 (oder 0x76, je nach SDO-Jumper) für den BME280 und 0x10 für den VEML7700 sehen. Der Pi hat an diesen beiden Pins bereits 1,8 kΩ Pull-up-Widerstände, und die Breakouts bringen ihre eigenen mit, also keine weiteren hinzufügen.Das Auslesen und Senden ist dann kurz. Ich verwende die Adafruit-CircuitPython-Treiber 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)
Flaches Objekt, daher stempelt Hermetry es mit der Empfangszeit, was für 30-s-Messwerte passt. Die Payload-Regeln findest du hier, falls du später Zeitstempel ergänzen willst: 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.
Von English mit KI übersetzt ·
Ja, das war es 🤦 Ich habe zwei Kabel umgesteckt und beide Adressen sind aufgetaucht (0x10 und 0x77). Das Skript lief auf Anhieb und die vier Tasten sind jetzt auf meinem Board. Gelernt: Physische Pin-Nummern und GPIO-Nummern sind nicht dasselbe
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
Von English mit KI übersetzt ·
Danke Lee für die Erklärung zu Bus 0, jetzt ergibt es Sinn
thanks Lee for the bus 0 explanation, makes sense now
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.
Mitdiskutieren
Melde dich an, um Fragen zu stellen und zu beantworten, hilfreiche Beiträge mit „Gefällt mir“ zu markieren und die Antwort zu kennzeichnen, die dein Problem gelöst hat. Jeder Beitrag bringt Punkte und Stufen.

