graph empty no data displayed | 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
graph empty no data displayed
No permission to create posts
June 27, 2018
4:00 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

The use of String type uses a lot of the limited Uno memory leading to instability.
This issue is now resolved to the point where I am now getting State : 200 ie successful data upload to Thingspeak.
The current solution has been to free up memory in the Uno using the F function ie Ciao.print(F("State :");
More work on the more efficient use of String type should also improve performance.

I am not getting any graphical display on ThingSpeak.
My Arduino Wifi is sending simple test data according to the Ciao WiFi Console and I get a Response State 400 ie an ERROR but why
The data is field1 =100.0
I have an API key
I am using the Ciao library which is in Arduino IDE
I am uploading every 60sec
my code
...
#define CONNECTOR ="rest"
#define SERVER_ADDR = "api.thingspeak.com"
#define APIKEY_THINGSPEAK= "xxxxx ..."
....

String uri = "/update?api_key=";
uri += APIKEY_THINGSPEAK;
uri += "&field1=";

float kWh = 100; //test data

uri += String(kWh);

Serial.print(F("thingspeak called uri="));Serial.println(uri);

Ciao.println("Send data on Thingspeak Channel");
CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty()){
Ciao.println("State: " + String(data.get(1)) );
Ciao.println("Response: " + String(data.get(2)) );
}
else {
Ciao.println("Write Error");
}

June 28, 2018
4:01 pm
Avatar
cstapels
Moderator
Members


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

If you get a successful write with a string (200), do you also see data in your channel then?
My understanding is that it stopped working when you changed to a new function. From the code above, it still appears that you are using the String class.

If you get a 400 error with the Ciao.print, but not otherwise, then I would look at the output form the Ciao.print function. Is it possible to put the output on the serial monitor?

Are you able to update you channel using a browser GET command? Replacethe api key with your channel write API key.
https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXXX&field1=1

July 1, 2018
11:19 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

My main program and the Thingspeak function code below use from Arduino IDE compiler
Sketch uses 17494 bytes (54%) of program storage space. Maximum is 32256 bytes.
Global variables use 1521 bytes (74%) of dynamic memory, leaving 527 bytes for local variables. Maximum is 2048 bytes.
The code now only uses C strings

The program runs without any apparent issues on an Uno WiFi Dev Ed displaying data on an LCD, Serial.monitor (if usb attached) and WiFi Console and State 200
It uploads one field to Thingspeak each 30 secs.
However the Ciao.write irregularly/periodically returns data.isEmpty() either for one or several writes or for 20 minutes or more! see chart attached

When isEmpty is true the URL (uri) is displayed on Serial monitor. It is always correctly constructed.
There are no Response errors 400 etc

Should I be getting the amount of upload write fails?

void uploadtothingspeak(){
char uri[45] = "/update?api_key=myapi16chars&field2=";// need to re initialse uri as strcat increments 44+\0 chars!
char buffer [5] =""; //0-1000 4 char plus \0
itoa (pulse_count1_Wh,buffer,10);//convert int to char array DEC
Serial.print(F("buffer ="));Serial.print(buffer);Serial.println(F(" Wh"));

strcat(uri, buffer); //concatenant uri and buffer (pulse_count1_Wh) 40+4+\0

//Serial.println(uri);
Ciao.println(F("Send data on ThingSpeak Channel"));
CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty())
{
String getdata_1 = data.get(1); String getdata_2 = data.get(2);
Ciao.print( F("State: "));//Ciao.println( String (data.get(1)) );
Ciao.println(getdata_1);
Ciao.print( F("Response: ")); //Ciao.println( String (data.get(2)) );
Ciao.print(getdata_2);
Ciao.print( F(" "));Ciao.print(buffer);Ciao.println( F("Wh"));

Serial.print(F("State ="));Serial.print(getdata_1);
Serial.print(F(" Response ="));Serial.println(getdata_2);
if (getdata_1 != "200") //State : 200 is correct data
{
Serial.println(uri);
}
} else {
Ciao.print(F("Write Error: uri ="));Ciao.println(uri);
Serial.print(F("Write Error uri ="));Serial.println(uri);
}
}Screen-Shot-2018-07-01-at-10.53.50-PM.pngImage Enlarger

July 2, 2018
3:05 pm
Avatar
cstapels
Moderator
Members


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

