Social Networking using RFID .

Introduction:

The following project sends out messages to social networking sites like Twitter using a RFID reader. The RFID reader used is ID-12 and an Ethernet cable is used to send messages to twitter. The user Id and password are provided in the program. Once the RFID device is read using the RFID reader. The code maintains an array of RFID Tags and their corresponding names, which is tweeted in the user's account.

/media/uploads/rpelleti3/_scaled_photo02281401.jpg

Connections:

/media/uploads/rpelleti3/lab3.jpg

/media/uploads/rpelleti3/lab3-2.jpg

Configuration

A simple code to read the RFID Tag Numbers is used:

RFID Reader

#include "mbed.h"
#include "RFID.h"

RFID rfid (p13,p14);
Serial pc (USBTX,USBRX);
int main() {
  while (1){
    int id = rfid.read();                // Reads the RFID Tag
    pc.printf("Tag ID = %d\n\r",id);     // Prints the RFID Tag into the Terminal
    }
}




Using the Tag numbers obtained by the above code. An array of RFID Tags is created along with the corresponding names. This is used in the following code to update the remote HTTP server.

main.cpp

 #include "mbed.h"
 #include "ID12RFID.h"                          // RFID Header Files
 #include "EthernetNetIf.h"                     // Ethernet Header Files
 #include "HTTPClient.h"                        // HTTP Client Files
 
 #define TWITTER_USER "TWITTER USER NAME"       // Enter the user name of the twitter account instead of "TWITTER USER NAME"
 #define TWITTER_PASSWORD "TWITTER PASSWORD"    // Enter the password of the twitter account instead of "TWITTER PASSWORD"
 
 #define IDS_COUNT 4
 
 const int ids_list[IDS_COUNT] = {110319217, 3969345, 11238390, 45320969};
 const char* names_list[IDS_COUNT] = {"James", "Peter", "Ema", "John"};
 
 EthernetNetIf ethernet;
 HTTPClient twitter;
 
 ID12RFID rfid(p14);
 
 DigitalOut tag_present(LED1);
 DigitalOut tweet_ok(LED4);
 
 int main() {
   
   ethernet.setup();
   twitter.basicAuth(TWITTER_USER, TWITTER_PASSWORD);
 
   while(true) {
   
     int id = rfid.read();
     tag_present = 1;
     printf("Tag : %d", id);
     for(int i = 0; i < IDS_COUNT; i++) {
     if (ids_list[i] == id) {
     HTTPMap msg;
     msg["status"] = names_list[i];
     msg["status"] += " says Hi to all !!!";
     HTTPResult r = twitter.post("http://api.supertweet.net/1/statuses/update.xml", msg, NULL);
     tweet_ok = !r;
   }
    }
     tag_present = 0;
   }
}


Please log in to post comments.