I don't understand how to change the rate at which data points are added | 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
I don't understand how to change the rate at which data points are added
Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
1
January 1, 2018 - 7:07 pm
sp_Permalink sp_Print

After an extensive Google search and on this forum, I haven't found anything that gives me an idea of how to change the number of data points over a given time period.   Right now I am getting a data point about every 8 minutes, although inexplicably, it sometimes changes to as many as 1 data point per minute.

I have absolutely no clue why it changes or how to try to set it to the rate I want which is 1 data point per minute.

Can someone please point me to meaningful documentation on this or explain the steps?

 

Thanks!

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
2
January 1, 2018 - 9:24 pm
sp_Permalink sp_Print

What is updating your channel?  Are you using a device or a ThingSpeak app such as MATLAB analysis?

Sensor devices can update a channel with HTTP commands or with MQTT protocol. MATLAB can update a channel from the desktop environment.  MATLAB analysis can write to a channel in a similar way, generally with thingSpeakRead command.  Then you can schedule a time control to complete that action at regular intervals.

  Is your question related to how many points are displayed in a plot or how many points you have in your channel? 

If you are interested in seeing how a channel updates, try the Getting Started tutorial. It will take you through the whole process step by step.

If you are looking for options on the plots, see the create a chart page.  The parameters listed there are for HTTP commands, but they match the controls for ThingSpeak plots when you press the pencil icon.

 

Let us know if that helps.

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
3
January 1, 2018 - 9:35 pm
sp_Permalink sp_Print

cstapels said
What is updating your channel?  Are you using a device or a ThingSpeak app such as MATLAB analysis?
Sensor devices can update a channel with HTTP commands or with MQTT protocol. MATLAB can update a channel from the desktop environment.  MATLAB analysis can write to a channel in a similar way, generally with thingSpeakRead command.  Then you can schedule a time control to complete that action at regular intervals.

  Is your question related to how many points are displayed in a plot or how many points you have in your channel? 

If you are interested in seeing how a channel updates, try the Getting Started tutorial. It will take you through the whole process step by step.

If you are looking for options on the plots, see the create a chart page.  The parameters listed there are for HTTP commands, but they match the controls for ThingSpeak plots when you press the pencil icon.
  Let us know if that helps.  

Hello and thank you for the reply.

I am using a sensor to update my channel via an HTTP Get URL.

Does that mean that my local program's delay settings govern how many data points per hour for example are made?   For example, the Channel willl plot as many points as I send via URL (up to the limit of one data point every 15 seconds?)

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
4
January 10, 2018 - 10:13 am
sp_Permalink sp_Print

Still haven't figured out how to change the update interval 🙁

I guess the basic question I need answered is this......

Is the interval controlled from MY SIDE (my arduino sketch for example) or from the THINGSPEAK side in the channel settings?

Avatar
Vinod

Forum Posts: 186
sp_UserOfflineSmall Offline
5
January 10, 2018 - 10:23 am
sp_Permalink sp_Print

If you have a free account, you can send data to a ThingSpeak channel up to once every 15 seconds. If you try sending it faster, the request will be rejected. You can send it slower, if you wish, and that would be controlled by your device.

If you have a paid license, you can update a channel as fast as once per second enforced on the server side. Again, if you wish to go slower, that would be on your device end.

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
6
January 10, 2018 - 11:08 am
sp_Permalink sp_Print

Vinod said

If you have a free account, you can send data to a ThingSpeak channel up to once every 15 seconds. If you try sending it faster, the request will be rejected. You can send it slower, if you wish, and that would be controlled by your device.

If you have a paid license, you can update a channel as fast as once per second enforced on the server side. Again, if you wish to go slower, that would be on your device end.  

ok,

I think you're saying it is controlled from MY side and not by Thingspeak other than free = greater than or equal to one update every 15 seconds and paid you can update as often as every second.

So this is to conclude that there is NO CONTROL over the data interval or how it's displayed (other than stated above) while at the ThingSpak website.

Thanks

Avatar
Vinod

Forum Posts: 186
sp_UserOfflineSmall Offline
7
January 10, 2018 - 11:12 am
sp_Permalink sp_Print

Are you asking about controlling the rate of storing data to ThingSpeak, or the rate at which the data is refreshed in the charts?

My comments above relate to how fast you can send data to ThingSpeak.

If your question is about how fast a chart is refreshed, for a free license the chart is updated every 15 seconds. For a paid license, the charts can be configured to update once a second or at a lower rate.

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
8
January 10, 2018 - 7:27 pm
sp_Permalink sp_Print

Vinod said

Are you asking about controlling the rate of storing data to ThingSpeak, or the rate at which the data is refreshed in the charts?

My comments above relate to how fast you can send data to ThingSpeak.

If your question is about how fast a chart is refreshed, for a free license the chart is updated every 15 seconds. For a paid license, the charts can be configured to update once a second or at a lower rate.  

You know, those two things both could probably affect the apparent rate.

But I'm referring to the time between each data point.  Not the refresh rate on ThingSpeak

I had set my data rate to 1 data point every 60 seconds, but they were all over the place....1 minute, 2 minutes, 3 minutes all the way up to hours between data points....this being after they6 were all plotted.

Avatar
Vinod

Forum Posts: 186
sp_UserOfflineSmall Offline
9
January 10, 2018 - 8:32 pm
sp_Permalink sp_Print

Piez said

I had set my data rate to 1 data point every 60 seconds, but they were all over the place....1 minute, 2 minutes, 3 minutes all the way up to hours between data points....this being after they6 were all plotted.  

I think the quickest way to understand what is going on is to share your code (redact the API keys, please) that is posting data to ThingSpeak.