There should definitely not be any upload write fails.
I wonder if it is possible that the Ciao.write function returns empty if it fails to connect. Are you sure the device has a strong signal at all times? Can you share the library that you are using that has the Ciao function in it? It looks like the check on data being empty comes before you have even sent any data to ThingSpeak. Thus I do not think the empty result is due to formatting of the request issues, or a write fail on the ThingSpeak side.

I am going to guess that you are not waiting long enough for a server response. You could consider putting a delay in between these two lines

CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty())

or something like
CiaoData data;
while(data.isEmpty){
data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
delay(300);
}

July 3, 2018
3:52 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

Further to this issue are also a few writes sometimes to the channel but which are reported as empty which suggests a timing problem

The Arduino library containing Ciao is public domain UnoWiFiDevEd.h

meanwhile I will try your while(... suggestion.

July 3, 2018
8:42 am
Avatar
cstapels
Moderator
Members


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

Found the library, thanks. Let us know how it goes. Id suggest trying just a delay before you add the while loop.

July 5, 2018
3:11 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

Thanks for your suggestions.
I am using your while(... code suggestion and getting reliable writes to channel.
Note that Ciao function is data.isEmpty() and not data.isEmpty.

However there are occasions when there is a correct write to channel ie State = 200 but where the received Response =0. Another timing issue? But it is not a fatal issue.
Thingspeak called :buffer =313 Wh
State =200 Response =14455
Thingspeak called :buffer =316 Wh
State =200 Response =14456
Thingspeak called :buffer =320 Wh
State =200 Response =0
Thingspeak called :buffer =324 Wh
State =200 Response =14458
Thingspeak called :buffer =328 Wh
State =200 Response =14459
Thingspeak called :buffer =332 Wh
State =200 Response =0
Thingspeak called :buffer =336 Wh
State =200 Response =0
Thingspeak called :buffer =340 Wh
State =200 Response =14463

(should State not be called Status as Rest is stateless?)

Timing appears very important as additional code often/may cause a Uno restart.
I don't have a full understanding of the limited Uno memory processes which require (?) careful management.
Sketch uses 17526 bytes (54%) of program storage space. Maximum is 32256 bytes.
Global variables use 1517 bytes (74%) of dynamic memory, leaving 531 bytes for local variables. Maximum is 2048 bytes.

This uploadtothingspeak function is called about each 30secs from an Arduino main program (loop) which has a routine
attachInterrupt(pin_irq, IRQcounter, FALLING); // D2 triggered by photo cell . It is a small simple(?) routine with only a few code lines but can be called every 1 to 120+ secs .
At an interrupt the main loop execution including Ciao... calls is suspended. There is no direct code link between the interrupt routine and the upload fn.

void uploadtothingspeak(){

char uri[45] = "/update?api_key=myapikeyof16chars&field2=";// need to re initialse uri as strcat increments each time 44+\0 chars!
char buffer [5]; //0-1000 4 char plus \0 for field write to channel
buffer[0] ='\0';
char getdata_1[4]; //for State 200, 400 etc
getdata_1[0] ='\0';
char getdata_2[8]; //for Response 0-9,999,999
getdata_2[0] ='\0';
itoa (pulse_count1_Wh,buffer,10);//convert int to char array DEC
Serial.print(F("buffer ="));Serial.print(buffer);Serial.println(F(" Wh"));

strcat(uri, buffer); //concatenate uri and buffer (pulse_count1_Wh) 40+4+\0
//Serial.println(uri);
Ciao.println(F("Send data on ThingSpeak Channel"));
//CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
CiaoData data;
while(data.isEmpty())
{
data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
delay(300);
}
delay(100);
if (!data.isEmpty())
{
strcpy(getdata_1, data.get(1)); //get State and copy char[4]
//delay(100);
strcpy(getdata_2, data.get(2)); //get Response
Ciao.print( F("State: "));//Ciao.println( String (data.get(1)) );
Ciao.println(getdata_1);
Ciao.print( F("Response: ")); //Ciao.println( String (data.get(2)) );
Ciao.print(getdata_2);
Ciao.print( F(" "));Ciao.print(buffer);Ciao.println( F("Wh"));

Serial.print(F("State ="));Serial.print(getdata_1);
Serial.print(F(" Response ="));Serial.println(getdata_2);
char success[] ="200";//State : 200 is correct data
if (strcmp(getdata_1, success) != 0)
{
Serial.print(F("not State200 "));Serial.println(uri);
}
} else {
Ciao.print(F("Write Error uri ="));Ciao.println(uri);
Serial.print(F("Write Error uri ="));Serial.println(uri);
}
}

July 10, 2018
9:21 am
Avatar
cstapels
Moderator
Members


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

From the response numbers, it appears that the update is happening, even though you return 0. I think this is consistent with what you said above.

If there is an interrupt, it might be interrupting the response buffer getting filled? Or perhaps the response is still timing out before it gets the information. You have 100 ms of delay commented out in the above, that could be another part of it.

The full memory for the uno is not usually as much a problem as the amounts of memory that are allocated for a specific buffer, such as the http write buffer. Sometimes those sizes are set in the underlying library.

July 11, 2018
2:03 pm
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

State =200 Response =30621
Thingspeak write function called uploadint =30002 buffer =270 Wh
State =503 Response =

This website is under heavy load

We're sorry, too many
not State=200 /update?api_key=my key&field2=270

This message from Thingspeak might explain a few things. I have seen it partly before but you a char[18+1] (a REST GET spec) to see the complete message
I am writing to channel each 30 secs
What is the minimum grade of service for Thingspeak?

July 12, 2018
11:10 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

No channel writes for 30mins! and erratic before and the non writes occur regularly.
State(get1) = and Response(get2) = (ie no data point write reference number)

Even writes to channel once per 60secs makes no difference.

Why should I purchase an account?

I need to know the Thingspeak performance standards so that I can develop my app appropriately.

My code has always appeared to execute correctly. It is now modified a little.

July 12, 2018
11:14 am
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline
July 13, 2018
4:42 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 215
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Unfortunately, I am unable to see your screenshot. There are no known issues at this time and I confirmed that I am able to consistently store data in my ThingSpeak channel using the API.

If you are developing your own app that integrates with ThingSpeak, I would strongly urge you to read and Terms of Service and Privacy policy linked in the footer of https://thingspeak.com as they have information that may be relevant.

July 13, 2018
12:12 pm
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline

I have disabled the attachInterrupt(... routine and am writing fixed values to channel fields 1 2 & 3 yet the issue persists.
There are still times when there is no write to channel for 15-20mins nor any server error messages.
There are many times when there is no State (GET(1) or Response (GET2) FROM THE Server although the write to channel is successful.

The screen shot was taken after the events which started at 23:15 GMT +0800 and ceased at 23:30 GMT+0800 (Perth Australia) on the 13th July 2018
The Serial Monitor log below shows the start of the "no writes"
The screen shot shows the no writes and this is the relevant code

CiaoData data;
data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);
delay(300); //this delay does not seem to make any difference even if several times longer.
if (!data.isEmpty())
{
count_no_state = 0;
strcpy(getdata_1, data.get(1)); //get State and copy char[19]
Serial.print(F("State ="));Serial.print(getdata_1);
strcpy(getdata_2, data.get(2)); //get Response
Serial.print(F(" Response ="));Serial.println(getdata_2);

I have a ADSL2+ internet connection which provides about 5Mbit/s downloads. My PC is running Mac OS 10.11.6

Thingspeak write function called uploadint =30002
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =3
Thingspeak write function called uploadint =30001
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
State =200 Response =34316
Thingspeak write function called uploadint =30001
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
State =200 Response =34317
Thingspeak write function called uploadint =30002
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =1
Thingspeak write function called uploadint =30002
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =2
Thingspeak write function called uploadint =30003
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =3
Thingspeak write function called uploadint =30002
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =4
Thingspeak write function called uploadint =30002
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =5
Thingspeak write function called uploadint =30003
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =6
Thingspeak write function called uploadint =30001
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =7
Thingspeak write function called uploadint =30004
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =8
Thingspeak write function called uploadint =30003
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =9
Thingspeak write function called uploadint =30003
buffer_1 =5 buffer_2 =500 Wh buffer_3 =500 avg W
count_no_state =10

July 13, 2018
12:13 pm
Avatar
mac

Silver
Members
Forum Posts: 10
Member Since:
August 10, 2017
sp_UserOfflineSmall Offline
Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: James181
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

James181, kimberlypg2, JamesAdorb, waynesmith, paulettebw60, ashleytb4

Administrators: Hans: 387, lee: 457