Failing to update a channel from my Spark Core via HTTP | Particle / Spark | 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
Failing to update a channel from my Spark Core via HTTP
Avatar
ccrumpacker
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
1
June 27, 2014 - 3:57 pm
sp_Permalink sp_Print

I began looking at the Arduino with Ethernet shield (http://community.thingspeak.com/tutorials/arduino/using-an-arduino-ethernet-shield-to-update-a-thingspeak-channel/) and adapted that to work with the Spark Core. Everything looks to be in order and I connect to the api address but fail to update it each time. Since code pastes seem to look like Poo on this forum I posted my code here:
http://community.thingspeak.com/tutorials/arduino/using-an-arduino-ethernet-shield-to-update-a-thingspeak-channel/

and the Serial output of the debugging is below, you can see I get a -1 back after sending what I think is a properly formatted update. Any thoughts would be appreciated. Once I get this running I plan to write up a tutorial on this.

=== Starting ===
-Network SSID: redacted
-Local IP: 172.17.2.271
-Link to view streamed data: https://thingspeak.com/channels/14187
.Connected to Spark Cloud
...Attempting to read the DHT22 sensor..Acquired
.DHT22 read successfully
-Temp oF: 71.06
-Humidity: 41.60
-Data String: field1=71.06&field2=41.60
-Data String Length: 25
...Attempting to update Thingspeak
...Connection succesful, updating datastreams
.Failure from Thingspeak
-Client Read: -1

Avatar
lee

Forum Posts: 457
sp_UserOfflineSmall Offline
2
June 27, 2014 - 8:16 pm
sp_Permalink sp_Print

Hi,

Did you post the wrong link for your code?

Also, on the line that says:
client.print(tsData);
Other people have had more success by changing it to:
client.println(tsData);

lee

Avatar
ccrumpacker
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
3
June 30, 2014 - 9:19 am
sp_Permalink sp_Print

I sure did, silly copy and paste. Here is the code as it stands.

https://github.com/rainierez/SparkCore/blob/master/Spark2Thingspeak.ino

I'll try changing it to client.println(tsData); and report back later. I have a ton of meetings this morning. :/ thanks for the input though

Avatar
ccrumpacker
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
4
June 30, 2014 - 3:23 pm
sp_Permalink sp_Print sp_EditHistory

That may have helped, but what is 100% necessary is to put a slight delay after the client.print statements before you proceed to the client.close. I found a delay of 100 usually works and knocks out the sporadic.

client.print("POST /update HTTP/1.1
");
client.print("Host: api.thingspeak.com
");
client.print("Connection: close
");
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"
");
client.print("Content-Type: application/x-www-form-urlencoded
");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("
");

client.println(tsData);

delay(100);

Forum Timezone: America/New_York

Most Users Ever Online: 114

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

epicpaymentsny

DanielBobby

mercedeszw18

ujuxoketate

olihfez

winnieeq69

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee