Arduino Yún - HTTP POSTing pin data over WIFI?

Hey all, I've been playing around with an Arduino Yun for a few weeks now and loving it, there's just one thing I can't seem to crack over WIFI. As the title might entail I'm trying to post some pin data out up to the API ThingSpeak with an HTTP Post, using an 'if statement' (or just inside a loop without an if statement, I'm happy either way). This code, taken from the ThingSpeak Talkback example sketch is where I'm starting from, it takes commands from the Thingspeak API and performs functions and all I've added a simple digital read on PIN 4 with doesn't upset the existing functionality. I would love to post that PIN value to To the API – which I know how to do with tools like Firefoxes POSTER eg.

URL: Content Type: application/x-www-form-urlencoded Body: api_key=F6MWU8Y7CA9UMDK3&field1=62

ETC but I just don't know what methods to use in terms of the Arduino Yun's WIFI, Libraries and methods to HTTP Post. If anyone can point me in the right direction that would be amazing!

Sorry if this is the wrong place to post this, I had a look around and this is the first time posting anything on this forum!

Thanks, Dood —--

#include "Bridge.h"
#include "HttpClient.h"
//ThingSpeak Settings
String thingSpeakAPI = "";
String talkBackAPIKey = "OGPWLXS4ZW7P6JJT";
String talkBackID = "180";
const int checkTalkBackInterval = 1000; // Time interval in milliseconds to check TalkBack (number of seconds * 1000 = interval)
// Variable Setup
long lastConnectionTime = 0;
void setup()
// Setup On-board LED
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
// Initialize Bridge
// Initialize Serial
void loop(){
void switchRead(){
int tiltSwitch = digitalRead(4);
void checkTalkBack()
HttpClient client;
String talkBackCommand;
char charIn;
String talkBackURL = "http://" + thingSpeakAPI + "/talkbacks/" + talkBackID + "/commands/execute?api_key=" + talkBackAPIKey;
while (client.available()) {
charIn =;
talkBackCommand += charIn;
if (talkBackCommand == "TURN_ON")
digitalWrite(13, HIGH);
else if (talkBackCommand == "TURN_OFF")
digitalWrite(13, LOW);

If you must use HTTP POST (can't use GET) then it looks like you'd have to execute Curl on the Yun to POST the content using the Shell Commands.

Your command would be: curl -d 'api_key=XXXXXXXXXXXXXXXXXXX&field1=62'

When I run your POST I get back a number ("86"). From, the example there which also returns an integer, the code would look like:

void loop() {
  Process p;
  p.runShellCommand("curl -d 'api_key=XXXXXXXXXXXXXXXXXXX&field1=62'");

  // do nothing until the process finishes, so you get the whole output:

  // Read command output. 
  while (p.available()) {
    int result = p.parseInt();          // look for an integer
    Serial.println(result);         // print the number as well
  delay(5000);  // wait 5 seconds before you do it again

I don't have a Yun and can't test this, but y'know, theoretically it should work. The Yun docs state that it already relies on Curl for GET requests so apparently POST just hasn't been implemented yet in the Yun interface library.

Brilliant! That worked alright, now I'm going have to backtrack and figure out why it worked ;)

The 86 that you got back was the number of the post (it would be 87 then 88 there after etc)

Thanks very much, data is going up to the ThingSpeak channel like a charm.