Pachube with LEGO™ MINDSTORMS™ NXT

Pachube(pronounced as “Patch bay”) is an on-line database service allowing people to connect sensor-derived data (such as energy and environmental data from objects, devices & buildings) to the Weband to build their own applications based on that data. In this post we show you how you can use the WIFI Module for LEGO™ MINDSTORMS™ NXT to become part of the internet of things.

Pachube connects people to devices, applications, LEGO™ MINDSTORMS™ NXT and the Internet of Things. As a web-based service built to manage the world’s real-time data, Pachube gives people the power to share, collaborate, and make use of information generated from the world around them. The site receives millions of datapoints every day from all sorts of projects and products.

Wait, the Internet of Things? Yes! As more and more devices become web-enabled, they will share more information and in the process, become smarter and more connected.

We have made a quick and easy example in RobotC that allows you to send information from your LEGO™ NXT in real-time: as soon as something happens, it is posted to the internet. This can be used for some really interesting projects:

Gather information: how does the temperature of your room vary over the day? How much energy is your computer using over the course of the day?

Monitor your home: how can you check if your lights are on while you’re at school or work?

After you have put the data up on the web, you can do some more interesting things, including make real-time charts, embed graphs of the data in your website, and send real-time alerts to other devices like a cell phone or Google Talk.

We’ve posted some RobotC code to get started below. The code is heavily commented so it should be easy to covert to other languages for your NXT. We have left our account information in the code to help you get started (it’s an experimental account); feel free to post some data to it as you like.

DIWIFI-Pachube.C

// Connect to Pachube!
//
// DIWIFI-Pachube posts information on the "Internet of Things" to Pachube information online.
//
// "Pachube ("patch-bay") connects people to devices, applications, and the Internet of Things.
// As a web-based service built to manage the world's real-time data, Pachube gives people
// the power to share, collaborate, and make use of information generated from the world
// around them." - http://pachube.com
//
// This program uses the HTTP client in the Dexter Industries DIWIFI sensor to send information to Pachube.
// We have left our account information on this example to provide a complete example. Post whatever you
// want to this channel, it's just meant to allow you to try the service out.
//
// To setup your own Pachube feed, just change the variables at the tope of the Pachube.h file, and change the
// API Key.
//
// See more about the Dexter Industries Wifi Sensor for the Lego Mindstorms NXT here: http://www.dexterindustries.com/wifi.html
//
// Run this program with the RobotC Debugging Stream On to view any errors.
// For more information visit http://www.dexterindustries.com/
// Dexter Industries, 2012. Feel free to use as you see the need to but give credit where credit is due.
//////////////////////////////////////////////////////////////////////////////////////////////////////
#include "drivers/common.h"
#include "DIWIFI-Pachube.h"
task main()
{
clear_read_buffer();
int CID = 0;
closeAllConns(); // Housekeeping: Close any open connections.
clear_read_buffer(); // Housekeeping: Clear out the buffer.
CID = start_TCP_client(); // We start the HTTP client here. Connect to Pachube.com, get a CID.
writeLineBreak();
Send_to_Pachube(CID); // This kicks off the meat of the project. This will send info to our
// Pachube account.
}

Related Posts:

First of all, awesome to seek a wifi week 2, and the stuff you guys have got in these week are just what I need for my own project.

Second, I am having a little bit of a problem with the code here when I copy and paste it to try it out.. It says “Undefined procedure ‘Receive’.” And it’s right–I don’t see a defined ‘Receive’ function anywhere in the code or in the driver.

Do you know if I am doing anything wrong? All I’ve done is copied and pasted the code and tried to compile