Archive for the ‘ Home Automation ’ Category

Since this project will collect data from many different sources such as data acquisition boards, pc computers, network systems, and weather station data, I’ve debated on building a centralized collection system or a distributed system. After prototyping a collection database and a windows service that would capture all of the data, I thought it may be better to build a distributed system instead.

What would a distributed collection system entail?

Here are some pieces of a distributed for a possible home-based data collection system:

  • Database for some config information as well as data measurement storage and retrieval
  • Web service for receiving all measurement updates
  • Windows service for collecting all analog measurement data from the LabJack ADC(s)
  • Scripts running on each computer be it the Mac OS, Windows XP, or Windows 7 for performance and capacity measurements.
  • Windows service to collect all data logging for weather, power, power and some event data.

Here are some of the pros of both a  centralized system and a distributed system:

Centralized System Pros:

  1. Simpler maintenance since all measurements are taken from one spot.
  2. Less complexity overall since there are fewer pieces overall.

Distributed System Pros:

  1. Easier to collect data from computers since rights are less of an issue when running locally.
  2. Each piece is far simpler since it’s only responsible for doing a few basic things.
  3. The system can grow as the different types of measurements grow without affecting existing measurements

I’ve continued to think about a centralized system since one giant windows service that gets all of it’s configuration data from the database would be far cooler and ultimately be more useable from install to install if I wanted to use this system elsewhere. This is nice, but as I was writing some prototype code for this service, it quickly got fairly complex and I hadn’t taken a single measurement.

I now believe that a distributed system might be easier for a the reasons listed above. I still plan on building a fairly healthy windows service to take the analog to digital measurements done primarily by the LabJack(s), but now can focus entirely on that process in the windows service. One issue that kept cropping up was how to handle delta-only measurements for state on a schedule. Another issue was how not incur a long timeout wait while the service tried to connect to a computer for WMI measurements every time the service ran since the computers would many times be off.

With a distributed system, the computer security and scheduling issues aren’t as much of a problem since the processes would only take measurements when the  computer was running. I would let the web service determine if the measures needed to be recorded or ignored.

Next Steps

  1. First, I will attempt to prototype a web service built in either PHP or ASP.Net, not sure yet. I’m very familiar with ASP.net web services but would like to try PHP.
  2. Second, I’ll hook the web service up to the MYSQL database I’ve prototyped. As soon as I’ve done this and proved I can record measurements from some simple scripts, I’ll put my code and schema out for anyone that cares to check it out.

Leave your Comment

So one of the things I would like to include in my Home Automation project is the ability to track performance and capacity metrics for all computers in the household. I would like to monitor PC information like hard drive capacity, free drive space, CPU utilization, current processes, maybe a list of installed software, etc.

Fortunately, all of these PCs run Windows XP so that helps considerably. I do have other devices on the local network, but that will be a topic for a later post. Since I know VB quite well and there are a LOT of examples on the web using it and Windows Management Instrumentation (WMI) to gather information on the Windows devices, I’ll use these two tools to do the bulk of this work. Also, I wanted to remotely gather this information and not have each PC contain scripts scheduled to run.

Here’s some information on my current setup:

  • All PCs are in the same Windows Workgroup

  • All PCs have the same accounts with similar passwords (1 account for logging in and one account for remote access)

  • All devices on the network are setup with DHCP for addressing

  • Some of the PCs have Windows Firewall enabled

Although XP is pretty open out of the box, there are a few things we need to do before we can successfully run WIM-based VB Scripts remotely:

Windows Security – We need to setup the windows account we’re going to use similarly across all PCs we intend to remotely access. This account should be in the Administrator’s group.

Windows Firewall – We must be able to remotely connect to a PC running Windows Firewall with WMI and VB Script. This will be done by configuring a secure WMI connection in Windows.

Guest User – In a Windows XP workgroup, all remote connections coming from the “network” will be authenticated as a Guest User. A Guest User has very few rights so we must determine how to configure Windows to recognize the account used by the remote connection.

Here are the last two configuration settings in further detail:

Windows Firewall Settings For A Secure WMI Connection –

