i2cdetect muestra una cuadrícula vacía con un BME280 y un sensor de luz en mi Pi 4
Traducido del English por IA ·
Vale, esto es para mi monitor de ambiente del laboratorio (proyecto de 2.º año). Pi 4, Raspberry Pi OS Bookworm, una placa breakout BME280 y otra VEML7700 de luz (lux), ambas de estilo Adafruit con sus propios reguladores. El plan es que Python en la Pi lea las dos cada 30 s y publique en Hermetry. La parte de Hermetry ya funciona, probé con un valor falso y aparece en mi placa.Los sensores no. Activé I2C en raspi-config, reinicié y:
$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
...
70: -- -- -- -- -- -- -- --
Conexionado: VIN al pin 1 (3,3 V), GND al pin 6, SDA al GPIO 3, SCL al GPIO 5. Ambas placas están conectadas en cadena en una protoboard. Ya cambié los cables puente. ¿Es posible que los dos sensores estén defectuosos? No eran muy caros.
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.
Traducido del English por IA ·
¿Por qué es el bus 1 y no el 0? Siempre me lo he preguntado con estos comandos
Why is it bus 1 and not 0? I always wondered that with these commands
Traducido del English por IA ·
El bus 0 está reservado para la EEPROM de identificación del HAT en los pines 27/28. El bus 1 es el de usuario. Aoife, cuando dices «GPIO 3», ¿te refieres al pin físico 3 o al GPIO 3 de BCM?
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?
Traducido del English por IA ·
…Me guié por los números impresos en mi cable breakout, que creo que son números GPIO. ¿Entonces GPIO3 y GPIO5?
…I went by the numbers printed on my breakout cable, which I think are GPIO numbers. So GPIO3 and GPIO5?
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.
Traducido del English por IA ·
Sí, era eso 🤦 Moví dos cables y aparecieron las dos direcciones (0x10 y 0x77). El script funcionó a la primera y las cuatro teclas ya están en mi placa. Lección aprendida: los números de pin físicos y los números GPIO no son lo mismo
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
Traducido del English por IA ·
gracias Lee por la explicación del bus 0, ahora tiene sentido
thanks Lee for the bus 0 explanation, makes sense now
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

