Von English mit KI übersetzt ·
James hat die Verkabelung richtig gemacht. Zwei Busse, jeweils 2.2k, dann passt das. Wir betreiben so in einem Pumpenhaus 14 Sonden pro Bus.85.0 ist der Einschaltwert des DS18B20, das bedeutet, dass die Messung vor Abschluss einer Wandlung erfolgte, meist ein Brown-out am Bus. Im Code verwerfen, niemals senden.Bei den Keys jetzt ändern, bevor Historie entsteht. Keys zählen als eindeutige Namen über die gesamte Organisation (Starter begrenzt auf 250), daher verbrauchen ROM-IDs pro Sensor dieses Kontingent schnell, sobald Sie einen zweiten Keller aufbauen. Benennen Sie sie nach Position, führen Sie eine Zuordnung von ROM-ID zu Position in einer Datei auf dem Pi und senden Sie alle 20 in einer Nachricht. Eine Nachricht mit 20 Datenpunkten kostet dasselbe Kontingent wie eine mit einem.
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)
Die Regeln für Keys stehen unter 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.

