In the final couple of code club sessions we built a pulse rate monitor to show a practical application for the NetMF InterruptPort, and communication between threads using the Interlocked class (Increment & exchange). This was then enhanced to display the data locally and upload it to the cloud to illustrate a basic HTTP interaction and serial communications.
The application displays the approximate pulse rate in Beats Per Minute (BPM) on a 16×2 character LCD display and also uploads the information to a free developer account at Xively a “Public Cloud for the Internet of Things”.
The xively trial account has a limit of 25 calls a minute, rolling 3 minute average (Dec 2013) which was more than adequate for our application and many other educational projects.
The xively API supports managing products, managing devices, reading & writing data, reading & wiring metadata, querying historical data and searching for data feeds, using a RESTful approach.
The NetduinoPlus2 has full support for the NetMF system.http and sufficient memory so that there is plenty of room left for an application. If you are using a Netduino Plus (or other NetMF device with limited memory) an approach which reduces memory consumption is detailed here.
The xively data API supports JSON, XML and CSV formats for upload of data and for the pulse rate monitor we used CSV. The following code was called roughly every 20 seconds.
static void xivelyFeedUpdate( string ApiKey, string feedId, string channel, string value )
using (HttpWebRequest request = (HttpWebRequest)WebRequest.Create(xivelyApiBaseUrl+ feedId + ".csv"))
byte buffer = Encoding.UTF8.GetBytes(channel + "," + value);
request.Method = "PUT";
request.ContentLength = buffer.Length;
request.ContentType = "text/csv";
request.KeepAlive = false;
request.Timeout = 5000;
request.ReadWriteTimeout = 5000;
// request body
using (Stream stream = request.GetRequestStream())
stream.Write(buffer, 0, buffer.Length);
using (var response = (HttpWebResponse)request.GetResponse())
Debug.Print("HTTP Status:" + response.StatusCode + " : " + response.StatusDescription);
catch (Exception ex)
The pulse rate information can then displayed by xively in tables and graphs.
At the end of term presentation several parents and family members were doing press-ups and other exercises to see how high their pulse rate went and how quickly it recovered.
Bill of materials (Prices as at Dec 2013)