Pi 4 52 derece gösteriyor, bu CPU sıcaklığı. Oda sıcaklığını nasıl okuyup gönderebilirim?
Yapay zekâ tarafından English dilinden çevrildi ·
Pi tarafında tamamen acemiyim. Raspberry Pi 4’ümün bodrum atölyemdeki sıcaklığı ölçmesini ve her dakika Hermetry’ye göndermesini istiyorum. Bir eğitimi takip ettim, vcgencmd measure_temp kullanılıyordu ve paho ile gönderme kısmı çalıştı, sayı kontrol panelimde görünüyor. Ancak 52 derece diyor ve bodrumum kesinlikle 52 derece değil.Bu yüzden suya dayanıklı olanı (kablolu) bir DS18B20 satın aldım. Kırmızıyı 5V’a, siyahı GND’ye, sarıyı GPIO4’e bağladım. /sys/bus/w1/devices/ içinde hiçbir şey görünmüyor, yalnızca w1_bus_master1 ya da bazen o bile yok. İnsanların bir direnç olması gerektiğinden bahsettiğini gördüm ama kitte direnç yoktu.
Total newbie with the Pi side of things. I want my Raspberry Pi 4 to measure the temperature in my basement workshop and send it to Hermetry every minute. I followed a tutorial that used vcgencmd measure_temp and got the sending part working with paho, the number shows on my dashboard. But it says 52 degrees and my basement is definitely not 52.
So I bought a DS18B20 (the waterproof one with the cable). Wired red to 5V, black to GND, yellow to GPIO4. Nothing shows up in /sys/bus/w1/devices/, only w1_bus_master1 or sometimes not even that. I’ve seen people mention a resistor but the kit didn’t have one.
Yapay zekâ tarafından English dilinden çevrildi ·
Pi’nin zaten kendi sıcaklık sensörü yok mu? Sanırım vcgencmd’nin okuduğu da bu.
Doesn’t the Pi have its own temperature sensor already? That’s what vcgencmd reads I thought.
Yapay zekâ tarafından English dilinden çevrildi ·
Gösteriyor ama bu CPU çip sıcaklığı, bu yüzden 52. Kasanın içi asla oda sıcaklığında olmaz.
It does but it’s the CPU chip temperature, that’s why 52. It’ll never be room temperature inside the case.
Yapay zekâ tarafından English dilinden çevrildi ·
Raspi-config içinde 1-Wire’ı etkinleştirdin mi? Ayrıca direnç isteğe bağlı değil, veri ile besleme arasında 4.7k.
Did you enable 1-Wire in raspi-config? And the resistor is not optional, 4.7k between data and power.
Yapay zekâ tarafından English dilinden çevrildi ·
Ayrıca ona 5V vermeyin. Veri hattı, beslendiğiniz gerilime çekilir ve Pi’nin GPIO pinleri yalnızca 3.3V’a dayanır.
Also don’t feed it 5V. The data line gets pulled up to whatever you power it from, and the Pi’s GPIO pins are 3.3V only.
Yapay zekâ tarafından English dilinden çevrildi ·
Birinci sınıfta aynı şeyi yaşadım, sonradan sensör çalıştı ama şanslıydım. Tam kontrol listesi:Bağlantı: kırmızı 3V3’e (pin 1), siyah GND’ye (pin 6), sarı GPIO4’e (pin 7) ve sarıdan 3V3’e 4.7k direnç. /boot/firmware/config.txt dosyasına (eski imajlarda /boot/config.txt) dtoverlay=w1-gpio ekleyin ve yeniden başlatın. 28-xxxxxxxxxxxx klasörünü görmeniz gerekir.Ardından, sahip olduğunuz paho koduyla birlikte betik:
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)
CPU okumalarının aynı grafikte karışmaması için temp_c gibi yeni bir anahtar adı kullanın. Broker adresi cihazın Connection details kartında yer alıyor.
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.
Yapay zekâ tarafından English dilinden çevrildi ·
Bir arkadaştan bir direnç aldım, kırmızıyı 3V3’e taşıdım, overlay’i etkinleştirdim ve 28- klasörü göründü. Prob 5V’a dayandı. Bodrum 17,8, bu doğru görünüyor. CPU sıcaklığını ayrı bir anahtar olarak tuttum, işe yarayabilir.
Got a resistor from a friend, moved red to 3V3, enabled the overlay and the 28- folder appeared. Probe survived the 5V. Basement is 17.8, which sounds right. Kept the CPU one as a separate key, might be handy.
Yapay zekâ tarafından English dilinden çevrildi ·
Kabloyu birkaç metreden uzun çekmeniz ve okumalar dengesiz olmaya başlarsa, direnci 2.2k’ya indirin.
If you ever run the cable longer than a few metres and readings get flaky, drop the resistor to 2.2k.
- Bu konuyu yanıtlamak için giriş yapmış olmalısınız.
Sohbete katılın
Soru sormak ve yanıtlamak, yararlı gönderileri beğenmek ve sorununuzu çözen yanıtı işaretlemek için oturum açın. Her katkı puan ve seviye kazandırır.

