problem with reading data from thingspeak channel fields using Python program | ThingSpeak Projects | 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.

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
problem with reading data from thingspeak channel fields using Python program
No permission to create posts
July 30, 2019
4:31 am
New Member
Forum Posts: 4
Member Since:
July 25, 2019
sp_UserOfflineSmall Offline

hello friends,

I am working on IoT projects since recently. I am trying to read the data written to multiple fields from thingspeak channel using the following Python program

import urllib2
import json
import time

CHANNEL_ID= '835361'

while True:
TS = urllib2.urlopen("" \

response =

#a = data['created_at']
b = data['field1']
c = data['field2']

print (b)
print (c)



Even though the data is available on all the fields it displays only one field data at a time and remaining fields value as None. plz help me with this urgently.


July 30, 2019
9:36 am

Forum Posts: 342
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Why do you have a sleep for only 5 seconds? With a free account, your channel can only be updated every 15s, reading every 5s is wasteful.

A far more efficient way to read data, compared to the polling approach you have here, is to use MQTT subscribe API to subscribe to your channel. See this stackoverflow post, for example:

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
18 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:

kusmumichael, petersmith99, Rambant, blakeharriss09, optisol, Niyonzima Fils

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457