I suspect the way the data is packaged before being sent to ThingSpeak has some subtle bug. If my hunch is right, your device is providing the timestamp of the data (instead of ThingSpeak recording when it received the data and using that for plotting) and the bug is in this section of the code on your device.

Avatar
Piez

Silver
Forum Posts: 15
sp_UserOfflineSmall Offline
10
January 12, 2018 - 7:28 pm
sp_Permalink sp_Print

Hello Vinod,

Thanks for your help and looking at this.

Here's the entire sketch.   If you see anything I would really appreciate your advice 🙂

/////////////// BEGIN CODE ////////////////

#include <DHT.h>
#include <DHT_U.h>

//#include"dht.h" // Including library for dht
#include <DHT.h>;
#include<LiquidCrystal.h>;
LiquidCrystal lcd(14,15,16,17,18,19);
#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3);

//#define dht_dpin 12
#define DHTPIN 12
#define heart 13
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);

char *api_key="ABCDEFGHIJK123456"; // Enter your Write API key from ThingSpeak
static char postUrl[150];
float humi;
float tem;
//int tem,humi;
float temConv;
float humiConv;
void httpGet(String ip, String path, int port=80);

void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.print(" Humidity ");
lcd.setCursor(0,1);
lcd.print(" Measurement ");
delay(2000);
lcd.clear();
lcd.print("Circuit Digest ");
lcd.setCursor(0,1);
lcd.print("Welcomes You");
delay(2000);
Serial1.begin(115200);
Serial.begin(115200);
lcd.clear();
lcd.print("WIFI Connecting");
lcd.setCursor(0,1);
lcd.print("Please wait....");
Serial.println("Connecting Wifi....");

 

connect_wifi("AT",1000);
connect_wifi("AT+CWMODE=1",1000);
connect_wifi("AT+CIPSTA=\"192.168.003.57\",\"192.168.003.001\",\"255.255.255.000\"",10000);
connect_wifi("AT+CWQAP",1000);
connect_wifi("AT+RST",5000);
connect_wifi("AT+CWJAP=\"MyWirelessSSID\",\"Password\"",10000);

Serial.println("Wifi Connected");
lcd.clear();
lcd.print("WIFI Connected.");
pinMode(heart, OUTPUT);
delay(2000);
t.oscillate(heart, 1000, LOW);
t.every(20000, send2server);
}

void loop()
{

humi = dht.readHumidity();
tem= dht.readTemperature();
// DHT.read11(DHTPIN);
lcd.setCursor(0,0);
lcd.print("Humidity: ");
//humi=DHT.humidity;
lcd.print(humi); // printing Humidity on LCD
lcd.print(" % ");
lcd.setCursor(0,1);
lcd.print("Temperature:");
// tem=DHT.temperature;
lcd.print(tem); // Printing temperature on LCD
lcd.write(1);
lcd.print("C ");
delay(2000);
t.update();
}

void send2server()
{
char tempStr[8];
char humidStr[8];
temConv=(tem*1.8)+32;
//temConv=tem;
// temConv=temConv-1.4; //Correction for DHT11-1
temConv=temConv-1.4; //Correction for DHT22-1

// Humidity Calibrations
if ((humi <= 47) && (humi > 40)) humiConv=humi+1;
if ((humi <= 40) && (humi > 39)) humiConv=humi+2;
if ((humi <= 39) && (humi > 36)) humiConv=humi+3;
if ((humi <= 36) && (humi > 34)) humiConv=humi+4;
if (humi <= 34) humiConv=humi+5;

dtostrf(temConv, 5, 3, tempStr);
dtostrf(humiConv, 5, 3, humidStr);
sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
httpGet("api.thingspeak.com", postUrl, 80);
}

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

void httpGet(String ip, String path, int port)
{
int resp;
String atHttpGetCmd = "GET /"+path+" HTTP/1.0

";
//String atHttpGetCmd = "GET /"+path+"

";
//AT+CIPSTART="TCP","192.168.20.200",80
String atTcpPortConnectCmd = "AT+CIPSTART=\"TCP\",\""+ip+"\","+port+"";
connect_wifi(atTcpPortConnectCmd,1000);
int len = atHttpGetCmd.length();
String atSendCmd = "AT+CIPSEND=";
atSendCmd+=len;
connect_wifi(atSendCmd,1000);
connect_wifi(atHttpGetCmd,1000);
}

void connect_wifi(String cmd, int t)
{
int temp=0,i=0;
while(1)
{
lcd.clear();
lcd.print(cmd);
Serial.println(cmd);
Serial1.println(cmd);
while(Serial1.available())
{
if(Serial1.find("OK"))

i=8;
}
delay(t);
if(i>5)
break;
i++;
}
if(i==8)
{
Serial.println("OK");
lcd.setCursor(0,1);
lcd.print("OK");
}
else
{
Serial.println("Error");
lcd.setCursor(0,1);
lcd.print("Error");
}
}

Avatar
Vinod

Forum Posts: 186
sp_UserOfflineSmall Offline
11
January 15, 2018 - 1:49 pm
sp_Permalink sp_Print

I think there is a lot going on in this sketch. I would try and simplify the sketch by removing the non-essential aspects and see if you notice the same behavior.

Specifically, please remove the LCD related functionality. Also, you are using a delay() function in your sketch in addition to software serial. Because delay() is a blocking function, you may see some non-intuitive effects with soft-serial and your sketch. Take a look at this and there may be tips in there that will improve the reliability of your sketch:

https://randomnerdtutorials.com/why-you-shouldnt-always-use-the-arduino-delay-function/

Forum Timezone: America/New_York

Most Users Ever Online: 114

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