La Pi 4 marca 52 grados, que es la CPU. ¿Cómo leo la temperatura de la habitación y la envío?
Traducido del English por IA ·
Soy un principiante total con la parte de la Pi. Quiero que mi Raspberry Pi 4 mida la temperatura de mi taller del sótano y la envíe a Hermetry cada minuto. Seguí un tutorial que usaba vcgencmd measure_temp y la parte de envío funcionó con paho, el número aparece en mi panel. Pero marca 52 grados y mi sótano definitivamente no está a 52 grados.Así que compré un DS18B20 (el impermeable con cable). Rojo a 5V, negro a GND, amarillo a GPIO4. No aparece nada en /sys/bus/w1/devices/, solo w1_bus_master1 o a veces ni eso. He visto que la gente menciona una resistencia, pero el kit no traía ninguna.
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.
Traducido del English por IA ·
¿No tiene ya la Pi su propio sensor de temperatura? Eso es lo que lee vcgencmd, creo.
Doesn’t the Pi have its own temperature sensor already? That’s what vcgencmd reads I thought.
Traducido del English por IA ·
Sí, pero es la temperatura del chip de la CPU, por eso marca 52. Dentro de la caja nunca será la temperatura ambiente.
It does but it’s the CPU chip temperature, that’s why 52. It’ll never be room temperature inside the case.
Traducido del English por IA ·
¿Habilitaste 1-Wire en raspi-config? Y la resistencia no es opcional, 4.7k entre datos y alimentación.
Did you enable 1-Wire in raspi-config? And the resistor is not optional, 4.7k between data and power.
Traducido del English por IA ·
Además, no le des 5V. La línea de datos se eleva hasta la tensión con la que lo alimentes, y los pines GPIO de la Pi solo soportan 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.
Traducido del English por IA ·
Me pasó lo mismo en primer año, la sonda funcionó después, pero tuve suerte. Lista de verificación completa:Cableado: rojo a 3V3 (pin 1), negro a GND (pin 6), amarillo a GPIO4 (pin 7), y una resistencia de 4,7k entre el amarillo y 3V3. Añade dtoverlay=w1-gpio a /boot/firmware/config.txt (o /boot/config.txt en imágenes antiguas) y reinicia. Deberías ver una carpeta 28-xxxxxxxxxxxx.Luego el script, con el mismo código paho que ya tienes:
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)
Usa un nombre de clave nuevo como temp_c para que las lecturas de la CPU no se mezclen en el mismo gráfico. El host del broker está en la tarjeta Connection details del dispositivo.
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.
Traducido del English por IA ·
Conseguí una resistencia de un amigo, moví el cable rojo a 3V3, activé el overlay y apareció la carpeta 28-. La sonda sobrevivió al 5V. El sótano marca 17,8, lo cual parece correcto. Mantuve la de la CPU como una clave separada, podría ser útil.
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.
Traducido del English por IA ·
Si alguna vez tiendes el cable a más de unos pocos metros y las lecturas empiezan a fallar, baja la resistencia a 2,2k.
If you ever run the cable longer than a few metres and readings get flaky, drop the resistor to 2.2k.
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

