2010
03.07

I had written some time ago about the concept of PWM driven meters.  Here is a perfect application.

The Jeenode will poll the Jeelink occasionally for its meter value to display.  About once every 5-10 seconds should be sufficient.  Power consumption, though will vary considerably, as things turn on and off, is not that vital to warrant real time indication.

Now if my Jeelink would only arrive already… I can get to work on some of these things!

The enclosure for this project will be an Ikea Ribba 5×7″ picture frame, some steel grille from Lowes, an old meter from an AM radio station, and of course a Jeenode, battery holder, driver hardware and so forth.

Share on Facebook
2010
03.07

This is the basic concept of the Jeenode based Home Monitor / Control system.  Each Jeenode board will perform some sort of function, either autonomously or via command, or a combination of both.

For example:  A Jeenode will control an attic ventilation fan.  It will automatically decide to actuate the fans, based on temperature.  A default setpoint will be programmed within, however, the Jeelink can alter this temperature.  Also the Jeenode will report the temperature periodically, and report when it activates and deactivates the fan.

Share on Facebook
2010
03.06

Behold the graphy goodness…

Click To Embiggen / Get The Latest

I have wanted to, for a long time, display, graph, and control various aspects of the home environment.  Temperatures, status of appliances, lights, water heater, furnace, and so on.  Looks like this is finally becoming a reality.

Inspired by the work done at the OpenEnergyMonitor site, I adapted their code to make the above realtime graph of temperature.  I will add more as inspiration hits.

But the steps were basically this.

ARDUINO TEMPERATURE MONITOR:
A very simple Arduino temperature monitor and data reporter was constructed with a Duemilanove, Ethernet Shield and a Modern Circuits TMP-421 temperature sensor.  The code is very simple, with no error detection or correction (for now) {sensitive bits redacted}.

#include “Wire.h”
#include <LibTemperature.h>
#include <Ethernet.h>

//Sets the unique mac address for the ethernet board
byte mac[] = {0xDE,0xAD,0xBE,0xEF,0xFE,0xED};
byte ip[] = {192,168,2,51};
byte gateway[] = {192,168,2,1};
byte server[] = {—,—,—,—};

//Setup a client
Client client(server, 80);

LibTemperature temp = LibTemperature(0);

void setup()
{
Serial.begin(9600);

Ethernet.begin(mac, ip, gateway);
delay(1000);
}

