Traducido del English por IA ·
Ese es el problema, yo hice exactamente lo mismo en mi primer montaje. Los pines I2C son el pin físico 3 (es el BCM GPIO2, SDA) y el pin físico 5 (BCM GPIO3, SCL). Tú tienes SDA en GPIO3, que en realidad es SCL, y SCL en GPIO5, que es el pin físico 29 y no es I2C en absoluto. Por eso el bus no tiene ningún dispositivo respondiendo y obtienes la cuadrícula vacía. Casi con toda seguridad los sensores están bien.Mueve SDA al pin físico 3 y SCL al pin físico 5; entonces deberías ver 0x77 (o 0x76, según el jumper SDO) para el BME280 y 0x10 para el VEML7700. La Pi ya tiene resistencias pull-up de 1,8 kΩ en esos dos pines, y las placas breakout añaden las suyas, así que no añadas más.Luego la lectura y el envío son breves. Uso los drivers de CircuitPython de Adafruit más 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)
Objeto plano, así que Hermetry le asigna la hora de recepción, lo cual sirve para lecturas de 30 s. Las reglas del payload están aquí si más adelante quieres añadir marcas de tiempo: 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.

