Skip to content

Instantly share code, notes, and snippets.

@IOIO72

IOIO72/README.md Secret

Last active March 10, 2019 09:07
Show Gist options
  • Save IOIO72/0e9fccd57bdec602a17a9848e748395f to your computer and use it in GitHub Desktop.
Save IOIO72/0e9fccd57bdec602a17a9848e748395f to your computer and use it in GitHub Desktop.
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":[]}]
@colinl
Copy link

colinl commented Mar 10, 2019

An extended version of this node that allows the collection of other data from the vgencmd would be very useful. Perhaps pass in the parameter required via the payload.

@colinl
Copy link

colinl commented Mar 10, 2019

Ah, sorry, I see this is a flow not a node, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment