Controlling Arduino With Twitter


I'm trying to control and arduino with twitter, so i can use it to control a powerswitch tail relay.

Basicly i want to have my arduino react when i tweet "turn on light" or something.

I haven't found any options to this that take into account the new oAuth that twitter has implemented.

anyone have a good way to do this? The arduino would be connected to a computer.

There is a twitter library but I recall there are some problems with Arduino 21 but It might give you a start. It could be that it is sending only. Not experimented with it yet.

I would start with an Arduino and ethernetshield. Let the Arduino monitor some minimal website (24/7) that serves a text file representing your last tweet. This brings the difficult part of parsing the tweets to a more powerful platform than the Arduino. e.g. PHP See -

The thing is i don't want to use the ethernet shield, i'd rather just interface it from a laptop. I assume this will make the job easier.

Similar strategy in fact, let the laptop parse the tweets and if something must be done send the right command over the serial line.

Check - for more about serial communication

check also - as that will be the core of your app. and instead of echoing the received byte switch on /off the light (you can simulate this with a LED, before connecting your real lightswitch :slight_smile:

do you have some example code?

no but it is easy to modify the Serial read example something like this;


int incomingByte = 0;      // for incoming serial data

void setup() 
  Serial.begin(9600);      // opens serial port, sets data rate to 9600 bps
  pinMode(LED, OUTPUT);

void loop() 
  if (Serial.available() > 0) 
    // read the incoming byte:
    incomingByte =;

    if (incomingByte == '1')
      digitalWrite(LED, HIGH);
    } else {
      digitalWrite(LED, LOW);
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);

If the Arduino receives a character 1 from the PC it will turn on the onboard LED.