I have this implemented. Here is what I did (feel free to optimize this

):
1. Install python on the second pi.
2. create a file e.g. temp.py with the following content:
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()
The last line of the code shows the port number that is used. Start this code with:
python temp.py
Now use a browser to connect to the ip or name of your second pi on port 8.8.8.8, e.g.:
http://192.168.254.9:8888/
You should get a page with only the temperature, if this is showing the temp you have to solve this first.
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.
Next, add a dummy temperature device in Domoticz. Go to the list of devices and make an note of the device number, we will need this later.
Past the following code to a script in e.g. /home/pi/domoticz/scripts (PI with Domoticz) and name it something like get-pi-temp.sh:
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"
Make sure that you get the details right.
Make the script executable with:
Code: Select all
chmod +x /home/pi/domoticz/scripts/get-pi-temp.sh
I use Cron to run this script every 5 minutes. Update your local cron on the first PI with these commands:
type: crontab -e (as user pi)
add this to the end of the file:
Code: Select all
*/5 * * * * /home/pi/domoticz/scripts/get-pi-temp.sh >/dev/null 2>&1
Now you should get a new temperature reading every 5 minutes in your Domoticz. Works for me, I have do this to retrieve the temp of 2 PI's that do not have Domoticz. On 1 PI I also connected 3 ds18b20 probes connected to the GPIO of that PI and pass them in a similar way to Domoticz.
Good luck!