I want to read out the system temperature of my second Pi without install Domoticz on it.
Can anyone tell me if this is possible ?
And if the answer is yes, how

Moderator: leecollings
Code: Select all
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import os
class MainHandler(tornado.web.RequestHandler):
def getCPUtemperature( self ):
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'C\n",""))
def get(self):
self.write( "%s" % ( self.getCPUtemperature() ) )
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Code: Select all
#!/bin/bash
#replace with your Device IDX you found in the previous step.
SecondPi=44
#Internal temperature SecondPI
TEMP=$(curl http://<name or IP of your second PI:8888)
curl --connect-timeout 60 "http://localhost:8080/json.htm?type=command¶m=udevice&idx=$PiZolder&nvalue=0&svalue=$TEMP"
Code: Select all
chmod +x /home/pi/domoticz/scripts/get-pi-temp.sh
Code: Select all
*/5 * * * * /home/pi/domoticz/scripts/get-pi-temp.sh >/dev/null 2>&1
I've tried to get it to work in many ways:Mozart wrote: To autostart this script at every boot you should create a script in /etc/init.d/ to make that work. There are examples on the internet how to do that, if you cannot get it working I will paste my /etc/init.d/ script for this.
Oops, missed this. Do you still need the script?erigoth wrote:Hello Mozart,
you wrote:I've tried to get it to work in many ways:Mozart wrote: To autostart this script at every boot you should create a script in /etc/init.d/ to make that work. There are examples on the internet how to do that, if you cannot get it working I will paste my /etc/init.d/ script for this.
1. @reboot in crontab
2. added bashscript to /etc/init.d
3. created a service for the bash script
the script starts, it just shows a blank page on the 8888 port...
when I kill the script and start it manually it works perfect but it wont start normally on reboot.
could you please share your script with me?
Hope you can help me.
greets,
Erigoth
Code: Select all
#!/bin/bash
Current_Temp=$(/opt/vc/bin/vcgencmd measure_temp | cut -c6-9)
IDX=$1
echo $Current_Temp
curl -s "http://domoticz.ip.address:8080/json.htm?type=command¶m=udevice&idx=$(echo $IDX)&nvalue=0&svalue=$(echo $Current_Temp)"
Users browsing this forum: No registered users and 1 guest