Control digital out pins by Twitter messages. Sensor readings sent back to Twitter.
MODIFIED BY JOHN DINGLEY FROM Twitter2LCD originally written by Fabrizio Granelli
*You can send text messages to the Arduino LCD screen from twitter if there is anyone is around at the other (Arduino) end you want to send text messages to.
*You can control the digital output pins of your arduino by sending it twitter "data" messages from same twitter page.
*Your Arduino can send twitter messages or data back from analog port sensors to the person who is using twitter on the other side of the world.
..............So full 2 way control with feedback!
* Allows twitter messages to display on an LCD display via arduino and ethernet shield. No PC required!
* ALSO ALLOWS CONTROL OF 4 DIGITAL OUTPUT PORTS VIA SIMPLE TWITTER MESSAGES
*This means I can control 4 relays for example just by sending a Twitter message.
* Arduino reads the twitter messages at 1 minute intervals and displays them on an LCD screen.
* They can be normal text messages to someone near to the Arduino OR if they have a D as first letter, they are read as "data" messages and used to control the Digital Output Pins.
* Also, the arduino can take measurements from sensors, for example a thermometer and Tweet the readings back to the remote operator who is sending the data/text tweets to the Arduino. So you have FULL REMOTE 2 WAY CONTROL VIA TWITTER
NOTE: IF YOU JUST WANT TO TURN THE OUTPUT PINS ON AND OFF REMOTELY, AND HAVE SENSOR DATA SENT TO TWITTER, YOU DON'T NECESSARILY HAVE TO HAVE THE LCD SCREEN PRESENT, the sketch will run fine, just don't bother connecting up an LCD module.
Step 1: What it does
How to use it:
* Set up your twitter account. Choose a username that has 6 (SIX) characters in it, no more and no less.
* - To send a text twitter message to be displayed on the arduino-LCD display, just send it as normal.
* - To send a DATA message (to turn one of 4 LED's on the arduino digital output ports on or off) send a twitter formatted as follows:
* a) Start with a capital "D" , this tells the arduino this twitter has data in it which it needs to look for
* b) After the "D" , with no spaces enter FOUR digits. These must be 0 or 1.
* c) EXAMPLE: the twitter message D0100 will turn on LED 2, D1000 would turn on LED1, D0010 would turn on LED3, D0001 will turn on LED4
* Therefore you can modify this code to turn relays on and off or control anything you like.
NO PC REQUIRED AT ALL
Arduino (I used a Uno) and Arduino 22
Ethernet cable to connect shield to your router box.
I use a standard Serial-to-LCD display. This connects to arduino with 4 wires in total so much easier to set up than a pure LCD screen. Arduino sends it text via a serial wire, using a print.Serial("yourtext"); type of command using SoftwareSerial library. LCD is actually optional, it will still work as a 2 way control system without it.
I have had trouble with some of the blue screened serial-to-LCD displays. I would get a completely standard green one from your Arduino supplier then you know it should work. Try to get one with 4 rows of text so everything fits on the screen.
In photo below you will see I tweeted the message D0101fgh to the Arduino. The Arduino sees the "D" at the front an therefore knows it is a data tweet not just a text message. It then looks at the next 4 characters after the D (which will always be 0 or 1), and these trun the 4 Output Pins ON or OFF.
[Note: The few random letters after the 0's and 1's are there because twitter will not send repeat messages that are the same as ones sent previously. A few random letters get around this (or regularly delete your tweets).
When the Arduino is tweeting data from the analog sensors back to the person using twitter on the other side of the world, it does the same thing but then automatically generates a few random harmless characters at the end of the message to achieve the same objective in the other direction.]