On the remote computer, we need to grant DCOM (DCOM is basically a Microsoft technology for communicating among software components) remote launch and activation permissions for the user we setup earlier. There’s a good article about this on the MSDN site. There’s a utility  in Windows called DCOMCnfg.exe that’s found in Administrative Tools in Control Panel (you can run this from Start->Run if you prefer). If you open this utility up, it should look something like this:

image

Once this is open, right-click on “My Computer” and click on the “COM Security” tab. You should see something like this:

image

For both the “Access Permissions” and “Launch and Activation Permissions” we need to add the user we setup above to the names list in both and make sure all of the “Allow” settings are checked on both dialog boxes. Once this is done, Windows Firewall will allow remote WMI connections to this computer.

Guest User Settings for Remote WMI Connections –

This one was a little tough to find. I had been attempting to run some WMI commands (more on this later) against several PCs and getting Access Denied messages until I discovered this behavior in Windows – When a remote connection is made to a computer in a Windows Workgroup, the user will be authenticated using the “Guest User” account in Windows. This can be reset to use the connection’s credentials by changing a setting in the registry. If you don’t feel comfortable changing registry settings in Windows, don’t attempt this. The registry key is located at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa and is called “ForceGuest”. By default, this setting is set to 1 (Windows will try to log on using the “Guest” account). If this setting is changed to 0 (disabled), the connection will be logged on as the specified user.  Once this setting is set to 0, you should be able make remote WMI connections using you current account. Their is an article on Microsoft’s support site that walks you through setting this up.

I’ll be working through some VB Script WMI calls in later posts but here is a simple script to find all of the drives on the specified computer “Spartan”:

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

strComputer = "Spartan"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LogicalDisk Where DriveType = 3")

For Each objItem in colItems

    strDriveLetter = objItem.DeviceID

    Wscript.Echo("Found Drive " & strDriveLetter & " On Computer " & strComputer)

Next

After putting this stuff together and working with various scripts across a Windows Workgroup, I’m quite excited about what can be done with WMI and VBScript, but getting the security and configuration setup correctly was much more of a job that I originally thought it would be. A Windows Domain would make this far easier, but I really wanted to stay away from that kind of a setup for my household. I really do hope this helps anyone attempting else using WMI, VBScript and a Windows Workgroup.

I just received my LabJack U3, so I’ll be checking that out in an upcoming post along with more on current and temperature sensors.

Comments (1)

While waiting for my current and temperature sensors to arrive, I thought it might be a good time to look at a few devices for interfacing a computer to the real world. Basically we need something to convert the signals from our various sensors and transducers to the computer.

This is usually handled by a device called a analog to digital converter or ADC. There are MANY different types of ADCs used for converting all kinds of signals to the digital world. The differences and choices could fill a whole set of books, but for our discussion, I’ll try to keep it short.

There are a lot of choices in the home automation arena that provide this function as well, but I really wanted a more flexible solution that I could build on and that didn’t tie me into a specific solution.

A few things we need to concern ourselves with when choosing the correct ADC are resolution, input levels, and sample frequency, and input voltage range.

Resolution

– Basically the number of levels representing the input signal range (in volts). The number of levels are measured in bits. Since it’s a binary scale, the different input resolutions are 8, 10, 12, 14, 16, 24, etc. An 8 bit ADC, would provide 256 different levels and a 24 bit ADC would provide 2^24 or 16,777,216 levels! Generally the higher the resolution, the more expensive the ADC, so we need to find a ADC that will provide enough discrete levels for our needs.

Number of Inputs

– For each sensor we want to use, we will need one input (for now I’m not going to cover single-ended or differential inputs). Again, prices go up with more inputs, so for now, I’m looking for a cheap low-count input ADC.

Input voltage range

– This is simply the maximum voltage the ADC will accept. A higher number here doesn’t mean a better ADC, you just need to determine what input voltage range suits your purposes and find a ADC that fits that range.

There are a ton of other properties when discussing ADCs, but not here, not now. If your interested in more details about ADC, check this Wikipedia article out.

