Read back status of ThingSpeak with Arduino | Arduino | 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
Read back status of ThingSpeak with Arduino
No permission to create posts
November 27, 2017
1:49 pm
Avatar
rico72

Silver
Members
Forum Posts: 5
Member Since:
October 23, 2017
sp_UserOfflineSmall Offline

Hi,

 

I'm using a Arduino Mega with a Ethernet Shield. The last 10 months it worked great. But this month data is missing in the graphs. I've reset-ed the Arduino and updated the ThingSpeak library to 1.2.1. and now it only sends a very limited number of data points and then stops.

Is there a method/command to put a read-back in the Arduino code to see on the Serial.plotter how ThingSpeak response to my write action?

(I have put the data I'm sending to ThingSpeak on the Serial.plotter and it seems the right values).

November 27, 2017
5:58 pm
Avatar
cstapels
Moderator
Members


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

The thingSpeak communication library function ThingSpeak.writeField will return the HTTP status 200 if the transaction was successful.  See the example for Arduino prototyping in the examples section.  You can use a separate function for writing such as the one below.  Then output the value of writeSuccess that is returned by this function to your serial monitor.  If returns 200 or 202, you are good.  

int writeTSData(long TSChannel,unsigned int TSField,float data,char* ReadAPIKey){
int writeSuccess = ThingSpeak.writeField(TSChannel, TSField, data, writeAPIKey); //write the data to the channel
return writeSuccess;
}

What library are you using for your wifi connection?

November 28, 2017
2:46 pm
Avatar
rico72

Silver
Members
Forum Posts: 5
Member Since:
October 23, 2017
sp_UserOfflineSmall Offline

Thank you for the response. I will try this.

Today just a few fields of a single channel were filled. Which is strange because I'm sending all eight fields of a single channel at once.

And to answer your question: I'm not using Wifi but just a wired connection. My Arduino is located next to my router so that was the easiest.

November 28, 2017
2:57 pm
Avatar
Vinod

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

You may also want to look at the memory occupied by your code on the Arduino. If your code, or one of the libraries you use, is leaking memory or doing dynamic memory allocation, and the code is already occupying a high percentage of available memory, the allocation of memory at runtime can overwrite the program and result in behavior like this.

One way to check this is to run your code on an Arduino compatible device that has more memory such as the MKR1000. If you see that the code behaves correctly on a device with more memory, I believe there is a high chance that your code is overwriting program memory at runtime.

November 28, 2017
4:18 pm
Avatar
rico72

Silver
Members
Forum Posts: 5
Member Since:
October 23, 2017
sp_UserOfflineSmall Offline

I just opened the log file it shows 3 things:

1) At start (first few minutes) I see on one channel WriteSuccess = -401 instead of 200

2) One channel is giving regular writeSuccess = -302 instead of 200

3) The channels that report back 200 do not always update all 8 fields. Some times half of them are updated.

 

Vinod I looked at the MKR1000 but to use that one I have to change my sensor inputs. At this moment I'm using 12 analog inputs. Sadly the MKR1000 has only 7 inputs.Is there another way to see if I have a problem with the memory? At this moment I dump the data also to the serial output just as commond before I send it to ThingSpeak, and it shows the right values on the Serial-monitor, but not in ThingSpeak.

 

I'm trying now to remember what I have changed (it worked great for almost a year)... the one thing that pops up is that I have added a serial-sensor as well. Directly connected to one of the serial inputs of the Mega. Is the ThingSpeak Arduino library using serial bus somewhere?

November 29, 2017
8:54 am
Avatar
JasonW

MathWorks
Members
Forum Posts: 28
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

That is a very odd problem you are having.  I second Vinod's idea about running out of resources.  Because the write operation occurs at the same time for all the fields, it is puzzling how some fields are getting updated and others aren't.  A corrupted string could be the reason.

November 29, 2017
9:45 am
Avatar
Vinod

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

rico72 said

I'm trying now to remember what I have changed (it worked great for almost a year)... the one thing that pops up is that I have added a serial-sensor as well. Directly connected to one of the serial inputs of the Mega. Is the ThingSpeak Arduino library using serial bus somewhere?  

Can you try reverting to your old Arduino sketch (without changing any hardware connections) and seeing if the problem still occurs. That will help isolate if it is a software issue. Next step would be then to go to a setup without the new sensor and seeing if that configuration of old hardware + old software gets you the correct behavior. The only reason I suggest this is to rule out hardware interrupts from the newly added sensor messing with the data transmission to ThingSpeak.

December 2, 2017
9:01 am
Avatar
rico72

Silver
Members
Forum Posts: 5
Member Since:
October 23, 2017
sp_UserOfflineSmall Offline

So the first results seems to be indeed pointing to a memory problem.

During one day I have left out the serial sensor. And it reported to ThingSpeak without any problems.

And the second day I have connected only the serial sensor and I logged also on Thingspeak the free Ram available in the Arduino memory. And that last logging was interesting. Over roughly one hour the free RAM in the Arduino went down from 3500 bytes to 200 bytes. And at that moment the sensor data was no longer visible on ThingSpeak (only empty fields were available in the downloaded CSV file).

 

So I have to check the library of the serial sensor to see what happens there.

 

Thank you very much for your support.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: Hans, agrisensezm
37 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:

Archieter, JamesExedo, IrbosHich, brodi, kasko, franklin castro

Administrators: Hans: 387, lee: 457