Raspberry Pi CPU Temperature

Description

This flow reads the CPU temperature of the Raspberry Pi.

Motivation

I use the Sense HAT on Raspberry Pi to get environment data of the room. The problem of getting the room temperature with Sense HAT is the temperature of the Raspberry Pi itself, because it influences the measurement.

By reading the CPU temperature of the Raspberry Pi, I can calculate the real temperature by using the formula temp = (cpu_temp - sensor_temp) / factor. To calibrate the data you need to estimate the factor for the formula by comparing the real room temperature with the sensor measurements.

Requirement

System command: vcgencmd measure_temp

Described Use Case

  • Raspberry Pi (I've tested 3B+ on Raspbian)
  • Sense HAT (directly mounted on the Raspi)
[{"id":"f9c23d23.c8c24","type":"exec","z":"1841b51e.41772b","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Raspberry CPU Temperature","x":310,"y":200,"wires":[["a0ad4644.0efbf8"],[],[]]},{"id":"a0ad4644.0efbf8","type":"function","z":"1841b51e.41772b","name":"Extract CPU Temp","func":"const re = /^temp=(.*)'C$/gm;\nmsg.payload = Number(msg.payload.replace(re, '$1'));\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":180,"wires":[["8317134.cff18f"]]},{"id":"a97d78fc.40c268","type":"inject","z":"1841b51e.41772b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":80,"y":200,"wires":[["f9c23d23.c8c24"]]},{"id":"8317134.cff18f","type":"debug","z":"1841b51e.41772b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":180,"wires":[]}]

Collection Info

Flow Info

Created 6 years, 5 months ago
Updated 5 years, 7 months ago
Rating: 4.666666666666667 3

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • exec (x1)
  • function (x1)
  • inject (x1)

Tags

  • cpu
  • temperature
  • sensehat
  • system
  • calibration
  • raspberrypi
  • raspberry
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option