MicroTweet - Adding tweeting to your Netduino/.Net Micro Framework projects

Today's Hardware Friday was included as component of a past Channel 9 article today we give it its own article. While it isn't directly "hardware" related, it is a project that helps you and your hardware project, such as a Netduino Plus project, reach out and touch...

MicroTweet - Twitter OAuth API Library for the .NET Micro Framework

Welcome!

MicroTweet is a native Twitter OAuth API library for the .NET Micro Framework. It can be used to post messages on Twitter from small, inexpensive devices such as the Netduino Plus.

MicroTweet is now available as a NuGet package! Click here for more details or simply use Install-Package MicroTweet to add MicroTweet to your project.

Featured Links

Getting Started

  • When running the sample projects, make sure you copy Config.sample.cs to Config.cs before building the project.
  • To use the Twitter API you must first register an application with Twitter to get a set of API keys.
  • The following values must be entered in Config.cs:
    • Consumer Key and Consumer Secret for your Twitter application.
    • Access Token and Access Token Secret for your Twitter user account. (Click the "My Access Token" link on your app's page to get these keys.)
  • Remember to configure the project to deploy to your device rather than the .NET MF Emulator.
  • ...

Here's a snap of the Solution;

image

Included in the download is couple samples which provide some cool examples;

Here's some partial code snips from the Tweeting Breathalyzer sample

First the setup;

// If the time update was successful, set up the TweetBot
if (timeUpdated)
{
    redLED.Write(false);
    twitterClient = new TwitterClient(Config.ConsumerKey, Config.ConsumerSecret, Config.UserToken, Config.UserTokenSecret);
    twitterClient.DebugMessage += new DebugMessageEventHandler(tweetBot_DebugMessage);
}

And sending a message;

static void button_OnInterrupt(uint data1, uint data2, DateTime time)
{
    if (twitterClient == null)
        return;
    greenLED.Write(true);

    int sensorValue = GetSensorValue();

    string message;
    if (sensorValue < 20)
        message = "No alcohol detected";
    else if (sensorValue < 40)
        message = "Tipsy";
    else if (sensorValue < 60)
        message = "Drunk";
    else if (sensorValue < 80)
        message = "Whoa!";
    else
        message = "x_x";

    DateTime adjustedTime = DateTime.Now + new TimeSpan(Config.TimeOffset, 0, 0);

    message += " at " + adjustedTime.ToString("h:mm:ss tt");

    try
    {
        twitterClient.SendTweet(message);
    }
    catch (Exception e)
    {
        Debug.Print(e.ToString());
    }

    greenLED.Write(false);
    button.ClearInterrupt();
}

As you can see it's almost too easy to add tweeting to your project with the library.

If you're building a hardware project that needs to tweet or are interesting in seeing how to write your own Twitter interface, you should stop now and go check this project out. Smiley

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.