Showing posts with label HOWTO. Show all posts
Showing posts with label HOWTO. Show all posts

Friday, July 30, 2010

Teaser: XBee Wireless Temperature Sensor

XBee wireless temperature sensor

Above: XB24-ZB with four TMP36 analog temperature sensors connected to XBee's analog inputs.

The reason four sensors are connected is: comparison and statistical analysis.

It remains to be seen how good or bad analog readings are, and how easy it is to compensate for these imperfections in software.

Credit

This design is based on a similar one, with a few minor differences:
  • TMP36 is used instead of LM34 (the only reason being that I had some spares laying around). Obviously, the result calculation is different. Wide selection of similar sensors (TMP35, TMP37, LM35), result would be just about the same, save for value recalculation;
  • Incidentally, this allowed to get rid of the voltage regulator because whereas LM34 requires +5V to +30V power, TMP36 is fine from +2.7V to +5.5V, hence, the same 3.3V power can be used to feed both XBee and TMP36;
  • Caveat is, at +70°C TMP36 output voltage reaches maximum allowable voltage for ZB series ADC, 1.2V. I don't think it's a problem because the intended usage is indoor temperature measurement, if your indoor temperature reaches +70°C, you'll have bigger problems to worry than a possibly damaged XBee. But keep this in mind if you're planning to use these sensors to monitor a temperature of, say, a water heater or air coming out from the furnace;
  • 330Ohm resistor added to ASSOC LED to restrict the LED's operating current (might want to use 1K and higher if your LED is too bright for you).

More to come.

Thursday, July 29, 2010

DZ XBee HOWTO


Now that XBee is supported, let's see how to make it work.

Bill of Materials

I would highly recommend to buy an extra XBee radio and an adapter if you have never worked with XBees before - it'll save you a lot of grief because you'll be able to monitor the network status activity. You see, the relay shield doesn't come with network status and activity lights, so unfortunately, you'll be flying blind and will have to re-plug XBee modules into adapter every time you're not sure what is going on.

Hence, recommended quantities are - three XBee modules, two adapters and one relay shield (add extra XBee module + relay shield pairs if you have more than one HVAC unit, one pair per unit) - starting at $110.80 before shipping.

Minimum quantities - two XBee modules, one adapter and one relay shield ($73.90 before shipping).
Before you say that's expensive, think how much you will spend breaking walls to wire cables, then patching them back, texturing and painting. Not even talking about time spent on all that exciting work.
Keep in mind that some suppliers have high lead times - I've seen as high as two weeks.

Power

Note that the power supply is not included into the bill of materials. The relay shield requires 9V DC power - you either might have one handy already, buy a cheap one wherever you fancy, or just use a 9V battery (the relay shield has screw on contacts for that). I don't know yet how long the relay shield is going to last on a battery with normal HVAC usage pattern, will find out and report.

Setup

Countless XBee tutorials exist, so I'm going to skip this part - suffice to say, get your XBees lined up and talking to each other.

DZ specific XBee setup

You need to flash one XBee module (the one on the adapter) with the Coordinator API firmware (when you get familiar with X-CTU software, this will become self-explanatory). Make sure you read the module configuration and flash correct firmware. After you flash API firmware, it won't be possible to use a dumb terminal to control the XBee anymore (limitation of ZB series), so make sure you're done with setting up communications correctly before you do that - like I said, extra XBee and an adapter will help a lot from here on.
IMPORTANT: Make sure you set AP=2 and write changes. The reason for this is that xbee-api library used for low level communications doesn't work with AP=1, and fails to report when AP=1, or forcibly change the module state to AP=2.

Baud Rates

Don't bother changing the port speed from default 9600 baud. DZ is more than happy with that speed, but if you change it, you might run into trouble remembering what it is next time you try to connect to XBee via an adapter.

DZ Configuration

