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.

