Raspberry Pi CPU temp

I feel like this would be pretty easy for someone with the right scripting skills. Unfortunately, I am not that person.

With that said, I use a pi to host brewblox (as I’m sure many other people do too). I have to keep it in the garage so my tilt can be within range. It can get petty hot in the garage and it would be nice to be able to track / graph the CPU temp on the brewblox UI. Does anybody already have a widget that does this?

I got curious and googled it, and the script was indeed pretty trivial.

Add this service to your docker-compose.yml file, and values will show up in graph options:

    image: brewblox/brewblox-misc:pi-temperature
    restart: unless-stopped
    privileged: true
    - /opt/vc:/opt/vc:ro
    - LD_LIBRARY_PATH=/opt/vc/lib

@Bob, so I updated my .yml file and started the stack. It pulled and installed the temp service but I didn’t see the pi-temp option in the graph list. Looking at the logs I get this:

pi@wbwserver:~/brewblox $ docker-compose logs pi-temperature
Attaching to brewblox_pi-temperature_1
pi-temperature_1 | Traceback (most recent call last):
pi-temperature_1 | File “/app/script.py”, line 48, in
pi-temperature_1 | ‘data’: {‘temperature[degC]’: check_cpu_temperature()}
pi-temperature_1 | File “/app/script.py”, line 36, in check_cpu_temperature
pi-temperature_1 | ["/opt/vc/bin/vcgencmd", “measure_temp”]
pi-temperature_1 | File “/usr/local/lib/python3.7/subprocess.py”, line 411, in check_output
pi-temperature_1 | **kwargs).stdout
pi-temperature_1 | File “/usr/local/lib/python3.7/subprocess.py”, line 488, in run
pi-temperature_1 | with Popen(*popenargs, **kwargs) as process:
pi-temperature_1 | File “/usr/local/lib/python3.7/subprocess.py”, line 800, in init
pi-temperature_1 | restore_signals, start_new_session)
pi-temperature_1 | File “/usr/local/lib/python3.7/subprocess.py”, line 1551, in _execute_child
pi-temperature_1 | raise child_exception_type(errno_num, err_msg, err_filename)
pi-temperature_1 | FileNotFoundError: [Errno 2] No such file or directory: ‘/opt/vc/bin/vcgencmd’: ‘/opt/vc/bin/vcgencmd’

You could try the fix suggested here.

It should work if you can run /opt/vc/bin/vcgencmd measure_temp on your Pi itself.

I bought the official fan for the raspberry pi 4. It sits inside the case and pulls air through the USB ports.

Through raspi-config, you can configure which pin controls it (pin 14 default) and at which temperature it turns on (default 80 degrees Celsius). I set mine to 75C.
Any PWM fan will probably work, but this one can be easily mounted.

This means it is not running most of the times, but it does turn on when the CPU is overheating. Sounds like what you are after too. Maybe instead of tracking, you’d want to set this up. It prevents overheating, tracking not needed.

@Elco , that’s nice they made official fan for the pi4. However, I saw this case and bought a pi4 just for it… LOL

@Bob_Steers, the pi temp fix works great, thanks for the help. I do have an additional question though, the “pi-temperature” is a service right? But it doesn’t list as a service under my spark-one or tilt. Should it?

Only services with a UI component are listed there. This one just publishes raw data in a compatible format.

We may add a listing some time of services that publish data, but the intention is that anyone can write a quick-and-dirty script that publishes measurements from their own homemade sensor.