Arduino python thingspeak cant update both feilds simultaneously NEED HELP | ThingSpeak API | Forum

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
Arduino python thingspeak cant update both feilds simultaneously NEED HELP
No permission to create posts
December 2, 2018
3:14 pm
Avatar
soushah
New Member
Members
Forum Posts: 1
Member Since:
December 2, 2018
sp_UserOfflineSmall Offline

hello everyone here is a code i wrote in python i can update temperature on the website not humidity why ? cant i update both i have 10 seconds interval after one request

HERE IS CODE
import json
import urllib.request
import threading
import serial

def post_cloud_humidity():
threading.Timer(10,post_cloud_humidity).start()

my_hum,my_temp=read_data().split(',')
print(my_hum,"Humidity")

url='https://api.thingspeak.com/update?api_key=####&field1='+str(my_hum)
data=urllib.request.urlopen(url)
print(data)

post_temperature(my_temp)

def post_temperature(my_temp):
url1='https://api.thingspeak.com/update?api_key=#######&field2='+str(my_temp)
data1=urllib.request.urlopen(url1)
print(data1)
print('Uploaded Temperature ')

def read_data():
try:

arduinodata =serial.Serial('COM8',9600,timeout=0.1)
while arduinodata.inWaiting:
val=arduinodata.readline().decode('ascii')
if len(val) == 13 :
return val
except:
print('Cannot read data !')

if __name__ =='__main__':
post_cloud_humidity()

December 3, 2018
10:13 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 512
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Your second request is being rejected because it comes immediately after the first request. If you are a free user, you will need at least 15 seconds between each request. You should write your request URL to update both fields simultaneously, which counts only as one update, not two.

I did not test this code, but here is the idea:
url='https://api.thingspeak.com/update?api_key=####&field1='+str(my_temp)+'&field2='+str(my_hum)

Then wait at least 15 seconds for the next post.

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

Bbet1814On, Konstantintus, inalv69, bryancv1, priscillaql69, gay porn

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457