Pi 4 zeigt 52 Grad, das ist die CPU. Wie lese ich die Raumtemperatur aus und sende sie?
Von English mit KI übersetzt ·
Ich bin bei der Pi-Seite absoluter Anfänger. Mein Raspberry Pi 4 soll die Temperatur in meiner Kellerwerkstatt messen und jede Minute an Hermetry senden. Ich habe einem Tutorial gefolgt, das vcgencmd measure_temp verwendet hat, und den Sendeteil mit paho zum Laufen gebracht, der Wert erscheint auf meinem Dashboard. Aber er zeigt 52 Grad an, und mein Keller ist definitiv nicht 52 Grad warm.Also habe ich einen DS18B20 gekauft (die wasserdichte Version mit Kabel). Rot an 5V, Schwarz an GND, Gelb an GPIO4. In /sys/bus/w1/devices/ erscheint nichts, nur w1_bus_master1 oder manchmal nicht einmal das. Ich habe gelesen, dass Leute einen Widerstand erwähnen, aber im Kit war keiner dabei.
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.
Von English mit KI übersetzt ·
Hat der Pi nicht schon einen eigenen Temperatursensor? Den liest vcgencmd doch aus, glaube ich.
Doesn’t the Pi have its own temperature sensor already? That’s what vcgencmd reads I thought.
Von English mit KI übersetzt ·
Ja, aber das ist die Temperatur des CPU-Chips, deshalb 52. Im Gehäuse wird es nie Raumtemperatur haben.
It does but it’s the CPU chip temperature, that’s why 52. It’ll never be room temperature inside the case.
Von English mit KI übersetzt ·
Hast du 1-Wire in raspi-config aktiviert? Und der Widerstand ist nicht optional, 4,7k zwischen Daten und Versorgung.
Did you enable 1-Wire in raspi-config? And the resistor is not optional, 4.7k between data and power.
Von English mit KI übersetzt ·
Versorge ihn auch nicht mit 5V. Die Datenleitung wird auf die Spannung hochgezogen, mit der du ihn versorgst, und die GPIO-Pins des Pi vertragen nur 3.3V.
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.
Von English mit KI übersetzt ·
Das Gleiche hatte ich im ersten Jahr, der Sensor hat danach funktioniert, aber ich hatte Glück. Komplette Checkliste:Verkabelung: Rot an 3V3 (Pin 1), Schwarz an GND (Pin 6), Gelb an GPIO4 (Pin 7), und ein 4,7k-Widerstand von Gelb nach 3V3. Füge dtoverlay=w1-gpio zu /boot/firmware/config.txt hinzu (oder /boot/config.txt bei älteren Images) und starte neu. Du solltest einen Ordner 28-xxxxxxxxxxxx sehen.Dann das Skript, mit dem paho-Code, den du schon hast:
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)
Verwende einen neuen Schlüsselnamen wie temp_c, damit sich die CPU-Werte nicht mit den anderen im selben Diagramm vermischen. Der Broker-Host steht auf der Karte Connection details des Geräts.
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.
Von English mit KI übersetzt ·
Habe einen Widerstand von einem Freund bekommen, Rot auf 3V3 umgesteckt, das Overlay aktiviert und der Ordner 28- ist erschienen. Der Fühler hat die 5V überlebt. Der Keller liegt bei 17,8, was plausibel klingt. Den CPU-Wert habe ich als separaten Schlüssel behalten, könnte praktisch sein.
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.
Von English mit KI übersetzt ·
Falls Sie das Kabel jemals länger als ein paar Meter verlegen und die Messwerte unzuverlässig werden, verringern Sie den Widerstand auf 2,2k.
If you ever run the cable longer than a few metres and readings get flaky, drop the resistor to 2.2k.
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.
Mitdiskutieren
Melde dich an, um Fragen zu stellen und zu beantworten, hilfreiche Beiträge mit „Gefällt mir“ zu markieren und die Antwort zu kennzeichnen, die dein Problem gelöst hat. Jeder Beitrag bringt Punkte und Stufen.

