Blog entries tagged with "home automation"

Naming devices under Linux

Thursday, November 28th, 2013 at 8:49 pm

When I recently started monitoring temperature it involved a USB to RS-232 adapter connected to my Linux box. A few weeks later I plugged in a USB device to monitor power usage.

Temperature was via /dev/ttyUSB0 and power was via /dev/ttyUSB1. Until an unscheduled reboot at which point they swapped around as that was the order the devices are detected at boot, not the order in which they were plugged in.

A quick search led me to discover that you can write rules for udev to give devices persistent names.

Relying heaving on Writing udev rules I muddled through to these rules:

SUBSYSTEM=="tty", ATTRS{product}=="USB2.0-Serial", SYMLINK+="digitemp"
SUBSYSTEM=="tty", ATTRS{product}=="RFA-Z106*", SYMLINK+="raven"

The generic RS-232 adapter now comes up under /dev/digitemp and the Raven comes up under /dev/raven. Now my monitoring will survive a reboot.

Tagged with: , ,

Monitoring power

Tuesday, November 26th, 2013 at 9:18 pm

While some people are heavily against smart meters, I am not concerned. In fact when I received the initial notification about the installation my first thought was about the possibility of playing with new technology.

When they finally installed the meter it coincided with a co-worker getting solar panels installed which led to a number of conversations about ways to monitor power generation and consumption. Based upon previous research I had done I knew that other people in Melbourne had had success with Rainforest Automation devices which use the ZigBee Smart Energy wireless protocol to connect to the smart meter.

My co-worker opted for the EAGLE as his solar panels also connected over ethernet, while I opted for the (cheaper) RAVEn which is a USB dongle.

Once the devices arrived I had to wait a few more days until my smart meter was completely setup, but then it was a simple matter of entering the address and install code from the RAVEn into the online portal for the smart meter. After a quick test with the windows app, I plugged it into my Linux box to see it come up as a serial port.

It was nice to simply run cat /dev/ttyUSB1 and see it output an XML fragment reporting the instantaneous demand every few seconds.

The documentation for the XML API showed me how to send commands and how to convert the hex values to decimal and how to apply the multiplier and divisor. It didn’t take long to wrap this in a script to be called by MRTG:

Events visible in this sample include:

  • Hot water turning on at 11PM AEST and topping up a couple of times
  • Fan and light while getting ready for work
  • Fridge cycling on during the day
  • Use of oven to cook dinner
  • Lights and other usage when I am at home

Due to complications with having off-peak electric hot water (aka a ‘controlled load’) I do not get summation values, instead that is just a graph of the instantaneous load. So while it doesn’t give true usage, it is a good enough indicator.

Currently this graph is available to anyone who knows the URL, and while it can let someone determine when I am or am not at home, the easier way to do that would be to go into my backyard and look through a window.

Tagged with:

Monitoring temperature

Monday, November 25th, 2013 at 8:24 pm

Ten years ago I purchased a couple of DS18S20 1-Wire temperature sensors to monitor the outdoor temperature, the ambient room temperature and the temperature inside my computers. Along with the sensors themselves I got a RS-232 to 1-Wire adapter and a DS1820 mounted on a demo board.

While I did connect them up and used DigiTemp to prove that the adapter and sensors worked. I didn’t get much further, until two months ago when I decided it was about time to do something related to home automation, the result being this:

USB to RS-232 to 1-Wire to DS1820

producing this:

After a failed attempt at using an old serial port header to connect the RS-232 adapter I splurged on an entire $6 to get a bright pink USB to RS-232 adapter. The remainder of the hardware pictured is the DS9097U-009 adapter and the demp DS1820 mounted at the end of an RJ11 cable.

The software side consists of the digitemp package, a wrapper to pull the temperature from the digitemp output, and my existing MRTG setup.

Since then this setup has been logging the temperature every five minutes. It was interesting to be able to see my central heating come on at 5pm and cycling to maintain a target temperature of 20°C until 11:45pm. The above snapshot shows the central heating coming on yesterday, but not on the current day.

Despite this now being in use for almost two months, my plan is to incorporate the sensors into something more sophisticated, for example an Arduino based ethernet connected thermostat for my central heating. This is not a new idea, there are just a couple of examples floating around to use for inspiration.

Tagged with: ,