Python script and Firefox add-on Postor HTTP post sending NULL values | ThingSpeak API | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.
Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Python script and Firefox add-on Postor HTTP post sending NULL values
No permission to create posts
September 27, 2013
12:28 pm
Avatar
manishjadhav
New Member
Members
Forum Posts: 2
Member Since:
September 27, 2013
sp_UserOfflineSmall Offline

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)

September 28, 2013
11:34 am
Avatar
manishjadhav
New Member
Members
Forum Posts: 2
Member Since:
September 27, 2013
sp_UserOfflineSmall Offline

Hi Guys,

My mistake, i hard coded the field names instead of using the generic "field1" , "field2" etc.

thanks for reading the post though.

Forum Timezone: America/New_York

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, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457