Updating multiple channels from html | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
Updating multiple channels from html
Avatar
Stillub
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
December 17, 2017 - 1:44 pm
sp_Permalink sp_Print

I posted this question under "Arduino" and probably should of placed it here... my bad...

Original post viewed here: http://community.thingspeak.com/forum/arduino/thingspeak-multiple-field-updates-from-html/

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
2
January 2, 2018 - 3:03 pm
sp_Permalink sp_Print sp_EditHistory

Stillub said

I posted this question under "Arduino" and probably should of placed it here... my bad...

Original post viewed here: http://community.thingspeak.com/forum/arduino/thingspeak-multiple-field-updates-from-html/  

I'm not sure if it's my URL or something going on with the ThingSpeak.com servers but I'm not having any success getting consistency.

It's quite possible they are working on the servers or there are a number of datastream intensive opertions going on that are slowing down the ThingSpeak server response times.

All speculation.  But I cannot figure out why my data URLS work fine one moment then not at all the next, and the intervals are all over the place as far as time between data points....like anywhere between 1 minute and several hours even though I am sending update feeds every 60 seconds.   I have a gut feeling something's going on with the ThingSpeak server(s) at this time.    Again, could be totally wrong...just a guess based on observation of data.

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
3
January 2, 2018 - 4:28 pm
sp_Permalink sp_Print

The servers seem pretty steady on channels where I have time controls set up. I see a fluctuation of about 15 seconds for these.  There is less variation in the channels I have that are using devices to write, except where they collide with other writes. 

If you have multiple writes to your channels, they might be competing, which will make the posting look intermittent.  Check your time controls and analysis scripts.  You licence type will tell you how often you can update. 

If you are using the REST interface from an HTML script, reliability may depend on your internet connection. Are you posting from a location with a reliable internet connection?  

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
4
January 3, 2018 - 2:23 pm
sp_Permalink sp_Print

cstapels said
  Check your time controls and analysis scripts.

What do you mean by this?

Where are these and are they pertinent to GET URLs suppling datapoints via an HTML feed (no Json, XML)

Avatar
MURLIDHAR ROY
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
5
January 3, 2018 - 3:35 pm
sp_Permalink sp_Print

I am trying to send two data values to thingspeak value. Please tell me the command through which I can send the two sensor data. The basic code is given below.

 

#include <SoftwareSerial.h>
/* Create object named SIM900 of the class SoftwareSerial */
SoftwareSerial SIM900(8, 7);
void setup()
{
SIM900.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
}

void loop() {
Serial.println("HTTP post method :");
Serial.print("AT\
\
");
SIM900.println("AT"); /* Check Communication */
delay(500);
ShowSerialData(); /* Print response on the serial monitor */
delay(500);
/* Configure bearer profile 1 */
Serial.print("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"\
\
");
SIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""); /* Connection type GPRS */
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"\
\
");
SIM900.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\""); /* APN of the provider */
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+SAPBR=1,1\
\
");
SIM900.println("AT+SAPBR=1,1"); /* Open GPRS context */
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+SAPBR=2,1\
\
");
SIM900.println("AT+SAPBR=2,1"); /* Query the GPRS context */
delay(500);
ShowSerialData();
delay(2000);
Serial.print("AT+HTTPINIT\
\
");
SIM900.println("AT+HTTPINIT"); /* Initialize HTTP service */
delay(2000);
ShowSerialData();
delay(500);
Serial.print("AT+HTTPPARA=\"CID\",1\
\
");
SIM900.println("AT+HTTPPARA=\"CID\",1"); /* Set parameters for HTTP session */
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\"\
\
");
SIM900.println("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\""); /* Set parameters for HTTP session */
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+HTTPDATA=33,10000\
\
");
SIM900.println("AT+HTTPDATA=33,10000"); /* POST data of size 33 Bytes with maximum latency time of 10seconds for inputting the data*/
delay(200);
ShowSerialData();
delay(200);
Serial.print("api_key=8MMR5DD7QC42NAUJ&field1=2\
\
"); /* Data to be sent */
SIM900.println("api_key=8MMR5DD7QC42NAUJ&field1=2");
delay(500);
ShowSerialData();
delay(500);
Serial.print("AT+HTTPACTION=1\
\
");
SIM900.println("AT+HTTPACTION=1"); /* Start POST session */
delay(1000);
ShowSerialData();
delay(2000);
Serial.print("AT+HTTPTERM\
\
");
SIM900.println("AT+HTTPTERM"); /* Terminate HTTP service */
delay(2000);
ShowSerialData();
delay(500);
Serial.print("AT+SAPBR=0,1\
\
");
SIM900.println("AT+SAPBR=0,1"); /* Close GPRS context */
delay(500);
ShowSerialData();
delay(500);
}

void ShowSerialData()
{
while(SIM900.available()!=0) /* If data is available on serial port */
Serial.write(char (SIM900.read())); /* Print character received on to the serial monitor */
}

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
6
January 5, 2018 - 1:50 pm
sp_Permalink sp_Print

Piez,

You can perform channel updates in MATLAB analysis scripts. (also in visualizations)  If you were using a script to update the channel, I would check if the script is doing multiple writes within the update limit.  Time controls are used to regularly schedule running of code.  They  can be used to trigger analysis scripts, which could also cause overlapping writes to channels. 

Writing simultaneously to multiple channels can also violate the update rate limitation and lead to missed data.

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
7
January 5, 2018 - 2:05 pm
sp_Permalink sp_Print

MURLIDHAR ROY,

See REST API documentation for the appropriate syntax. 

Does the code you provided work to update a single field?  If it works as is for one field, add &field2=... to get it to work for 2 fields.    If the code doesn't work as is, you may need a "?" before the api key.

If you are using a GET operation

https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=0

Then continue to append fields with the "&".

https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=0&field2=56&field3=123

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

winnieeq69

AutoCheernpen

Bostermet

engladNed

iivenul

olewaeayafaku

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee