Traduit de English par IA ·
C’est exactement le problème, j’ai fait la même chose sur mon premier montage. Les broches I2C sont la broche physique 3 (c’est le BCM GPIO2, SDA) et la broche physique 5 (BCM GPIO3, SCL). Tu as branché SDA sur GPIO3, qui est en réalité SCL, et SCL sur GPIO5, qui correspond à la broche physique 29 et n’a rien à voir avec l’I2C. Le bus n’a donc aucun périphérique qui répond, d’où la grille vide. Les capteurs sont presque certainement en bon état.Place SDA sur la broche physique 3 et SCL sur la broche physique 5 ; tu devrais alors voir 0x77 (ou 0x76, selon le cavalier SDO) pour le BME280 et 0x10 pour le VEML7700. Le Pi dispose déjà de résistances de rappel (pull-up) de 1,8 kΩ sur ces deux broches, et les breakouts en ajoutent les leurs, donc n’en rajoute pas.La lecture et l’envoi sont ensuite courts. J’utilise les pilotes CircuitPython d’Adafruit avec 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)
Objet à plat, donc Hermetry l’horodate à la réception, ce qui convient pour des mesures toutes les 30 s. Les règles de payload sont ici si tu veux ajouter des horodatages plus tard : 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.

