Yapay zekâ tarafından English dilinden çevrildi ·
James kablolamayı doğru yapmış. İki bus, her biri 2.2k, bu şekilde sorun olmaz. Biz bir pompa evinde bu yöntemle bus başına 14 probe çalıştırıyoruz.85.0, DS18B20’nin açılış değeridir; okumanın dönüşüm bitmeden yapıldığı anlamına gelir, genellikle bus üzerindeki bir brown-out. Kodda eleyin, asla göndermeyin.Anahtarlara gelince, geçmiş birikmeden şimdi değiştirin. Anahtarlar tüm organizasyon genelinde ayrı isimler olarak sayılır (Starter 250 ile sınırlar), bu yüzden sensör başına ROM id’leri ikinci bir bodrum kurmaya başladığınızda bu kotayı hızla tüketir. Onlara konumlarına göre isim verin, ROM id’den konuma giden bir eşlemeyi Pi üzerindeki bir dosyada tutun ve 20 değerin hepsini tek mesajla gönderin. 20 noktalı tek bir mesaj, tek noktalı bir mesajla aynı kotayı harcar.
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)
Anahtar kuralları Telemetry keys sayfasında.
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.

