top of page

Tweet using arduino-tweet.appspot.com

#include <Ethernet.h>

#include <SoftwareSerial.h>

#include <SPI.h>

#include <WiFly.h>

 

#include "wiflyshield.h"

//note that you have to change this if your are going to use Arduino Yun instead of Wifly + Arduino Uno

 

char token[] = " "; // Get this from arduino-tweet.appspot.com

 

// Fixed settings:

char server[]={31,170,163,90};

const char site[] = "arduino-tweet.appspot.com"; // Site that sends our tweets

SoftwareSerial wifiSerial(3,4); // This is where Arduino i/o pins are set

char msg[140]= "Student: John Kevin Ellamil, studno: 2010-13665, purpose: CoE 197 Advise"; // Tweet length;

void setup() {

 

Serial.begin(115200);

initWifly(); 

 

connectToNetworkUsingWiFly();

    if(client.connect(site, 80)) {

    Serial.println("connected");

    //delay(2000);

    client.println("POST http://arduino-tweet.appspot.com/update HTTP/1.0");

    client.print("Content-Length: ");

    client.println(strlen(msg)+strlen(token)+14);

    client.println();

    client.print("token=");

    client.print(token);

    client.print("&status=");

    client.println(msg);

    client.println();

    delay(5000);

    } else {

        Serial.println("Connection failed.");   

    }

  

}  

 

void loop() {

 

 // if there are incoming bytes available 

  // from the server, read them and print them:

  if (client.available()) {

    

    char c = client.read();

    //Serial.println("qwe .");

    

    Serial.print(c);

    //Serial.println(" asd ");

    

  }

 

  // if the server's disconnected, stop the client:

  if (!client.connected()) {

    Serial.println();

    Serial.println("disconnecting.");

    client.stop();

 

    // do nothing forevermore:

    while(true);

  }

}

 

bottom of page