User Tools

Site Tools


twitter_button

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

twitter_button [2013/08/13 12:13] (current)
Line 1: Line 1:
 +The Twitter Button is Back in Business! 
 +(Expect updated code soon)
 +Note: Twitter changed its authentication system to reject basic http auth...
 +This <del>might</del> does work: [[http://www.arduino.cc/playground/Code/TwitterLibrary|http://www.arduino.cc/playground/Code/TwitterLibrary]]
 +=====  Summary  =====
 +The "Twitter Button" project's goal is to use a big red HAL9000 button to indicate via twitter that a keyholder is present at [[NSL]] 
 +The project has since been expanded to include an RFID reader to identify keyholders in addition to the button.
 +
 +===== Status =====
 +**Active Use!**
 +The button is up and mounted next to the door!
 +Current twitter button status can be viewed on the [[When Are You There?]] page :)
 +
 +=====  Objectives  =====
 +Completed:
 +  *  Light up button while "NSL is open"
 +  *  Tweet status
 +  *  Status change by button-press
 +  *  Read and Identify RFID card
 +  *  Status change by RFID read
 +  *  Specific status change based on RFID card used
 +  *  Twitter session [[no|longer]] expires after 10 min.
 +  *  Twitter wont let you "retweet" past posts... (<del>need to make</del> each post [[is|now]] unique)
 +
 +In Progress:
 +  *  Configure for keyholder RFID cards... So far I have a handful of cards set up, let me know if I've missed you...
 +  *  Package into Box
 +  *  Sleep
 +
 +Current Issues:
 +  *  Twitter has a limit on posts per hour... not nice for testing
 +  *  Fit everything into the box, need to play more tetris. (I think that everything fits now)
 +  *  Make holes in box for power/ethernet/usb/program mode button
 +
 +Future Plans:
 +  *  Authenticate RFID with a Python app on server.
 +
 +=====  Code - Basic Concept  =====
 +''
 +<code>
 +  - include <Ethernet.h>
 +
 +byte mac[[]] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
 +byte ip[[]] = { 10, 0, 5, 247 };\t\t\t    // this is the ip within my lan
 +byte gateway[[]] = { 10, 0, 0, 1 };\t\t\t// neccessary to get access to the internet via your router
 +byte subnet[[]] = { 255, 0, 0, 0 };
 +byte server[[]] = { 128, 121, 146, 100 };\t\t   // Twitter's ip
 +
 +Client client(server, 80);
 +
 +void setup()
 +{
 +<code>
 +  Ethernet.begin(mac, ip, gateway, subnet);
 +  Serial.begin(9600);
 +  delay(1000);
 +  Serial.println(`connecting...`);
 +  if (client.connect()) {
 +    Serial.println(`connected`);
 +    client.println(`POST http://twitter.com/statuses/update.json HTTP/1.1`);
 +    client.println(`Host: twitter.com`);
 +    client.println(`Authorization: Basic XXXXXXXXXXXXX`);// the string of ###s after `Basic` is the base64_encoded Text of username:password of your twitter account</code>
 +    
 +\t\t\t\t\t\t\t\t\t\t\t\t// you can do the encoding at this site: http://www.functions-online.com/en/base64_encode.html
 +<code>
 +    client.println(`Content-type: application/x-www-form-urlencoded`);
 +    client.println(`Content-length: 28`);\t\t\t\t\t // this is the length of the text `Yahoo, im twittering!`
 +    client.println(`Connection: Close`);
 +    client.println();
 +    client.print(`status=Yahoo, im twittering!`);
 +  } else {
 +    Serial.println(`connection failed`);
 +  }</code>
 +}
 +
 +void loop()
 +{
 +<code>
 +  if (client.available()) {
 +    char c = client.read();
 +    Serial.print(c);
 +  }
 +  if (!client.connected()) {
 +    Serial.println();
 +    Serial.println(`disconnecting.`);
 +    client.stop();
 +    for(;;)</code>
 +\t;
 +<code>
 +  }</code>
 +
 +</code>
 +''
 +
 +=====  Contact  =====
 +Any inquiries/suggestions should be told/sent/given/yelled to [[Davo]] in person, via the nsl list, or via IRC... :)
  
twitter_button.txt ยท Last modified: 2013/08/13 12:13 (external edit)