XBee devices are configured in exactly the same way as 1-Wire devices: using a device factory. Here's a snippet that will produce a working switch (0013A200.4062AC98 is the 64 bit hardware address of my XBee module plugged into the relay shield, substitute it with yours):
<bean id="device_factory"
class="net.sf.dz3.device.sensor.impl.xbee.XBeeDeviceFactory"
init-method="start">
<constructor-arg index="0" value="/dev/ttyUSB0"/>
</bean>
<bean id="switch_0013A200.4062AC98_0"
factory-bean="device_factory"
factory-method="getSwitch">
<constructor-arg value="0013A200.4062AC98:D0"/>
</bean>
There are four channels on the relay board used. Channel numbers are printed on the silk screen (look at the data sheet if in doubt).
NOTE: Relays are marked COM1 to COM4, but channels to access them correspond to actual XBee channels - D0 to D3. This is done so that all XBee digital outputs can be controlled - D0 to D8, and P0 to P3.

Congratulations, you're done

From here on, things are just as usual - use the reference to switch_0013A200.4062AC98_0 as you would have with a 1-Wire based device.

UPDATE: Adjusted description to match the improved channel addressing.

UPDATE: This article describes the switch setup, see the Teaser: XBee Wireless Temperature Sensor for information about sensor setup.

Wednesday, December 16, 2009

DZ3 Configuration Walkthrough

Beware: this is an experiment, and work in progress (I'm writing the presentation as you're reading it). Just following the "release early, release often" policy to maximize the chance of getting useful feedback in time.



UPDATE: Restriction on minimal font size in your browser will affect the presentation view in the small window - maximizing it will fix the issue.

UPDATE: Permanent location for the configuration guide (this one and subsequent): http://www.homeclimatecontrol.com/configuration-guide

Wednesday, October 28, 2009

DZ3 Configuration, Part 1

This is a simplified representation of how things are connected in DZ3:

DZ3 Data Flow, simplified

