Measuring the processor temperature

  • Thread starter Thread starter Litserv
  • Start date Start date
  • Tagged users Tagged users None

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
64
Reaction score
55
What state or country do you live in
Other International
Rating - 0%
0   0   0
My Raspberry Pi is in a case with a lot of peripheral equipment; therefore the temperature rises more than usual, although not critically. From time to time I checked the temperature of the processor via the console using SSH ("vcgencmd measure_temp").

In the long run, this was too annoying for me. So I wrote a Python script that reads the processor temperature and writes it to a text file.
I read this text file with Reef-Pi via a driver 'file-analog', display it on the desktop and control a small fan for cooling. For the script, I adapted another script for reading out sensors.

Here is the script for anyone who is interested:

Python:
import os

#Create directories and define output files
rootDir = "/dev/shm"
WorkDrir = "/ReeFHardwareComs/temp-proc"
path = rootDir + WorkDrir
access_rights = 0o777
F_TP_name = "temp-proc"

if not os.path.isdir(path):
        try:
                os.makedirs(path, access_rights)
        except OSError:
                print ("Creation of the directory %s failed" % path)
        else:
                print ("Successfully created the directory %s " % path)

# Temperatur des Prozessors auslesen und auf Konsole ausgeben
temp = os.popen("vcgencmd measure_temp").readline()
temp = temp.replace("temp=", "")
temp = temp.replace("'C\n", "")
print(temp)

# Ausgabe in ein File
f = open(path + '/' + F_TP_name, 'w')
f.write(temp)
f.close()
os.chmod(path + '/' + F_TP_name, access_rights)

# File auslesen
f = open(path + '/' + F_TP_name, 'r')
daten = f.read()
print(daten)
f.close()


Suggestions for improvement are welcome.
 
I think for some users it might be very useful to have a full install:
Basically something takes copies the files and starts the service for the people with less IT-affinity.

You might try adapting the install script that @robsworld78 made for his flowmeter program, I used that as a basis for my air_quality monitor program and service for the SCD30
 
I think for some users it might be very useful to have a full install:
Basically something takes copies the files and starts the service for the people with less IT-affinity.

You might try adapting the install script that @robsworld78 made for his flowmeter program, I used that as a basis for my air_quality monitor program and service for the SCD30

Good idea, thanks for the hint. I'll see whether I can adopt the script or not. For the time being, I wait for a solution of the localization issue in Reef-Pi... ;-)
 

TOP 10 Trending Threads

IF YOU HAD TO OPERATE EVERYTHING ELSE MANUALLY, WHICH AUTOMATED SYSTEM WOULD YOU KEEP?

  • Auto top-off

    Votes: 41 58.6%
  • Automated dosing

    Votes: 5 7.1%
  • Mechanical filtration / roller filter

    Votes: 4 5.7%
  • Automated water testing

    Votes: 3 4.3%
  • Automatic feeding

    Votes: 0 0.0%
  • Lighting schedule

    Votes: 10 14.3%
  • Controller and remote monitoring

    Votes: 3 4.3%
  • Leak detection and emergency shutoff

    Votes: 1 1.4%
  • Automatic water changes

    Votes: 2 2.9%
  • None. I prefer to operate everything manually

    Votes: 0 0.0%
  • Something else (explain in the comments)

    Votes: 1 1.4%
Free Phyto Promo
Spend $39+ → free 16oz Phyto · Use code FREEPHYTO at checkout · $16.99 value · Densest 6-species blend · Free shipping on every order · 100% live arrival guaranteed Spend $39+ → free 16oz Phyto · Use code FREEPHYTO at checkout · $16.99 value · Densest 6-species blend · Free shipping on every order · 100% live arrival guaranteed
Shop Now Code: FREEPHYTO
Back
Top
Home
Post thread…
Market
What's new