RFID Tweeter

In this simple example of the "Internet of Things", we show you how to trigger a tweet from your mbed using an RFID tag.

Hardware Components

For this example, we use:

Library Components

To drive these hardware components and to talk to twitter, we use the following libraries:

Hardware Setup

Here is the setup we are going to use:


First of all, plug your mbed into the breadboard. Connect the ground (GND) pin with the breadboard's ground line and the USB power pin ((VU) to the power line.

RFID Reader

  • Connect the 5V (pin 11) and RST (pin 2) pins to the power line
  • Connect the GND (pin 1) and FS (pin 7) pins to the ground line
  • Finally connect the D0 (pin 9) pin to the p14 pin of the mbed (which is a serial input pin)

Ethernet Socket

  • Connect the socket's pin 3 to the mbed's RD- pin
  • Connect the socket's pin 1 to the mbed's RD+ pin
  • Connect the socket's pin 4 to the mbed's TD- pin
  • Connect the socket's pin 6 to the mbed's TD+ pin


The socket's pinout is valid for this part. If you are using a different one, be sure to check if the pinout is not different.

RFID Tweeter Bradboard

Then plug a network cable into the socket, and connect your mbed to your computer!



The basic authentication service for twitter is going down at the end of the week. To continue using that program, the code has been updated to use http://supertweet.net which acts as an API proxy. Simply visit the website to setup your twitter account for this API. See: http://www.supertweet.net/about/documentation

The full program including the libraries is published here:

Here is the main code form that program for reference:


// RFID Tweeter

#include "mbed.h"
#include "ID12RFID.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"

#define TWITTER_USER "donatiengarnier"
#define TWITTER_PASSWORD "myverysecurepassword"

#define IDS_COUNT 3
const int ids_list[IDS_COUNT] = {89481809, 89481810, 89481811};
const char* names_list[IDS_COUNT] = {"Donatien", "Simon", "Dan"};

EthernetNetIf ethernet;
HTTPClient twitter;

ID12RFID rfid(p14);
DigitalOut tag_present(LED1);
DigitalOut tweet_ok(LED4);

int main() {

  while(true) {
    int id = rfid.read();
    tag_present = 1;
    for(int i = 0; i < IDS_COUNT; i++) {
      if (ids_list[i] == id) {
        HTTPMap msg;
        msg["status"] = names_list[i];
        msg["status"] += " just arrived home!";
        HTTPResult r = twitter.post("http://api.supertweet.net/1/statuses/update.xml", msg, NULL);
        tweet_ok = !r;
    tag_present = 0;

Setting up for your own twitter account and tags

The program requires some configuration for your own setup

  • Replace the TWITTER_USER and TWITTER_PASSWORD macros with your account's parameters
  • Change the registered tag ids and their owners in the ids_list and names_list tables
    • Update the IDS_COUNT define accordingly
  • Personalize the message (msg["status"]) a bit...


Compile the program and download it to your mbed. Press the reset button, and it should spring in to life!

Hopefully this can be used as an easy reference for creating all sorts of "Internet of Things" applications.

1 related question:


30 Sep 2011

I have a problem. My program, exactly as above (except my ID tag number inserted, and twitter credentials changed) just stops after successfully detecting the tag. Examining the progress in a terminal window, I have an IP address OK (I have verified full Ethernet is OK using another program), the LED1 lights when the tag is presented, but I can get no further. I have added a printf just below the HTTPResult and it never gets there, so I asssume it's getting stuck here for some reason. Has anyone else had problems? Cheers

07 Dec 2011

I can't believe with this major example of using MBED, RFID and Twitter, so few comments! Does this mean that 99% of the people have no problems, or even good comments. I have a problem like you, but I did get an output tweet, but only once, or maybe twice! I later got word from Twitter/super-twitter that someone had compromised my account, so I changed to a different e-mail account and changed passwords. Still not working. I guess you know the password of Super Twitter goes in main.cpp, and not your regular twitter password.

Also, I found the wiring is not correct, for, I got no indication of any RJ-45 connection. Maybe, in the US the cable pinouts are different. Here is my wiring to RJ-45 and MBED. I got a couple of tweets back (LED1 first lit, then after a bit, LED4) And then nothing!!! Very frustrating. RJ-45 pin1 goes to mbed pin6...RJ-45 pin2 goes to mbed pin 5...RJ-45 pin3 goes to mbed pin8...RJ-45 pin6 goes to mbed pin7.

Been at it too long. What next to do? donde

07 Dec 2011

There appears to be, from my experience anyway, Ten or more different pin outs of RJ45 connectors.

Very confusing. But there is a thread with some diagrams, and more info.

Also, there is/was an error in the decoding of RFID number, One of my posts has a fix for it :)

As for sending tweets,

I found, you cannot send the same message a second time.

My fix: start message with random characters,

Or seconds,minutes as number.

Hope this is usefull


07 Dec 2011

OK on not sending same message. I believe the RJ-45 is now correct, for I got the setup to work once with the Twitter example without RFID.

Watching the process on minicom, basicially I see Init, Setup, Setup OK, and then "Problem during tweeting, return code 6". Whatever return code 6 means.

Let me change the message and get back to you.

Thanks, donde

07 Dec 2011

THAT DID IT! Just changing the wording. I had no idea, but that goes along with idea of people jamming the twitter network with constant repeats.

Anyway, minicom now shows: Init, Setup, Setup OK and finally: Tweet sent with success!

Thanks Cerl, you've made my day. Now maybe RFID Tweeter might work?

22 May 2012

The code using the Library Components listed above

ID12 RFID Reader Ethernet HTTP Client

which I import from the link listed in the description above:

"The full program including the libraries is published here:

http://mbed.org/users/donatien/programs/TweetRFID "

does not seem to compile.

I get these compile errors:

"cannot open source input file "api/socket.h": No such file or directory" in file "TweetRFID/lib/HTTPClient/HTTPClient.h", Line: 31, Col: 23

"cannot open source input file "core/fwk.h": No such file or directory" in file "TweetRFID/lib/HTTPClient/HTTPClient.cpp", Line: 29, Col: 21

"cannot open source input file "core/fwk.h": No such file or directory" in file "TweetRFID/lib/HTTPClient/data/HTTPMap.cpp", Line: 24, Col: 21

"cannot open source input file "core/fwk.h": No such file or directory" in file "TweetRFID/lib/HTTPClient/data/HTTPText.cpp", Line: 24, Col: 21

Is there some huge configuration control problem with this mbed system? Any ideas? Thanks in advance.

23 May 2012

Hi Michael, just registrer in Super Tweeter API and import the new library of HTTPClient, look this example, i am too use the same code of Donaten...


09 Jun 2012

I am having some challenges with the RJ45 pin-out, i am not seeing any connectivity lights. What is the pin-out that works? any help would be appreciated.

16 Nov 2012

Sorry to ask such a simple question RJ45 Sparkfun Breakout Board what is pin 1?

17 Nov 2012

Hello Charlie , Pin 1 is the rectangular shaped one , in the ( breakout board ) pcb .

17 Nov 2012

I am getting a compile error: cannot open source input file "TCPSocketConnection.h": No such file or directory

I have tried to compile the same program above after importing it and get the same error.

Thanks XM for previous comment.