Arduino and Ethernet Shield sending Tweets to Twitter

Arduino and Ethernet Shield sending Tweets to Twitter © GPL3+

The idea is to show how easy we can use Arduino to post automatic and cyclical Tweets to share the status of the Analog inputs in Twitter.

  • 1,247 views
  • 0 comments
  • 3 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
Eipgsd2k
Twitter
http://arduino-tweet.appspot.com/

About this project

My idea was to prepare a simple code to share, in my Tweer account, the status of the Analog inputs every 70". Look at this, it was so easy:

Important is to go to the following link to download the libraries and follow the instructions.

http://arduino-tweet.appspot.com/

Code

CodeArduino
Copy and paste. Change your token and IP
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 1, 177 }; //This is for the IP address of your board. Scan your router and select the ight IP address
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("PUT HERE YOUR TOKEN THAT LINKS THE TWEETS TO YOUR TWEETER ACCOUNT"); //put here your token

// Message to post
char msg[200];
int a0,a1,a2,a3,a4,a5;
int n=0;

void setup()
{
  delay(1000);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("SimplePostTwitter.ino  envía un tweet cada 70sgs. con el valor de la A0 en decimal y delante un número indicando el numero de Tweet");
  Serial.println("connecting ...");
}

void loop()
{
while(1){ //repeat for ever
          n++; // Index to say which order of tweet is
          //get some data from Aanalog inputs. 
          a0=analogRead(0);
          a1=analogRead(1);
          a2=analogRead(2);
          a3=analogRead(3);
          a4=analogRead(4);
          a5=analogRead(5);
          sprintf(msg,"Tweet number... %d : A0=%d : A1=%d : A2=%d : A3=%d : A4=%d : A5=%d", n,a0,a1,a2,a3,a4,a5); // Variables to show in the Tweet body
          Serial.println(msg);  //for testing
          if (twitter.post(msg)) { //To post the Tweet and somes diagnostics
                          int status = twitter.wait(&Serial);
                          if (status == 200) {
                            Serial.println("OK.");
                          } else {
                            Serial.print("failed : code ");
                            Serial.println(status);
                          }
              } else {
                          Serial.println("connection failed.");
                        }
           delay(70000); // Server can only receive 1 tweet per minute. This value is in miliseconds
         }
}

Comments

Similar projects you might like

Send Tweets Using Arduino with Artik Cloud

Project tutorial by Jasper

  • 1,668 views
  • 0 comments
  • 9 respects

LED Displayed Twitter Sentiment Analysis

Project tutorial by Andrew Steinheiser

  • 1,064 views
  • 1 comment
  • 3 respects

Using 9 Axes Motion Shield with Arduino

by Techmirtz

  • 4,416 views
  • 2 comments
  • 17 respects

DFRobot's 2.8" TFT Touch Shield for Arduino

by Techmirtz

  • 2,889 views
  • 1 comment
  • 22 respects

How can you Report Thief with a Photo on Twitter by Arduino

Project tutorial by ahmed ismail

  • 1,536 views
  • 0 comments
  • 8 respects
Add projectSign up / Login