Okay, so after fully reading the Wikipedia article you probably know more about ADCs than me. But suffice to say, I still need to determine what type of resolution I need. Let’s start with an 8 bit ADC.

For 8 bits and lets say a voltage range of 0-5 volts, that would be 5V divided by 256 levels or  .02 volts per level. Also, let’s say we need to measure a temperature sensor that provides a voltage range between 0 and 5 volts for a temperature range of 256°F (-40 to 216°F to make the math easier). That would give a maximum temperature resolution of 256°/256 levels or 1° per level. This is under perfect conditions and generally I would expect to lose half that resolution for all kinds of reasons I’m not going explain here. That means the smallest temperature change we could detect is 2°F

I think we can do better than that. Let’s see what a 12 bit ADC can give us for a resolution? For 12 bits we get 4,096 levels! From the math (256°F/4,096 levels) we get a maximum resolution of .06°F per bit. Even half of that is around .1°F. That seems more reasonable and I think I’ll stick with that. So now that we’ve chosen 12 bits as guide, lets find a few ADCs that will work for the needs of this project.

12 Bit Analog to Digital Converters:

  • MeasurementComputing – These guys handle all kinds of test and measurement equipment, but for out purposes, I found this little gem (miniLab 1008) that isn’t too expensive ($129.00). It has 8 single-ended or 4 differential analog 12 bit inputs.

  • DataQ Intsturments – Again, another company that carries many types of measurement and testing equipment. They also have a similar 12 bit ADC with 4 differential inputs (DI-158U). Currently it’s listed at $99.00.

DI-158U USB Data Acquisition Starter Kit

 

  • Labjack – Looks like a smaller company that really focuses on AD conversion. Their products even look cool. The one that seems to work for this project is the U3-LV pictured here at $108.00

image 

I’m not sure which one these I’ll be getting to prototype some sensor measurement, but I’ll be making a decision fairly soon. If anyone would like to comment on these or similar ADCs I would really appreciate it.

Comments (2)

I’ve researched what type of cheap current and temperature sensors I would like to prototype for my project and decided upon the following:

1. An NTC Type Thermistor from Cantherm (CWF1B104J3950) that provides relatively high precision, reliability, and response time. This type of sensor also allows for a fairly simple conditioning circuit.

2. An Integrated-circuit precision temperature sensor (LM34) from National Semiconductor. This sensor provides a very linear output (+10mv/°F scale) at a very low cost. The problem with the IC type sensor is that it requires a more complicated power supply if you wish to measure temperatures around or below 0° Fahrenheit. I’m prototyping these since I already have a decent supply of them.

3. The CR Magnetics’ CR8410 current-sensing transformer. This a relatively cheap current transformer that is capable of measuring up to 20 amps. You need to take precautions when using this type of device since there is a potential to create high voltages when reading house current so if you aren’t sure, get someone who is experienced with these.

These parts were ordered from Digikey. I use both Jameco and Digikey when buying electronic components and I’ve always had good results with both companies.

Also, some thanks to the people over at All About Circuits, I wasn’t sure on the transformers and they were there to help me out.

When they arrive, I’ll set these components up to do some initial testing and evaluation. In the meantime, I’ll start some initial work on the Computer measurements I discussed earlier as well as a solution for converting the conditioned signals from the current and temperature sensors to a digital signal a computer can understand.

Comments (3)

Okay, I thought maybe we would build on the last post and try to explore just what we could measure in the house after covering the various properties. A walk around the house provided many ideas…Some maybe not so easy to measure, but at least a starting point.

I listed the possibilities in various groups that made the most sense. I would also like to cover events, but that’s another post I think. After compiling this list I was struck at just how many things could possibly be measured.

Temperatures

  1. Outside
  2. Garage
  3. Pool
  4. Main Floor
  5. Upper Floor
  6. Basement
  7. Furnace Intake
  8. Furnace Plenum
  9. Furnace Exhaust
  10. AC Compressor Line
  11. AC Evaporator
  12. Ground Water
  13. Water Heater Exhaust
  14. Water Heater
  15. Refrigerator
  16. Freezer
  17. Dryer Temp
  18. Dishwasher