void loop()
{
Serial.print(“Temp: “);
Serial.print(temp.GetTemperature());
Serial.println(” degC”);
delay(100);

//Send the data
if (client.connect())
{

//Accessing a shared server requires the server domain name in here as there
//is no fixed ip address.  If your accessing a shared server you need to add
//your URL “GET http://—–.—/xxxxxxx/????.pl?T=”

client.print(“GET http://—–.—/xxxxxxx/????.pl?T=”);
client.print(temp.GetTemperature());
client.println();
client.stop();
}
else
{
Serial.println(“Failed to connect to client”);
}
delay(10000);
}

PERL SCRIPT ON MY SERVER:
A rather simple perl script was added to my server.  This was rather tough as my server did not allow cgi-bin script execution out of the box.  I won’t go into what it took to get working, as your mileage will vary (sensitive bits have been redacted).  I’ll be spending some time with my perl book and construct an all encompasing, scalable, script that will allow me to write to any database table and field, at any time.  For now things are hard coded.

#!/usr/bin/perl -w
use CGI::Carp qw( fatalsToBrowser );

# PERL MODULES WE WILL BE USING

use Data::Dumper;
use CGI qw/:standard/;

use DBI;
use DBD::mysql;

# HTTP HEADER
print “Content-type: text/html \n\n”;
print header;

my $currentvalue = param(‘T’)    or die “Value1 not in parameter list”;

# CONFIG VARIABLES
$platform = “mysql”;
$database = “home_monitor”;
$host = “localhost”;
$port = “—-”;
$tablename = “DATA”;
$user = “—-_———–”;
$pw = “—-_———–”;

# DATA SOURCE NAME
$dsn = “dbi:$platform:$database:$host:$port”;

# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user, $pw) or die “Unable to connect: $DBI::errstr\n”;

$vtime = time()*1000;

# PREPARE THE QUERY
$query = “INSERT INTO DATA (TEMP_001, Time) VALUES ($currentvalue,$vtime)”;
$query_handle = $connect->prepare($query);

# EXECUTE THE QUERY
$query_handle->execute();

And finally, a PHP script to access the database and graph the results.  The graphic package in use is Flot, a very slick open source, MIT Licensed, library perfect for what we need to do.

Flot is a pure Javascript plotting library for jQuery. It produces graphical plots of arbitrary datasets on-the-fly client-side.

The focus is on simple usage (all settings are optional), attractive looks and interactive features like zooming and mouse tracking.

The plugin works with Internet Explorer 6/7/8, Firefox 2.x+, Safari 3.0+, Opera 9.5+ and Konqueror 4.x+ with the HTML canvas tag (the excanvas Javascript emulation helper is used for IE).

So, there you have it… I will be adding things in the days to come, trying different configurations, fixing up the perl script and tidying up the graphics.  I will couple this with the Jeenodes as outlined earlier, and adding the graphing functionality to whatever platform I use to aggregate the Jeenode data.  The possibilities are endless.

Share on Facebook
2010
03.03

I do development on several different computers, and always forget to sync the files. I’ve tried USB drives, and usually forget them, or again, forget to sync, or do a quick proof of concept on the local disk, and once again, forget to sync.

Fortunately for me I have VNC access to just about all of my computers, both home and work, but this is not an ideal situation. But its not a big deal to log in, grab the files, and get to work… then forget to sync it back to home (or work).

I discovered Dropbox, a free(ish) file syncing service. They offer 2GB free, and to be honest, I cant see using that much space for simple microcontroller development. Installation was painless, I simply work inside my Dropbox folder, even compiling, and all my computers are automagically synced.

I also have an account for work, to sync the two office PCs and a remote location PC with such things as purchase and work orders, quotes, etc.  I have invited my home account to the work folders, and vice versa.  So you can keep things distinctly separated, yet have access, with settable permissions (read or read/write).

I might investigate hosting something similar on my cloud server, but, even the 2GB is already 10% of my 20GB there.

Share on Facebook
2010
03.03

jee-b-gone



jee-b-gone
Originally uploaded by ka1kjz

I managed to successfully port the TV-B-Gone code to the Jeenode. It was not as straightforward as one might think. I reassigned the outputs to port 1 of the Jeenode, and the IR LED would not work. I could make the visible LED work, and I would see the IR port flash sporadically when I connected a visible LED to it. No amount of fiddling would make it work, until I delved into the sourcecode a little deeper.

The IR LED is driven from a PWM port, something that is not obvious. Now I know why Ken had assigned such odd looking numbers to his I/O.

I investigated moving the PWM code to another PWM pin, as pin-3 is taken by the Jeenode “IRQ” signal, but its not that easy. There is some pretty low level register manipulation going on, and that was something I really did not want to get into at this time.

I moved the IR LED to the Jeenode “IRQ” signal, which happens to be the original Arduino Pin 3. IRQ-0 is dedicated to the radio, which works out for me, as I plan to fire the TV-B-Gone code via radio. I had to remove the sleep function for the time being, but once I get the radio going, I will reincorporate it at that time.

Share on Facebook
2010
03.03

I realized that the TV-B-Gone code, at least as presented by Ken Sherriff, was running full speed, full power, all the time. The batteries certainly won’t last long in that state! So adding the sleep() function was necessary, and very easy.

Starting with the code on the Arduino site, I slowly, line by line, adapted the example code to the TV-B-Gone code. This necessitated moving the trigger button to IRQ 0, as IRQ 1 was taken by the IR PWM code.

Worked on the first try! I did not bother to measure the current consumption, my debug serialPrint() lines indicated the sleep code was executing, and the wakeup routine would execute when the button was pressed.

I simply added the include statement:

#include <avr/sleep.h>

And simply tacked the following line of code to the end of loop() :

sleepNow();

And finally, stuck the following function to the end of the source:

void sleepNow()
{
set_sleep_mode(TRIGGER);                    // sleep mode is set here

sleep_enable();                                       // enables the sleep bit in the mcucr register

attachInterrupt(0, wakeUpNow, LOW);       // use interrupt 0 (pin 2) and run function
// wakeUpNow when pin 2 gets LOW

sleep_mode();                                   // here the device is actually put to sleep!!
// THE PROGRAM CONTINUES FROM HERE ON WAKE

sleep_disable();                                // first thing after waking, disable sleep

detachInterrupt(0);                             // disables int 0 as the wakeupnow code will
// not be executed during normal runtime
}

void wakeUpNow()
{
// any needed wakeup code can be placed here
}

To prevent version skew, I leave addition of the sleep routines to the reader.  I’ve notified Ken for possible inclusion in version 2.  Now to port this to the Jeenode.

Share on Facebook
2010
02.27

Constructed this tonight…

Its an infra-red emitter, and visible LED operational indicator to implement the TV-Be-Gone code on the Jeenode.

I’ll be porting Ken’s code over to the Jeenode tomorrow and testing it.  All indications are it should work.

Share on Facebook
2010
02.26

Railfan Photos


waltham_outbound_t_station_022010

Originally uploaded by ka1kjz

Another test of the Flickr blog-this feature, now with more lines.  It would be nice if they would let me tag!  Perhaps the flickr tags translate over, I have not gotten into that habit over there yet.

Another facet of my many many hobbies is being a railfan. Though not as fanatical as some, who track train consists (the actual numbers of cars in a train, scary I know that term!), I am generally into the infrastructure of railroading. Stations, tracks, spurs to nowhere, old lines no longer extant, if they built it, I am interested.

This is the “outbound” (away from Boston, or west bound) T station in Waltham Massachusetts. Not alot to really see here, its a very small station, only 2 cars or so, where the smallest station on the Metro-North line in Connecticut is 4 cars, or roughly double this length.

I have other plans in Massachusetts this spring, so I hope to cover the T line more soon.

Share on Facebook
2010
02.26

jeenode_temp_control




jeenode_temp_control

Originally uploaded by ka1kjz

This post was sent from Flickr, just trying out the Blog This function. Lets see how badly it munges my blog! :)

Share on Facebook
2010
02.25

While poking around the various Arduino forums, I found some work by Ken Shirriff, a port of the TV-B-Gone code.  Stated simply, a TV-B-Gone runs through all the IR power codes, turning off (or on) most any television.

So couple the Jeenode with the Arduino TV-B-Gone code and the room monitor, turn off the TV after 2-3 hours of motion inactivity (no one in the room or they fell asleep!).

This code can also be used to turn ON the TV, as a security measure.  Add a sensor for current draw, and you will know if the TV is indeed on.

So… to the drawing board!

Share on Facebook