Ok, I am not familiar with Python at all. I managed to work through the instructions above and make the changes to my weewx.conf file and then create cputemp.py in my /usr/share/weewx/user directory. This eliminated the errors in the my syslog. I am not seeing the cpu temp on the charts. How would I look up the variables in python to see if they are registering at all.
On Tuesday, June 9, 2020 at 9:35:28 PM UTC-5 [email protected] wrote: > Mike, I have updated my weewx.conf file. Could you offer a little more > clarification on the new file? To confirm this is the /usr/bin directory? > Does the filename matter? > > -Jonathan > > > On Friday, May 8, 2020 at 3:41:39 AM UTC-5, Mike Revitt wrote: >> >> I have this working on my Rasberry pi at >> https://weather.cougar.eu.com/telemetry.html and this is how I did it >> >> in weewx.conf >> >> In >> [Engine] >> [[Services]] >> >> set >> >> data_services = user.cputemp.AddCpuTemp >> >> Then add this Python program to the bin user directory where your >> Rasberry Pi code is. >> >> # Copyright (c) 2009-2020 Mike Revitt >> >> # See the file LICENSE.txt for your rights. >> >> """Gets the CPU temperature on a Rasberry Pi""" >> >> >> >> *import* weewx >> >> *from* weewx.engine *import* StdService >> >> *from* gpiozero *import* CPUTemperature >> >> >> >> *class* AddCpuTemp(StdService): >> >> >> >> *def* __init__(self, engine, config_dict): >> >> >> >> # Initialize my superclass first: >> >> super(AddCpuTemp, self).__init__(engine, config_dict) >> >> >> >> # Bind to any new archive record events: >> >> self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record) >> >> >> >> *def* new_archive_record(self, event): >> >> >> >> cpu = CPUTemperature() >> >> >> >> *if* event.record['usUnits'] == weewx.US: >> >> event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32 >> >> *else*: >> >> event.record['extraTemp1'] = cpu.temperature >> >> >> >> >> >> >> >> >> On Thursday, May 7, 2020 at 3:48:53 PM UTC+1, Luc Heijst wrote: >>> >>> Recently I downloaded the latest version of weewx-cmon (v 0.20) which >>> was converted to use with python3. >>> This version, and also elder versions of cmon.py, did not read the >>> cpu-temp of my Raspberri PI systems (models 1B, 2B, 3B and 3B+). >>> >>> On my raspberry PI the following statement is true: >>> *os.path.exists(tdir)*, still a cpu-temp could not be found in this >>> section >>> The *elif os.path.exists(tfile):* statement caused the bottem section >>> to be skipped and that is the section that reads the RPI cpu-temp. >>> >>> See the modifications in yellow which fixed this problem. >>> >>> Luc >>> >>> --- snipped of cmon.py --- >>> # read cpu temperature >>> tdir = '/sys/class/hwmon/hwmon0/device' >>> # rpi keeps cpu temperature in a different location >>> tfile = '/sys/class/thermal/thermal_zone0/temp' >>> *temp_found = False* >>> if os.path.exists(tdir): >>> 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): >>> *temp_found = True* >>> 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)) >>> ### elif os.path.exists(tfile): ### original statement >>> if* not temp_found and *os.path.exists(tfile): >>> 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)) >>> >>> ----------- >>> >>> >> You can then access the Rasberry Pi CPU temperature as the variable >> extraTemp1 from within your HTML files >> > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/849af89d-2e65-469c-a54c-d9574a0781a0n%40googlegroups.com.