Every entity can act as a signal producer, and as a signal consumer. Exceptions are temperature sensors that can only be producers, and dampers that can only be consumers (unless there's instrumentation feedback).

Temperature Sensor

  • Consumes nothing
  • Produces Temperature
Thermostat
  • Consumes Temperature
  • Produces Zone Demand
  • Has 1:1 relation with the Damper
Zone Controller
  • Consumes Zone Demand
  • Produces Total Demand
HVAC Unit
  • Consumes Total Demand
  • Produces Running
Damper Controller
  • Consumes Zone Demand, Running
  • Produces Damper Position
  • Has to be aware about Thermostat:Damper relations
Damper
  • Consumes Damper Position
  • Produces nothing
  • Has a 1:1 relation with the Thermostat
Data Logger
  • Consumes everything
HOW TO PUT IT ALL TOGETHER

At this moment, the DZ3 container is based upon Spring Framework. If you are familiar with Spring, then a quick look at the sample configuration will tell you everything you need to know (provided you're somewhat familiar with the the code base).

If not, stay tuned.

UPDATE: Configuration Guide is now available.

DZ3 Runner

Release early, release often

-- ESR

There is no established place for shell components of DZ3 yet, so, for lack of a better place, here's a script that will run a valid DZ3 code base that you've just built on any Unix system (watch long lines):

#! /bin/sh

LIBDIR=${HOME}/.m2/repository

COMMONS_LOGGING=${LIBDIR}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
LOG4J=${LIBDIR}/log4j/log4j/1.2.15/log4j-1.2.15.jar
SPRING=${LIBDIR}/org/springframework/spring/2.5.6/spring-2.5.6.jar

DZ=${LIBDIR}/net/sf/dz3
DZ_VERSION=3.0

JUKEBOX=${LIBDIR}/net/sf/jukebox
JUKEBOX_VERSION=6.0-RC2

# Reverse order, so inheriting classes have a priority (good for configuration)

export CLASSPATH="./${your_configuration_directory}:\
${DZ}/dz3-model/${DZ_VERSION}/dz3-model-${DZ_VERSION}.jar:\
${DZ}/dz3-common/${DZ_VERSION}/dz3-common-${DZ_VERSION}.jar:\
${DZ}/dz3-sensors/${DZ_VERSION}/dz3-sensors-${DZ_VERSION}.jar:\
${DZ}/dz3-spring/${DZ_VERSION}/dz3-spring-${DZ_VERSION}.jar:\
${JUKEBOX}/jukebox-common/${JUKEBOX_VERSION}/jukebox-common-${JUKEBOX_VERSION}.jar:\
${JUKEBOX}/jukebox-datastream/${JUKEBOX_VERSION}/jukebox-datastream-${JUKEBOX_VERSION}.jar:\
${JUKEBOX}/jukebox-jmx/${JUKEBOX_VERSION}/jukebox-jmx-${JUKEBOX_VERSION}.jar:\
${JUKEBOX}/jukebox-sem/${JUKEBOX_VERSION}/jukebox-sem-${JUKEBOX_VERSION}.jar:\
${JUKEBOX}/jukebox-service/${JUKEBOX_VERSION}/jukebox-service-${JUKEBOX_VERSION}.jar:\
${COMMONS_LOGGING}:\
${LOG4J}:\
${SPRING}"

#echo $CLASSPATH

# Remember that arguments on the command line are relative to the root of CLASSPATH
# -Dcom.sun.management.jmxremote is needed to allow accessing DZ with JMX management tools
$JAVA_HOME/bin/java \
-Dcom.sun.management.jmxremote \
-cp $CLASSPATH \
net.sf.dz3.runtime.Container $*

COMING UP

Runtime configuration

DZ3 Quickstart

(This post is sticky, will be updated as DZ3 codebase grows, and will eventually be migrated to the main site when DZ3 is sufficiently mature)

Below is what you have to do to have DZ3 code base installed on your system. It goes without saying that having a working installation of JDK 1.6 is a prerequisite. I distrust any implementation other than Sun's, but it's been many years since I've tried anything else, YMMV. (Update: found an article describing how to install Sun Java on Ubuntu).

You may want to copy and paste it into a shell scropt and see what happens when you run it. Watch long lines.

NOTE: You need to have Google Calendar dependencies on file system in order to build everything. Either follow simple instructions, or remove or comment out the dz3-schedule-gcal module from dz3-master/pom.xml.

Fedora 10+

#! /bin/sh

yum install maven2
yum install svn
cd ${
your_development_directory}
svn co \
https://jukebox4.svn.sourceforge.net/svnroot/jukebox4/trunk/jukebox-master \
jukebox-master
(cd jukebox-master && mvn install)
svn co \
https://servomaster.svn.sourceforge.net/svnroot/servomaster/trunk/servomaster-common \
servomaster-common
(cd servomaster-common && mvn install)
svn co \
https://diy-zoning.svn.sourceforge.net/svnroot/diy-zoning/trunk/dz3-master \
dz3-master
cd dz3-master
# This test will most probably fail on your box because it is system specific
rm dz3-sensors/src/test/java/net/sf/dz3/device/sensor/impl/ShellSensorTest.java
mvn install


You're done. DZ3 codebase is installed on your box.
NOTE: installed. In order to connect servo controller based actuators you will also need to build servomaster-serial or servomaster-usb (depending on your hardware) which need to be checked out and built separately - but this is beyond the "quickstart".

Ubuntu 9.04

The only difference with the above is that instead of executing
yum install maven2
yum install svn
you execute
sudo apt-get install maven2
sudo apt-get install subversion

Mac OS X

(to the best of my understanding of explanations of a Mac expert):
  1. Install Development packet, it'll give you Subversion, among other things
  2. Install macports
  3. Run "port install maven2"
The rest should work like it does on Unix (theoretically, at least).

Update: I'm told that both Maven and Subversion are preinstalled on Mac OS X starting with version 10.5.

Windows

You're on your own here. The only advice I can give is to use TortoiseSVN and download and install Maven manually. And of course, shell scripts won't work - unless you're running Cygwin, but if that's the case, then you don't need my advice.

UPDATING CODE BASE

The only thing you have to do is to execute svn update followed by mvn clean install in jukebox-master and dz3-master directories. Don't forget to kill the shell sensor test case, or modify it to suit your system - should be trivial. Something like this:

#! /bin/sh

cd ${your_development_directory}
(cd jukebox-master && svn update && mvn clean install)
cd dz3-master
svn update
rm dz3-sensors/src/test/java/net/sf/dz3/device/sensor/impl/ShellSensorTest.java
mvn clean install

COMING UP

DZ3 invocation and runtime configuration.