Flows

  1. Furnace Air
  2. Supply Water
  3. Ice Maker Water
  4. Water Heater
  5. Dryer Air

Electrical Current

  1. Main
  2. Circuits
  3. Dryer
  4. Furnace
  5. Washer
  6. Dish Washer
  7. Refrigerator
  8. Freezer
  9. Water Heater
  10. Water Pump

Voltage

  1. Main

Light

  1. Exterior
  2. Main Floor
  3. Basement
  4. Upper Floor
  5. Garage

House Water

  1. Ph
  2. Conductivity

Weather

  1. Wind Speed
  2. Wind Direction
  3. Humidity
  4. Rain
  5. Barometric Pressure
  6. UV Radiation Level

Liquid Levels

  1. Pool
  2. Softener

Acoustic Levels

  1. Outside
  2. Garage
  3. Main Floor
  4. Basement
  5. Upper Floor
  6. Mechanical Room

Computers

  1. Count
  2. Disk Count
  3. Disk Space
  4. Disk Free Space
  5. Total Memory
  6. Free Memory
  7. CPU Utilization
  8. Number Of IP Devices

Leave your Comment

I started thinking that maybe I should cover some terms and definitions about sensing and measurement for this project before getting too deep into it.

First off, the words sensor and transducer are both widely used when referring to the measurement of physical phenomena and properties. Generally, the transducer is the component measuring the input energy or physical property, and the sensor contains the transducer as well as any circuitry required to convert the measurement into a usable electrical signal.

Here’s a small diagram of what makes up a sensor:


Let’s list out some of the different physical properties that we cold potentially measure:

1) Flow of liquids or gases
2) Levels of solid or liquid
3) Direction of flow for gases or liquids
4) Relative amount of liquid in a gas (humidity)
5) Amount of light striking a surface
6) Ph / Conductivity
7) Temperature
8) Acoustic (magnitude, spectrum)
9) Pressure / Strain / Force
10) Electrical (current, potential, and field properties)
11) Magnetic

Now I realize some of these do not seem extremely applicable to a home environment, but I would rather not limit myself just yet.

Next, we’ll list out some potential measurement possibilities around the household.

Leave your Comment

To be honest, this project will be done on a limited budget, using some existing equipment and building some of my own sensors. I have no budget for the big names in home automation (HA) and I’m mainly focused on things that aren’t your traditional HA components.

Since I’ve been a Microsoft developer for a great many years, any software used – written or not will be based primarily on MS tools.

Here are the main parts to the stated project:

1) A Graphical User Interface (GUI) – to display and allow a person to navigate through the various views of sensory data from throughout the home.

2) A Collector System (CS) – allowing various sensors and transducers report in via a push or pull process that is loosely coupled to the devices.

3) Configuration Database (CD) – that will tie Targets (items of interest such as a refrigerator, furnace, or swimming pool) to Measures (metrics like temperature, air-flow, electrical current, or humidity for example) and also allow thresholds and alarms to be tied to these combinations.

4) Event System (ES) – Will produce events based on event rules, targets, measures, and thresholds.

5) Data Warehouse (DW) – For storing measurement data for trend statistical analysis.

So, the key parts are a GUI, a Collector System, a Configuration Database, Eventing System, and Data Warehouse.

Next, I will try to formulate this into some type of project statement and a diagram of how the main components of the system.

Leave your Comment

Devoted to building on a specific area of home technology.

I’ve dug into home automation but was never satisfied with the interfaces, usability, or reliability of the systems. One thing I did notice though was the innate desire people had to understand what was already happening in their home / environment…From the mechanical systems, utilities, environmental situations both inside and out.

With an education in Electrical Engineering and a career involving transducers and sensing, micro controllers, databases, data warehousing, high-speed data acquisition, user-interface design, and web application development, I thought I would be in an excellent position to attempt a full-blown home-sensing project (I’ll give it a better name later). Maybe it will span multiple projects; I’m not sure just yet.

We’ll start next time with an initial project definition, technologies involved, and project scope definition.

Leave your Comment