You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am executing the code on my raspberry pi and i am getting this error
AttributeError: 'module' object has no attribute 'Channel'
CODE:
import thingspeak
import time
import json
channel_id = 0# PUT CHANNEL ID HERE
write_key = 'gjgjgj' # PUT YOUR WRITE KEY HERE
read_key = 'vhjjvhj' # PUT YOUR API KEY HERE, (read access only)
while True:
try:
# Get the last 2 results from field 1 of your channel
data = json.loads(channel.get_field(field=1, options={"results": 2}))
print(data['feeds'])
except:
raise
print("connection failed")
time.sleep(10)
The text was updated successfully, but these errors were encountered:
For anyone trying to troubleshoot this issue, I had the same problem. For me I had stupidly called my program thingspeak.py so the import wasn't pulling in the library at all but my program again! I renamed the program to ts.py and it worked fine.
I am executing the code on my raspberry pi and i am getting this error
AttributeError: 'module' object has no attribute 'Channel'
CODE:
import thingspeak
import time
import json
channel_id = 0# PUT CHANNEL ID HERE
write_key = 'gjgjgj' # PUT YOUR WRITE KEY HERE
read_key = 'vhjjvhj' # PUT YOUR API KEY HERE, (read access only)
channel = thingspeak.Channel(id=channel_id, api_key=read_key)
while True:
try:
# Get the last 2 results from field 1 of your channel
data = json.loads(channel.get_field(field=1, options={"results": 2}))
print(data['feeds'])
except:
raise
print("connection failed")
time.sleep(10)
The text was updated successfully, but these errors were encountered: