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

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

June 27, 2014
8:16 pm
Avatar
lee

Admin
Forum Posts: 457
Member Since:
March 14, 2011
sp_UserOfflineSmall Offline

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

June 30, 2014
9:19 am
Avatar
ccrumpacker
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2014
sp_UserOfflineSmall Offline

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

June 30, 2014
3:23 pm
Avatar
ccrumpacker
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2014
sp_UserOfflineSmall Offline

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: dennis55
20 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:

josephrj11, dennis55, jillhp4, tabathawg69, MarinaMa, Susandom

Administrators: Hans: 387, lee: 457