Hi All,
A while ago, I posted a how-to about controlling arduino (and anything connected to it) from a cell phone through twitter and a computer: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1268669525 . This worked great, and required no extra hardware. Unfortunately, twitter changed their auth system so this no longer works. Also, it used a php script which really wasn't necessary. Thus, I have eliminated it, and retooled the other programs, it now works great with a python script running on the computer, and an arduino program.
First, you need to setup twitter via SMS: http://support.twitter.com/forums/23786/entries/14589
Then, run the following python script on your computer that the arduino is connected to. Note: replace /dev/ttyUSB0 with the name of your serial port, and change the twitteruser variable to your twitter username.
import urllib
import serial
import time
from xml.dom import minidom
ser = serial.Serial('/dev/ttyUSB0', 9600)
twitteruser = "arduinocomnet"
urlparts = ['http://search.twitter.com/search.atom?q=from:', twitteruser, '&rpp=1']
foobar = ''.join(urlparts)
while(1):
xmldoc = minidom.parse(urllib.urlopen(foobar))
title = xmldoc.getElementsByTagName('content')[0].firstChild.data
message = title[0:-5]that
if message == "Ledon":
ser.write('1)
elif message == "Ledoff":
ser.write('0)
time.sleep(30)
One important thing is that twitter only lets you post the same status once every few days, so I wrote the python script to ignore the last 5 characters of the twitter message. This allows you to add a space and then a random 4 digit number (i usually just use the time) after your twitter status, to prevent twitter from giving you the same status error. If this doesn't make sense, just look at my sample twitter feed for how it should work: http://twitter.com/#!/arduinocomnet
Then, this program on the arduino listens to the serial port and (in this case) turns an LED on or off.
int inByte;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
}
if (inByte == '1') {
digitalWrite(13, HIGH);
}
if (inByte == '0') {
digitalWrite(13, LOW);
}
}
Now just send a text message to twitter like "Ledon 1234", and in 30 seconds, your led will turn on.
I have used this setup to turn on and off a few large appliances (through relays) from anywhere with cell service. It works great!
Please feel free to adapt this code to your liking and ask me any questions you have here,
Good Luck!