Page 1 of 1

Get the temputre of a raspberry pi and send a ifft trigger

Posted: Wed Nov 18, 2015 9:51 am
by benji_19994
a simple python script to send the raspberrys pi CPU temperature to ifft
Code: Select all
import os
import json
import requests
import time
def getCPUtemperature():

        res = os.popen('vcgencmd measure_temp').readline()
        return(res.replace("temp=","").replace("'C\n",""))

def GetCpuFrequency():
        res = os.popen('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_fr$
        return res

def SendNotificationToDevice():
        temp = float(getCPUtemperature())
        url     = 'https://maker.ifttt.com/trigger/Comp_data/with/key/cMCErA1-M$
        payload = {'value1' : temp }
        headers = {}
        res = requests.post(url, data=payload, headers=headers)
temp = float(getCPUtemperature())
CyrrentCPUFreq = GetCpuFrequency()

print('Current CPU Temp');
print(temp);