Go Down

Topic: Mega with wiznet shield (wire hack)+thingspeak+sd problem (Read 5 times) previous topic - next topic

vespapierre

#15
Nov 21, 2012, 04:25 pm Last Edit: Nov 21, 2012, 04:33 pm by vespapierre Reason: 1
seems that I'm newbie...
I have checked the example method of post...

http://community.thingspeak.com/documentation/api/

How can I put that to your code Tim?

is this the sending to the server?:
<code>
sprintf(pageAdd,"/",totalCount);
   // sprintf(pageAdd,"/arduino.php?test=%u",totalCount);

   if(!getPage(server,pageAdd)) Serial.print("Fail ");
   else Serial.print("Pass "); </code>

Should I use strcpy  to put the lines to pageAdd and then sprintf(pageAdd); ?

Sorry for the question...


SurferTim

The API says it will take GET or POST requests, so this should work. In loop() change the sprintf line.
Code: [Select]
sprintf(pageAdd,"/update?key=MyKey&test=%u",totalCount);

Change MyKey to your key. Change "test" to "Field", "Channel", etc. Change totalCount to the parameter you want to pass.

Insure there are no illegal characters in the parameters, like spaces.

vespapierre

Tim,

seems your code is working. Exactly did what you wrote. Serial monitor said:

Starting ethernet...
192.168.9.110
Starting SD...ok Ready
connecting...connected
HTTP/1.1 200 OK
Server: nginx/0.8.53
Date: Wed, 21 Nov 2012 19:01:40 GMT
Content-Type: text/html; charset=utf-8
Connection: close
Vary: Accept-Encoding
Status: 200
ETag: "b4fd1d2cb085390fbbadae65e07876a7"
Cache-Control: max-age=0, private, must-revalidate

2809
disconnecting.
Pass 1

I have just add manually temp values.


SurferTim

Of all the things I enjoy seeing in the serial monitor, this is my favorite:
Quote
Pass 1


vespapierre

I have defined the temp0, temp1 ... values as "int". How can put them to sprintf(...)? Manual send was : &field1=200&field2=200 ....
instead of 200 i have to put the temp0, temp1 ....

Go Up