Monday, June 28, 2010

Nimbits as a Parallax Data Logger

This post will walk you through how to get a value from a Parallax Basic Stamp (BS2) micro-controller and feed it into the Nimbits Data Logger cloud using a bit of C#.

Your reading from any number of Parallax sensors can then be viewed in a Visio Diagram, Spreadsheet, and your Android Phone. You can even have alerts or current readings posted to your Facebook Wall.   Remember, your data is being fed up to the Google App Engine Cloud computing platform, so the data being fed up from your computer's USB port can be accessed from anywhere in the world.

If you're not familiar with Parallax Micro-controllers check out  http://www.parallax.com for some amazing sensors and robotics projects.

I'm not going into how to actually build a sensor. I'm assuming the audience here is already familiar with stamp programming.  The sample code I'm providing here shows the basics of pumping a value from a Parallax Board of Education out a the serial port which is then read by a .net client program running on the computer the stamp board is connected to.

When I tested out this tutorial, I had my old "Board of Education Development Board - Serial Version", connected to my Windows PC using a serial to USB converter.  Parallax also carries a USB BOE now as well.

I was also had a spare BASIC Samp 2 Module.

Step 1 Setup your Data Point

  • Log into app.nimbits.com directly or through Facebook by visiting apps.facebook.com/nimbits
  • Create a new Data Point by clicking the + symbol on the tree. 
  • Name the data point whatever you like. 
  • You can double click the point from here and configure it's settings. Set up a calculation you'd like it to execute, compression settings etc.


Step 2 Setup your stamp 


  • After setting up the hardware mentioned above. Download the Stamp Editor from Parallax's web site: http://www.parallax.com/tabid/441/Default.aspx
  • The COM Port my BOE is on was Com 3. Make a note of what port your stamp is actually on.
  • The .Net code i'm going to provide in Step 3 will receive any number coming up that port that your Stamp Module is sending as a DEBUG message. Here is a snippet of PBASIC code that will send a debug message with number 42 (my favorite number). For this demo, that's all i'm going to do - but that number can of course be a reading from any sensor code you have in place:
' {$STAMP BS2}
' {$PBASIC 2.5}

DO
DEBUG DEC 42
PAUSE 1000
LOOP
END

Step 3 Feed whatever value the Stamp is sending up to Nimbits

  • With this code tokenized to your stamp module, the stamp should now be sending the number 42 up the wire. The next step is to grab the reading and feed it up to the Nimbits Cloud
  • This code is very simple, it uses the Nimbits SDK to authenticate you to Google's infrastructure.
  • In Visual Studio 2008 or Higher, create a new C# Console Application project. 
  • Download the Nimbits SDK 
  • The NimbitsSDK is a .Net 3.5 assembly. Simply add it as a reference in your project.
  • The NimbitsSDK source code is also available on Google Code.
  • Add this code to your project. Change the PointName and PortName to your settings
  • Change the email and passwords that match the account you logged into Nimbits with.

using System.IO.Ports;
namespace TempProbe1
{
class Program
{
static SerialPort ComPort;
private static string PointName = "ParallaxPoint1";
private static string PortName = "COM3"; // Check device Manager for Port Number
private static NimbitsSDK.client SDK1 = new NimbitsSDK.client("example@gmail.com", "password");


static void Main(string[] args)
{


ComPort = new SerialPort(PortName, 9600);
ComPort.Parity = Parity.None;
ComPort.StopBits = StopBits.One;
ComPort.DataBits = 8;
ComPort.DataReceived += OnSerialDataReceived;
ComPort.Open();
while (true) { }


}
public static void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args)
{
string data = ComPort.ReadExisting();
double v = Double.Parse(data);
SDK1.RecordValue(PointName, v, new DateTime());
Console.WriteLine("Recorded a new value! " + v);


}


}
}

That's it! Your values are now being recorded on the Nimbits Data Logger cloud. Any connected spreadsheet and diagram will show the new readings. Also, if you add Nimbits to your Facebook by visiting http://apps.facebook.com/nimbits you can then configure your point to post new readings to your status. Facebook posts look like this:








Enjoy!

Sunday, June 27, 2010

Nimbits on Facebook

Nimbits is now the only data logging service that integrates with the Facebook Graph platform!  You can add Nimbits Data logging to your Facebook profile by following this link: http://apps.facebook.com/nimbits

When you log into app.nimbits.com you can go to a data points property page and either configure the point to post any newly recorded value to your Facebook wall or post alerts (when the value exceeds your high or low setting.  Of course, be careful. You will probably annoy your friends if you post second by second readings to your wall.

In order to use the Facebook functionality, you must add the Nimbits Facebook app to your profile. Just visit http://apps.facebook.com/nimbits   and allow Nimbits access to your profile. Just note that if you are also using Nimbits with your Google account, the Facebook email account you use must match. Nimbits matches your existing email with the Facebook account. Otherwise, Nimbits will register you as a new user under the Facebook email address it found.

Here is an example of a Facebook wall post when my temperature probe read in a new value







Enjoy!