Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

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:

http://mbed.org/media/uploads/donatien/schematic.png

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

Ethernet Socket

Warning

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!

Software

Information

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:

main.cpp

// 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() {
  ethernet.setup();
  twitter.basicAuth(TWITTER_USER, TWITTER_PASSWORD);

  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

Finally

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.




calendar Page history
Last modified 21 Jun 2010, by   user Donatien Garnier   tag HTTPClient, ID12, internetofthings, RFID, tutorial, twitter | 5 comments  

5 comments on RFID Tweeter:

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

Ceri

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?

Please login to post comments.