KiZD

Feed Raspberry Pi temp

Aug 30th, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/python
  2. import subprocess
  3. import time
  4. import os
  5. import urllib2
  6.  
  7. serverIP = "your_server_IP"
  8. nodeID = "node_id"
  9. apikeyRW = "your_apikey_RW"
  10. interval = interval_in_secs
  11.  
  12. while True:
  13. currentTemp = subprocess.check_output(["/opt/vc/bin/vcgencmd","measure_temp"])
  14. currentTemp = float(currentTemp.split("=")[1][:-3])
  15. urllib2.urlopen("http://" + serverIP + "/emoncms/input/post.json?node=" + nodeID + "&csv=" + str(currentTemp) + "&apikey=" + apikeyRW)
  16.  
  17. time.sleep(interval)
Advertisement
Add Comment
Please, Sign In to add comment