12:28 pm

September 27, 2013

I have created a new channel with only one field and have tried to post the field data using both python script from a raspberry PI and a direct post using the firefox addon POSTOR. the data was posted as NULL when i checked the JSON. What am i doing wrong? Please see my script also below.
# Return CPU temperature as a character string
#!/usr/bin/python
import os
import httplib, urllib
import time
def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'C\n",""))
def postStats():
cpuTemp1 = getCPUtemperature();
print "CPU Temp: ", cpuTemp1
params = urllib.urlencode({'cputmp': cpuTemp1,'key':'XXXXXXXXXXXXX'})
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
conn.close()
if __name__ == "__main__":
while True:
postStats()
time.sleep(30)
Most Users Ever Online: 166
Currently Online:
36 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457