R Pi 4 Temperature and Load Log

 

I have been experimenting with PWM and the Pimorini Fan Shim.  I will make a Zip of the Python once I and fully debugged it and put here..   The result is shown in the window above.  The aim is to keep the cpu at between 61 and 69C and to exercise the fan as little as possible when the R Pi 4 is inactive.  

One issue has been choice of pwm parameters to ensure fan runs at all and smoothly another has been a good compromise between spped of responce when cpu is running on 100% and avoiding needless operation of fan when R Pi is relativly inactive.

I am fairly sure have cracked this so I will run this set upfor a week or so and publish the script after that.  However please email to if you wnat a copy before that or any info on methods used.

Ref: Support PWM to control speed? #22 on Pimorini Fan Shim Support

Implementation and CSV File

Above implemented in Python3 using a rotating buffer that is sent data on every cycle and only remembers the last 200 sets and then sends an html file here with those last 200 sets of data. Kind of useful for keeping an eye on something. The buffer can also make a csv file so that the data can be more easily analysed at a later date.   Whether the top line of the buffer is overwritten or not depends on whether the Fan is running.  So you will see that when the cpu is cool no lines are added but the top line gets overwritten every few seconds.

I use separate modules for items such as the Class that does the buffer to make them more easily re-usable.

I find this buffer to html file to website arrangement very useful when I want to remote monitor what is happening.

 

Python etc

I have started te process of building up "cleaner" code and publishing on GitHub.   The first stage of this is near complete with a set of code for the Circular Buffer this is at Github Grayerbeard text_buffer with the code sending its dummy test data to www.ftp4rpi.smalle.uk ...... test_text_buffer_log.html and log files to smalle.uk house log

Following still being developed. Here is Zip file of all Files Listed below.

Put files from zip  in a folder e.g. \home\pi\code

Add sub directories “log” and  “old” at \home\pi\code\log and \home\pi\code\old.

Then run cpu_monitor_037.py with “python3 cpu_monitor_037.py”.

You will get error messages probably because some python items are not installed so install them.

This article may help at this point:  Set Up

Remark out the FTP stuff if you don’t have a web site to send stuff to.

If you ar interested just in the PWM control of the Fan Shim then you only need to extract relavant parts from "cpu_monitor_037.py" and  "cpu_monitor_037.py".

Configuration File (note has parameters for a room Temperature Control Program Included)

config_037.cfg

Code for using Config File

config_037.py

class for cpu temp monitoring etc

cpu_037.py

cpu monitor and fan control

cpu_monitor_037.py

ftp creds file edit to suite web site

ftp_creds.csv

a text buffer program to maintain log html and csv log files for local and web site use

text_bffr_037.py

a bash script for re-starting up the python as tmux sessions if its detected they have stopped

tmux_restart.sh

a bash script for starting up the python as tmux sessions

tmux_start.sh

for stopping tmux sessions

tmux_stop.sh

.utility code to use in other python

utility_037.py

simple WD program to restart python if it stops

watch_dog_037.py

class used by WD prog

wd_037.pycpu_037.pycpu_037.py