Friday, July 16, 2010

[Data In] Connect Arduino to Nimbits Data Logger

It's very easy to have an Arduino device feed data up into the Nimbits Data Logger cloud. This is a fun and simple example where a push button that is wired to an Arduino board sends the fact that it was pressed to a listening .net program.  In this example, every time the push button (my house's doorbell) is pressed, a Nimbits data point gets updated and the event is broadcast on Twitter and Facebook.

This is a simple example to give a basic understanding of how to send output from an Arduino device to Nimbits Data Points.

Make sure you log into Nimbits and create a data point. In this example, my data point is called "doorbell".

Double click on the data point and edit it's properties from the menu on the top left. Here is where you can set  the point up to broadcast new values to twitter, facebook or to send you an IM. Make sure you use the menu items to enable these features on your account.

The Circuit

The circuit is right out of this tutorial on the Arduino Home Page:

The Arduino Code:

A small mod to the code on the sample page will wait until the button is pressed and released before sending the "Ding Dong" message up the serial (USB) connection.

int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
boolean pressed = false;

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input


void loop(){

val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
if (pressed)
//must have just been release
pressed = false;
Serial.println("Ding Dong");
digitalWrite(ledPin, LOW); // turn LED OFF
} else {
pressed = true;
digitalWrite(ledPin, HIGH); // turn LED ON

The Windows Program.

You can download Visual Studio 2008 Express to write this simple console application. Create your new project and add the NimbitsSDK as a refrence.  [Download the Nimbits SDK] [Source code]

The SDK simplifies logging in securely with your google account.

Now it's just a matter of running this code to monitor our com port. You'll need to add the credentials you used to log into nimbits, the target data point, and the com port your Arduino is on.:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
namespace NimbitsDoorBell
class Program
static SerialPort ComPort;
private static string PortName = "COM4"; // Check device Manager for Port Number
private static NimbitsSDK.client SDK1 = new NimbitsSDK.client("", "password");
private static String pointName = "doorbell";
private static int timesPressed = 0;

static void Main(string[] args)

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

public static void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args)
string data = ComPort.ReadLine();
Console.WriteLine( data);
timesPressed += 1;
SDK1.RecordValue(pointName, timesPressed, DateTime.Now, "Doorbell Rang");
Console.WriteLine("Ding Dong" + timesPressed);

That's it! Now every time the button is pressed nobody will be out of the loop!


  1. I have a BlackWidow 1.0 - arduino. Any tips/comments on interfacing nimbits to this module?

  2. Hi Sunny,

    I just ordered a networking shield for my Arduino Mega. As soon as it arrives i'll put out some sample code for pulling data from a networked device. It should work the same for a wireless black widow board. If you can get data from any arduino device onto a PC, you can use the .net and java code I posted on this blog to feed data into a Nimbits Data point. Thanks!

  3. Great! I appreciate the response! I am looking forward to it. Thanks.

  4. Hello,

    Can I use nimbits, if the data from arduino is more than 1.
    Thank you,

  5. Hi Gazibon,

    You can create a data point for each arduino data feed. So if you have an arduino sending a temperature and humidity reading into nimbits, you would create a data point for each one to record the values to. Hope that helps!