Traducido del English por IA ·
James tiene bien el cableado. Dos buses, 2.2k cada uno, y te irá bien. Nosotros usamos 14 sondas por bus en una casa de bombas de esa forma.85.0 es el valor de encendido del DS18B20; significa que la lectura se hizo antes de terminar una conversión, normalmente una caída de tensión en el bus. Descártalo en el código, nunca lo envíes.En cuanto a las claves, cámbialo ahora, antes de tener historial. Las claves cuentan como nombres distintos en toda la organización (Starter limita a 250), así que los ID ROM por sensor consumirán ese límite muy rápido en cuanto montes una segunda bodega. Nómbralas por posición, guarda un mapa de ID ROM a posición en un archivo en la Pi y envía los 20 en un solo mensaje. Un mensaje con 20 puntos cuesta la misma cuota que uno con un solo punto.
import glob, json, paho.mqtt.client as mqtt
MAP = {"28-0316a2794bff": "rack1.top", "28-0316a27a11ff": "rack1.mid"} # etc
vals = {}
for p in glob.glob("/sys/bus/w1/devices/28-*/temperature"):
rom = p.split("/")[-2]
t = int(open(p).read()) / 1000
if rom in MAP and t != 85.0:
vals["cellar." + MAP[rom]] = round(t, 2)
c.publish("v1/telemetry", json.dumps(vals), qos=1)
Las reglas de las claves están en Telemetry keys.
James has the wiring right. Two buses, 2.2k each, and you’ll be fine. We run 14 probes per bus in a pump house that way.
85.0 is the power-on value of the DS18B20, it means the read happened before a conversion finished, usually a brown-out on the bus. Drop it in code, never send it.
On the keys, change it now before you have history. Keys count as distinct names across the whole organisation (Starter caps you at 250), so ROM ids per sensor will eat that fast once you build a second cellar. Name them by position, keep a map from ROM id to position in a file on the Pi, and send all 20 in one message. One message with 20 points costs the same quota as one with one.
import glob, json, paho.mqtt.client as mqtt
MAP = {"28-0316a2794bff": "rack1.top", "28-0316a27a11ff": "rack1.mid"} # etc
vals = {}
for p in glob.glob("/sys/bus/w1/devices/28-*/temperature"):
rom = p.split("/")[-2]
t = int(open(p).read()) / 1000
if rom in MAP and t != 85.0:
vals["cellar." + MAP[rom]] = round(t, 2)
c.publish("v1/telemetry", json.dumps(vals), qos=1)
Key rules are on Telemetry keys.

