Thursday, February 25, 2010

Create a Visio Diagram with Nimbits Data

In this Blog Posting:  Connecting Spreadsheets to Nimbits  I show you how to pull values you are feeing into Nimbits Data Points into an Excel Spreadsheet where you can then create charts, do calcs or any excel function on your current values.

You can very simply take this a step further by including spreadsheet data in a Visio Diagram.  I'm doing this with Visio 2007 Pro - i believe you need a Pro edition of Visio to import data.

Simply Launch Visio 2007 and Create a new Drawing. Select the Data Menu and choose "Link Shapes To Data." Then choose to link to the Microsoft Excel Workbook that you previously set up to use your Nimbits data

Follow the menus to select the rows and columns you are interested in in your workbook. These can be the cells pulling your nimbits data or any other cells that may be performing functions with your data.

You should then have a a screen similar to this. This shows my temp probe:




Now, let's put the value in a shape.  Put any shape you like on the diagram - i'm going to use a thermometer shape. You can then just drag the value you want to assign to your shape onto the graphic, and format it any way you like.  



That's it! You can now create very complex diagrams that will show your changing nimbits data point values


You can read more about Visio and Excel integration here: http://msdn.microsoft.com/en-us/library/aa701255.aspx

Saturday, February 13, 2010

Connecting a Temp Probe to Nimbits

Nimbits is a free Data Historian / Data Logger that allows you to store Time Series data on Google's Infrastructure and Connected to your Google Account.  Learn more at www.nimbits.com

In a previous blog posting  I connect a  Sensetronics Model F Temperature probe to the Nimbits Cloud using pure JAVA and a linux system.  In this posting, i'm going to accomplish the same thing except we're going to do it with a simple .net class and the Nimbits SDK. This is much easier and will run on any Windows Desktop.

When you're done, check out this post on how to automatically post your temp reading to your Facebook wall. 

The end result here is a program that runs on a Windows PC with a Temp Probe attached to a USB port and you'll be able to see changing temperature on your Android Phone Running the Nimbits Data Logger App, Connected Excel Spreadsheets or anything else connected to Nimbits.

This is a good tutorial for using the NimbitsSDK and you should be able to use this as an example for interfacing any device on a COM Port to Nimbits.  The SDK really simplified authenticating to Google and recording your data with just a couple of lines of code.

You can also just download this Visual Studio Project here: TempProbe1.zip


If you're not a programmer, you can download a free client program here that will interface with your Temp Probe to Nimbits and feed the result up to the cloud for you.   Just download the zip file below and run Setup.exe. This will install the client in your program files directory. You can then run the program from the command like like this:


TempProbe.exe /port=COM3 /email=example@gmail.com /password=password /point=FProbe1


The parameters provided above will connect you to Nimbits and begin recording temp readings into the point you provided.  Make sure you log into Nimbits first and create the target point. 

Download TempProbe.zip




What you need
If your computer doesn't have a serial port, you'll need a Serial to USB Converter.

Step 1

Log into Nimbits by visiting www.nimbits.com and launch the Nimbits Portal. Login with your Google Account and follow the instructions to create a new Data Point. In this example, i'm creating a point called FProbe1. It's important that you do this first. 

Launch Visual Studio and Create a new C# Console Application Project. Right click on the project and select to add a reference. Add a reference to NimbitsSDK.dll that you downloaded from the link above.

Step 2. 

Add this code to your project. You'll want to update the name of your data point, and your Google username and password.  Run the program and you should start to see a Fahrenheit reading that will be sent into Nimbits. You'll be able to see these changes on your Android Phone or anywhere else!  You can also use Nimbits to get email alerts if your temp goes out of range, or perform automatic calculations using the readings (for example, you can calculate a dew point or convert your temp to Celsius)

This Code simply creates an instance of the SDK with your Google login, Opens the Com Port, writes a single character to the probe which triggers a reading, and records the result to your Nimbits data point.

Code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading;

namespace TempProbe1
{
class Program
{
static SerialPort ComPort;
private static string PointName = "FProbe1";
private static string PortName = "COM3"; // Check device Manager for Port Number

private static NimbitsSDK.client SDK1 = new NimbitsSDK.client("example@gmail.com", "secretpassword");


static void Main(string[] args)
{

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

while (true)
{
ComPort.Write("A");
Thread.Sleep(10000); //10 Second Readings
}

}

//The Device puts out three lines, we're only interested in the temp result
public static void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args)
{


string data = ComPort.ReadLine();
string result = data.Substring(0,data.IndexOf("\r")).Trim();
Double value = 0.0;

if (! result.Equals("Bat Ok") && ! result.Equals("-99.9"))
{
value = Double.Parse(result);
SDK1.RecordValue(PointName, value, DateTime.Now);

Console.WriteLine(value);
}
}

}
}