SocialBot9000: Arduino Based Twitter Display

If for some reason the ustream embed does not appear, refresh the page.

UPDATE: The SocialBot9000 device has returned to meet it’s parts box. Look for something new and exciting… when I think it up. I am leaving the rest of the post as is.

Display Your Message on the SocialBot9000. (UPDATE: SEE ABOVE NOTE)

  1. Enter your message in the form below.
  2. Press “Tweet”. You will be redirected to twitter.
    • If you are not logged in you will be promoted to do so.
    • You will see your message with the required syntax ready to tweet.
    • tweet your message.
  3. watch the ustream for your message to appear
  4. Be Patient: you are waiting for twitter to put your tweet in the search results (30 seconds or so), the socialbot to see it (5 seconds-ish), ustream to catch up (30 seconds).

Project Origins:

I was watching Ben Heck’s show on revision3. For Valentines day he made a device that would show love messages sent via twitter. Ben Heck being a nerd master, with more fu than I, WAY over complicated the project. It had custom microcontrollers, php, serial interfaces and all kinds of crap cool stuff. So I thought to myself, I can rebuild it simpler, smaller and with basically the same hardware setup I just used for my Arduino Thermostat.

Required Hardware:

  1. Arduino Uno
  2. Ethernet Shield
  3. LCD Display
  4. Protoshield
  5. Jumper wires

Basic Steps:

In short we need to do the following:

  1. Build Hardware
  2. Search twitter for whatever we want to display
  3. Put it on the screen (Arduino Ethernet Client)
  4. Provide some sort of UI to let the world play with Socailbot900

Building the Physical SocialBot9000

If you have the hardware I listed above this is going to be really easy. This part of the project took me less than 30 min.

  1. Insert Ethernet Shield into Uno
  2. Insert Proto Shield into Ethernet Shield
  3. Connect jumper wires
  4. Insert LCD
  5. Start the harder part (well for me anyway)

There is a lot of information on how to hook up LCDs so I won’t go too deep. The real complication here is not conflicting with the Ethernet. So check out the source (link bellow) for the pin configuration I used.

Here is a cheat sheet:

LCD Pin Hookup
1 Ground
2 5v
3 Pot (middle pin)
4 Arduino Digital 2
5 Ground
6 Arduino Digital 3
7 None
8 None
9 None
10 None
11 Arduino Digital Pin 4
12 Arduino Digital Pin 5
13 Arduino Digital Pin 6
14 Arduino Digital Pin 7
15 5v
14 Ground

Searching Twitter:

Twitter provides a handy API thing to easily extract data and BAM:

That will get ya where you want to go. So I wrote a PHP page that curls that URL, cuts out the message and gets is ready for the socialbot. So the PHP looks like this:

$ch = curl_init(“″);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_GET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$start = strpos($output, “start”) + 6;
$end = strpos($output, “end”);
$tweet = substr($output, $start, $end-$start);
echo ‘<'.trim($tweet).'>‘;

Arduino Ethernet Client:

If you read this bildr turtorial you are 90% there.

There are a few important notes.

  1. I am going crazy with the OLs in this post.
  2. Arduino 1.0 supports DHCP, so you don’t have to assign the Arduino a static. Because this is a client situation that works out well. EXCEPT when you are on a network where the DHCP server and the Arduino don’t seem to talk, then its back to static land. Moral of the story: try DHCP first.
  3. To keep this really simple I would have loved for my twitter searching part to be on the same server as everything else. However, my shared hosting account does not have an IP so I had to host this part somewhere where I could pretend. Like a linux machine in a closet somewhere in the world.

You can download and play with the Arduino code here (right click, save as, bla, bla, bla, if you got this far I really don’t need to tell you).

Provide some sort of UI to let the world play with Socailbot900
For now that UI is this post, the ustream and the iframed form. The ustream is coming from a webcam/netbook in a closet. Earth shattering I know.

I am pretty sure my form could use some help, but it was not the focus of this project.

The one cool thing that is interseting to note is how to set up a tweet, making it easy for people to interface with the SocialBot9000.

First the syntax. My twitter search of for “socialbot9000″. So twitter will return any tweet where its mentioned. Then I look for “start” and “end”. So for a message to appear you need to tweet something like “@socialbot9000 start I like cats (not really) end”. I am a online marketer for a living and I can tell you trying to get people to set that up for themselves will be a pain and rife with errors. Enter the form.

So the form submits you message to a php thing that concatenates it with the rest of the syntax. There is client side processes to make sure the message is less than 30 chars. Because anything more is just useless.

So my PHP for the UI should looks like this:

$tweet = $_POST["limitedtextarea"];
header( ‘Location: start ‘.$tweet.’ end’ );

So in here is a marketing pro-tip. Want to set up a message that people can quickly and easily tweet. Just use the URL above. A fine example would be this.

5 Responses to SocialBot9000: Arduino Based Twitter Display

  1. Pingback: Display Twitter on an Arduino - Hack a Day

  2. I so sorry! I tried to tweet ” ┌∩┐(◕_◕)┌∩┐ ” to it, and now all it says on the screen is SocialBot9000… I don’t think it liked the ASCII characters…

  3. jackman says:

    hi Anzel360,

    i have a few problem regarding this tutorial. i just have to copy the code and replace the IP with my laptop IP and replace the port number from”XX” with “80″ rite? the IP is twitter IP or my laptop IP coz i dont manage to get it to work. all i get is !DOCTYPE html. do u know what it is?

    • Anzel360 says:

      So the server IP should be the place that hosts the php script, not twitter. So make sure your laptop is the lamp/wamp/whatever you have running php. Also make sure the path to the document is correct.

      If you are getting some sort of return, it sounds like your arduino is successfully talking to your server.

  4. Pingback: OSCON Recap | Anzel360

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>