Thanks to the hints in this case. I run weewx on a Raspberry Pi 4 too and could not see a CPU temperature.
I modified the file cmon.py like this:
# read cpu temperature
tdir = '/sys/class/hwmon/hwmon0/device'
# rpi keeps cpu temperature in a different location
tfile = '/sys/class/thermal/thermal_zone0/temp'
if os.path.exists(tfile): # moved above 'elif os.path.exists(tdir):'
try:
s = self._readproc_line(tfile)
t_C = int(s) / 1000 # degree C
record['cpu_temp'] = t_C
except Exception as e:
logdbg("read failed for %s: %s" % (tfile, e))
elif os.path.exists(tdir): # moved behind 'if os.path.exists(tfile):'
try:
for f in os.listdir(tdir):
if f.endswith('_input'):
s = self._readproc_line(os.path.join(tdir, f))
if s and len(s):
n = f.replace('_input', '')
t_C = int(s) / 1000 # degree C
record['cpu_' + n] = t_C
except Exception as e:
logdbg("read failed for %s: %s" % (tdir, e))
The '
if os.path.exists(tfile):
' must be checked first. The complete block beginning with '
if os.path.exists(tfile):
' must be moved and if and elif must be changed. Now i can see the CPU temperature.