Traducido del English por IA ·
Me pasó lo mismo en primer año, la sonda funcionó después, pero tuve suerte. Lista de verificación completa:Cableado: rojo a 3V3 (pin 1), negro a GND (pin 6), amarillo a GPIO4 (pin 7), y una resistencia de 4,7k entre el amarillo y 3V3. Añade dtoverlay=w1-gpio a /boot/firmware/config.txt (o /boot/config.txt en imágenes antiguas) y reinicia. Deberías ver una carpeta 28-xxxxxxxxxxxx.Luego el script, con el mismo código paho que ya tienes:
import glob, json, time
import paho.mqtt.client as mqtt
dev = glob.glob('/sys/bus/w1/devices/28-*/w1_slave')[0]
def read_c():
lines = open(dev).read().splitlines()
if not lines[0].endswith('YES'):
return None # CRC failed, skip this one
return int(lines[1].split('t=')[1]) / 1000.0
c = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id="basement-pi")
c.username_pw_set("YOUR_ACCESS_TOKEN") # token as username, no password
c.tls_set()
c.connect("YOUR_BROKER_HOST", 8883, keepalive=60)
c.loop_start()
while True:
t = read_c()
if t is not None:
c.publish("v1/telemetry", json.dumps({"temp_c": round(t, 2)}), qos=1)
time.sleep(60)
Usa un nombre de clave nuevo como temp_c para que las lecturas de la CPU no se mezclen en el mismo gráfico. El host del broker está en la tarjeta Connection details del dispositivo.
Did the same thing in first year, the probe was fine afterwards but I was lucky. Full checklist:
Wiring: red to 3V3 (pin 1), black to GND (pin 6), yellow to GPIO4 (pin 7), and a 4.7k resistor from yellow to 3V3. Add dtoverlay=w1-gpio to /boot/firmware/config.txt (or /boot/config.txt on older images) and reboot. You should see a 28-xxxxxxxxxxxx folder.
Then the script, on the same paho code you have:
import glob, json, time
import paho.mqtt.client as mqtt
dev = glob.glob('/sys/bus/w1/devices/28-*/w1_slave')[0]
def read_c():
lines = open(dev).read().splitlines()
if not lines[0].endswith('YES'):
return None # CRC failed, skip this one
return int(lines[1].split('t=')[1]) / 1000.0
c = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id="basement-pi")
c.username_pw_set("YOUR_ACCESS_TOKEN") # token as username, no password
c.tls_set()
c.connect("YOUR_BROKER_HOST", 8883, keepalive=60)
c.loop_start()
while True:
t = read_c()
if t is not None:
c.publish("v1/telemetry", json.dumps({"temp_c": round(t, 2)}), qos=1)
time.sleep(60)
Use a new key name like temp_c so the CPU readings don’t mix into the same chart. Broker host is on the device’s Connection details card.

