With more and more embedded devices "smart" in the world, begins to take on an increasingly important concept of the Internet of Things (IoT), a neologism by which you want to express the capacity that these devices (brutally "things") in order to connect to the world wide web and exchange information. In this come into play a number of online platforms that provide the service to upload and logging information in real-time making it available to other devices that request them. The architecture is oriented such that the platform is obviously RESTful where the data grouped into channels and feeds are accessible through the concept of URL.

One of the main platforms is certainly ThingSpeak, for which I have implemented a client for. NET Micro Framework and I have included in my library uPLibrary (now at version present on CodePlex, namespace uPLibrary.IoT.ThingSpeak.



The main class is ThingSpeakClient, which provides the only method Update(string writeApiKey, Data Entry Data Entry) to upload a data entry in its data channel that we created on the site ThingSpeak. The data entry is represented by the same name DataEntry class that allows you to specify values ​​for the fields in the feed of the channel, a status message, the location (latitude, longitude and height) and a Twitter account with its message from "tweeting" loading the data online.

Regarding the reading of data, are several methods available for read ie ReadFeeds (), ReadLastFeedEntry (), Readfield () and ReadLastFieldEntry () that provide a wide choice and respectively for an entire feed (all fields), last entry of a feed (all fields), all values ​​of a field in the channel and finally the last entry of a specific field in the channel. Each of them returns a collection of DataEntry with the information read from the server online.

There is also the method ReadStatusUpdate() to read the latest update channel status.
An application example is trivial, imagine having to upload online any physical quantity measured (eg temperature, pressure, humidity, ...) the sample code may be as follows.


   1: public static void Main()
   2: {
   3:     ThingSpeakClient client = new ThingSpeakClient(false);
   5:     var data;
   6:     DataEntry dataEntry = new DataEntry();
   7:     while (true)
   8:     {
   9:         // rilevamento del dato
  10:         // data = ....
  11:         dataEntry.Fields[0] = data.ToString();
  12:         client.Update("writeApiKey", dataEntry);
  14:         Thread.Sleep(15000);
  15:     }
  17: }

Equally simple can be considered an example of reading the data from the server.

   1: public static void Main()
   2: {
   3:     while (true)
   4:     {
   5:         ArrayList dataEntries = client.ReadLastFieldEntry(null, 
   6:                                             <channeId>, <fieldId>);
   8:         // consumo di data entries...
  10:         Thread.Sleep(15000);
  11:     }
  12: }
In short, thanks to a free membership on ThingSpeak and using my client, you will have the opportunity to share online all data read from the sensors of your prototypes, perhaps made with Netduino!

Obviously, the whole is provided on Codeplex and has also been updated in Nuget Gallery !