OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › Interval Website & CPU Temp
A comment on my pictures/post of my installation from mrburns42 regarding temperature extremes prompted me to add some code to the interval program home page to display the CPU temp as a just-in-case/visibility measure. This is the first time I’ve ever touched Python so forgive any amateurishness and please post any improvements.
Added to ospi.py under Function Definitions:
def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'Cn",""))
Added to ospi.py under Class definitions, home, Get(self):
homepg += 'n'
Modified home.js:
w("Device Time: "+datestr(devt*1000)+"
");
w("CPU Temp: "+(cputemp)+"
");
This displays the temp in Fahrenheit (you can see the calculation above converting from Celcius). A potential expansion/improvement would be to add a setting in options F or C and then of course, display the temp value based on that setting.
This is a great addition! I hope they merge it. I’d be interested in some logging as well so we can get a better picture of temperature and trends throughout the day/week.
If you are interested in graphing of the CPU temp I highly suggest you explore options such as Cacti. They are wonderful with dealing with this information. You can install Cacti right on the Raspberry Pi or you can have another server do Cacti and use SNMP to poll the RPi.
By the way, the solution you came up with is awesome!
I am using salbahra’s awesome web interface, so since my rPi has php on it I made some additions to his code to allow me to have custom pages….one of them being a stats page. Check out my screenshot of the stats –
OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › Interval Website & CPU Temp