Marc's Public Blog - Linux Home Automation


All | Aquariums | Arduino | Btrfs | Cars | Cats | Clubbing | Dining | Dinners | Diving | Electronics | Exercising | Flying | Hiking | Linux | Linuxha | Public | Rc | Sciencemuseums | Snow | Solar | Trips



Table of Content for linuxha:

More pages: March 2004 March 2009 May 2009 August 2009 November 2009 December 2009 February 2010 March 2010 June 2010 August 2010 March 2011 July 2011 August 2011 November 2011 January 2013 November 2013 December 2013 July 2014




2004/03/25 TV and remotes with linux
π 2004-03-25 00:13 by Merlin in Linux, Linuxha, Public

Current Music: DJ Tiƫsto - Live At Innercity - Norefjell
Current Mood: Yeah another long time project finally completed

So, those who've visited my house know that I have a sick system where I use
X10 wireless remotes, that get picked up by a receiver in the wall, which
transforms the signals from RF to electrical signals, which then get picked up
by a receiver in my linen^H^H^H^H^Hcomputer closet, which transforms this into a command for my serial port, which is read by a linux daemon, which in turn runs commands of my choosing, like changing the music or the volume (it's especially awesome under the shower, because I can use a throwaway wireless remote, and still control the music. I'm sure you'll agree that it is very important to be able to do so ;-)

Anyway, I also have another PC that is my video server, and plays files from another server (my disk server), and sends the video in a S-Video cable that goes under the house and reaches my TV.
So far, so good, except that I had to use my laptop on my couch to control the video and pause it or whatever (this turned out not to be a great problem since my laptop is always on my couch, but I digress).

So, I have some TV capture card with an IR receiver, and an IR remote. With a little work, I found and setup some linux software to receive the IR codes from the remote, and pass them on as commands to mplayer, a video player on linux.
This wasn't bad, except that I have to point the IR remote in my back, towards the PC, which is nowhere near the TV, and it wouldn't even work at all if I can see the TV but I'm a place in the room where my IR remote can't reach the IR receiver.
So, I had that working a couple of years ago, but I never really used it because it was a clearly inferior and imperfect solution that no self respecting geek would bring himself down to using :)

That's where my mouseremote comes in. This handy little sucker looks like a 5 way learning remote, also supports sending X10 events (i.e. to control my lights, and also my music from the closet), and then it also sends two more sets of RF signals that get picked up by another computer. The first set allows me to move the mouse on my TV screen for the PC I use to play videos, and the second set allows me to send random keys from the remote and have them used by the PC.
This is where the interesting part comes in: using those keys to do interesting stuff, like controlling the video so that I can just use my mouseremote like a regular remote, except that I'm talking to a PC that's not even within line of sight.
I wouldn't want to further bore you with technical details, and you can find them here should you really be curious (considering that it took me a little while to get it working, I documented it so that the next guy who tries this doesn't have to spend as much time than me). I'll just leave you with the (admittedly somewhat insane) list of things that happens in real life when you press play:
  1. the mouseremote sends an RF signal with the key I pressed
  2. multimoused on linux reads from the serial port and receives a translation of the RF signal
  3. it generates mouse events into the /dev/mumse fifo
  4. it separates and sends keypresses (like DVD+1) to /dev/x10fifo
  5. MouseRemote reads from the fifo and executes commands as directed in MouseRemote.conf
  6. MouseRemote.conf calls irsend, like so ' irsend SEND_RELAY "0000000000001005 00 5" Hauppauge ', which tricks the patches lircd to think I used my IR remote to send this code
  7. I'm running a patched lircd that understand this special trick, and relays it to its fifo as if it were coming from the infrared remote
  8. mplayer, running in lirc mode, reads from the lircd fifo, parses ~/.lircrc, receives the fake IR code, and pauses or resumes the video

See, it's really simple :)
I only got that working last night once I got the special evil trick to generate fake IR events in lircd, as if I were using my IR remote. We'll put aside the fact that I've owned the remote for mmmh, 4 years now :-)
Eh, at least I get points for documenting all this , so as to make it easier for the next guy...

Anyway, that's when you get to witness someone next to me in my couch, me pressing play or pause on my remote, the video stopping or starting as appropriate, me displaying a huge grin on my face, and the person next to me wondering "what's up with him, he pressed pause, the video paused, what's so special about that?".
If they only knew ;-)))

This is where I also get to say a few words about linux vs windows.
With windows, I would definitely have spent less time on all this: either I would have found some complex software that someone wrote and that happened to do what I needed, or I would have been entirely out of luck.
With linux, it took me a fair number of hours to make this all work (10 or so), but once I found that the main pieces existed (IR and RF readers) I knew that I could write the missing glue to make it all work together. In its own way, if you are into this, it's really rewarding to not only know it all works, but to have been able to make it work and piece it up together...

Eh, everyone needs a hobby, or two, or three, or... Oh, whatever, just let it be :)

Actually, if I get really bored, I'll have to setup freevo and MythTV on one, or several of my PCs, to turn them into more tivos (although that would probably also mean that I'd have to shell out some bucks to buy a small and quiet computer, and I have that stupid bet with myself that I have so much hardware already that I don't need to buy more computers (and I haven't bought a computer in more than 5 years, everything I have is from excess spare parts that I put together).
Anyway, I already have a Tivo and ReplayTV, and I don't *really* need to be watching more TV, and I don't really have the time to get bored, but you never know :)
2009/03/16 Insteon Setup and my own Blender Defender
π 2009-03-16 00:00 in Linuxha, Public
I have been spending a fair amount of time learning how to setup and work with Insteon Home Automation recently, as a way to replace X10 I had in my old house. Insteon is meant to be close to 100% reliable when setup correctly.

I could write a lot about Insteon, but I already have spent around 10H doing so in the Misterhouse Insteon docs for linux HA I wrote. In the process, I also researched UPB and Z-Wave to decide which one was the best option and here is my Summary of X10 vs UPB vs Z-Wave vs Insteon.

my own Blender Defender
my own Blender Defender

what an insteon dimmer switch looks like
what an insteon dimmer switch looks like

my main power strip going to a filter, X10 and Insteon modems
my main power strip going to a filter, X10 and Insteon modems

X10 CM11a on the left, Insteon Filter on lower right and Insteon Modem (PLM) on upper right
X10 CM11a on the left, Insteon Filter on lower right and Insteon Modem (PLM) on upper right

The Insteon Filter allows me to plug my UPS and devices in the back of it without them messing with Insteon signals going to and coming from the powerline.

While most of the time was spent setting up misterhouse to control our home lights and create virtual scenes as well as manage our outside lights depending on motion sensor input, I also build our own Blender Defender to teach chat to stay off the counter where he likes to go explore in search of food :) (Blender Defender is not my idea, I just improved on the concept since mine had to work at night too, see the link for the original author who inspired me).

My blender defender was a bit harder to build because it had to work at night, and I had to include a motion sensor to turn the light on first before the camera could work and detect motion (which makes things a bit harder because the motion detection library has to deal with a change in light, which can look like motion).
So far, it seems to have worked, although it was a bit less satisfying, maybe also because our blender is missing the strobe lights and isn't as scary and chat seems to have learned the first time.

Anyway, here's the result, taken in the middle of the night with the living room light turned via Insteon thanks to the script (yes, the camera doesn't show the blender, but the cat has been coming by jumping from the couch next to the kitchen counter, and this is the only camera angle that stops the cat as soon as he crosses the threshold without triggering when he's at the same height on the couch side, which is allowed).

Just like the original blender defender, I also used the super cheap D-Link DSC-900 and wrote my own scripts to activate my insteon device and light (including the fun part of preventing the outside patio light from turning on on outside motion sensor events as the light through the window could have changed the kitchen picture enough to trigger the blender in the middle of the night).
The hard part in the setup was the motion sensor library tweaks. You'll want motion and I heartily recommend starting with my motion.conf file and look for the CHANGED tags as a guide to setup your own (please understand that eventually you'll need to tweak for your own room and camera, good luck with that :) ).

2009/05/27 Mythtv + Denon-AVR3808 Hack
π 2009-05-27 00:00 in Linux, Linuxha
I had a minor issue where I have 4 hauppage remote controls and one on the kitchen counter that I sometimes use to control my mythtv when I'm in the kitchen.
The only problem was that sound is actually controlled by the Denon receiver and that the hauppage remote doesn't talk to the denon.

I finally found a fix for this, which somewhat justifies the extra money I spent for an ethernet connected receiver: I wrote an lirc configuration that effectively telnets to the denon to tell it to change volume when the hauppage receives a relevant remote code for that.

lircrc:

# Denon
# Mute
begin
prog = irexec
button = MUTE
repeat = 1
config = /var/local/scr/denonmute
end

begin prog = irexec button = Vol+ repeat = 1 config = /var/local/scr/denoncmd MVUP 3 end

begin prog = irexec button = Vol- repeat = 1 config = /var/local/scr/denoncmd MVDOWN 3 end

denonmute:

#!/bin/bash

FILE=/var/run/denonmute

test -f $FILE || touch $FILE

# prevent bounces [ $(( $(date "+%s") - $(stat -c "%Z" $FILE) )) -lt 2 ] && exit

if grep -q MUON $FILE 2>/dev/null; then CMD=MUOFF else CMD=MUON fi

echo -ne "$CMD\r" | nc -q0 denon 23 echo $CMD > $FILE

denoncmd:

#!/bin/bash

# $0 cmd [repeat]

for i in `seq 1 ${2-1}` do echo -ne "$1\r" | nc -q0 denon 23 sleep 0.2 done

exit

And there you go, I can now send volume requests to my mythtv and they get forwarded to my denon over TCP/IP. Pretty cool :)

2009/08/04 Work on HAI Omnistat code for misterhouse
π 2009-08-04 00:00 in Linux, Linuxha, Public
We recently made a subzone for our bedroom which allows to send a crapload of air from our HVAC system to the bedroom at night so that it can get cooled or heated quickly without bothering to bring the rest of the house to temperature.
But to control and monitor all this, there was some half finished code in misterhouse that I cleaned up, fixed up and improved. I now get reports of what's going on, can remotely control my HVAC system to change its setpoints, remotely and easily program its 48 time and setpoint settings via a web browser instead of the cumbersome panel interface, and of course I can log everything, like so:

07/08/2009 18:57:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 50, cool to 86, mode: program_auto 07/08/2009 18:57:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 18:58:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 50, cool to 86, mode: program_auto 07/08/2009 18:58:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 18:59:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 50, cool to 86, mode: program_auto 07/08/2009 18:59:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 19:00:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: fan/cool, heat to 62, cool to 74, mode: program_auto 07/08/2009 19:00:01 Main Omnistat State set to: cool_sp_change 07/08/2009 19:00:01 Main Omnistat State set to: heat_sp_change 07/08/2009 19:00:01 Main Omnistat State set to: current_output_change 07/08/2009 19:00:14 set cool to 76 07/08/2009 19:00:16 Main Omnistat State set to: cool_sp_change 07/08/2009 19:00:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 19:01:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 62, cool to 76, mode: program_auto 07/08/2009 19:01:00 Main Omnistat State set to: current_output_change 07/08/2009 19:01:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 19:02:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 62, cool to 76, mode: program_auto 07/08/2009 19:02:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 19:02:30 MBR Omnistat State set to: temp_change 07/08/2009 19:03:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 62, cool to 76, mode: program_auto 07/08/2009 19:03:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto 07/08/2009 19:04:00 Main Omnistat RC-90: Indoor temp is 74, HVAC Command: off, heat to 62, cool to 76, mode: program_auto 07/08/2009 19:04:30 MBR Omnistat RC-80: Indoor temp is 73, HVAC Command: off, heat to 50, cool to 88, mode: program_auto

You can see more on the Misterhouse HAI Omnistat Setup Page

2009/11/08 Brand One Powermeter, Solar and Power Monitoring with Cacti and Real Time PG&E Time of Use price calculation
π 2009-11-08 00:00 in Linuxha, Solar
Update: I have a much better solution (and meter), the ECM1240 from Brultech, read about it here.

Ok, the title is a mouthful, but that's why it's been about 6 months since I started and I have results to show for it only now.

My goals were to get:

  • a daily summary of power use per hour
  • have enough data to recreate a PG&E bill on a daily basis before we get it (to be able to predict whether we're using electricity in the right amount and at the right time before getting the bill).
  • more importantly, be able to drill a bill down to the day and the hour (we have data updates every 2mn) and see how much more power the house is using if the dishwasher is on, or the electric toaster oven.
  • get a real sense of how much our AC is running and how much it costs.
  • For this, while ordering the Solar Panels (aka PV system) from Cobalt Power, I asked for a monitoring system and the only one they found at the time that would allow monitoring of both the PV production and the PG&E Meter was a third party One Meter from One Brand Electronics.

    It looks like this:

    the meter that does gathering and resending to my monitoring server
    the meter that does gathering and resending to my monitoring server

    the probe gathering boxes (gets volts and amps)
    the probe gathering boxes (gets volts and amps)

    this shows the CTs that measure current from their induced magnetic field
    this shows the CTs that measure current from their induced magnetic field

    The voltage probes are simply connected to the lines and those are precise. Unfortunately, I don't care about voltage nearly as much as current sinc ethe voltage tends to be known and the current is what affects your bill.

    It's a reasonably easy solution to add to any setup during or after the fact, but the low points with the Brand Electronics One Meter solution are:

  • by design the current measured is inexact. I see current used on the PV inverter when it's not supposed to use much of anything, and of course I also see random small currents in either direction on the AC when it's off.
  • while the data gathered is good enough for general trends, longer term use has shown that it can be off by as much as 40Kwh/month on my PG&E Meter, which is a fair amount.
  • the One Meter interface is really bad. I'm a linux CLI guy, but it is bad. It is impossible to change its basic configuration like what it sends over telnet and at what interval without having its firmware reburnt by onebrand, but get this: you can't even change the IP address it'll talk to either without sending it back.
  • it has a serial interface for configuration that is quite poor and it'll dump old data you might have missed in a different format that what it sends over telnet to make your life harder.
  • it is a very slow microcontroller that is so slow that it takes over one minute to send 12 samples of data
  • it is of course unable to set its own time over ntp and is unaware of DST, so I just put mine on UTC and I fix things on the server side.
  • last, but not least, it will randomly corrupt itself and send totally bogus data points. Thankfully it however recovers at the next sample. I had to write fairly complex code to analyse the data samples, detect and throw away bad ones.
  • Ok, so are you sold yet? :)
    Well, it's not that bad now since I went through the effort of writing the code to deal with all this. So, if you were to get one, you'd be up and running pretty quickly if you can hack perl, the language I used for my magic script that does all the work (see the bottom of the page for source code).

    The above script took a fair amount of time to write since outside of working around quirks in the One Meter output, I wrote in the PG&E billing logic for California and it is able to output per hour per day production and use, as well as equivalency in dollars. Converting into dollars make sense since with TOU (time of use pricing) you can end up with days where your used more than you produced, but the end bill is still negative.

    This is a typical example of a summer day (July 8th picked at random):

    
    Hourly Differences
    00_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    01_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    02_:  1.0Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  1.0Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  1.0Kwh/$0.1 PG&E|
    03_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    04_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    05_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    06_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -0.0Kwh/$0.0 PV|  0.8Kwh/$0.1 PG&E|
    07_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -0.7Kwh/$0.1 PV|  0.1Kwh/$0.0 PG&E|
    08_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -2.2Kwh/$0.2 PV| -1.3Kwh/$0.1 PG&E|
    09_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -3.2Kwh/$0.3 PV| -2.3Kwh/$0.2 PG&E|
    10-:  0.8Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -3.9Kwh/$0.6 PV| -3.1Kwh/$0.4 PG&E|
    11-:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -4.3Kwh/$0.6 PV| -3.4Kwh/$0.5 PG&E|
    12-:  0.8Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -4.5Kwh/$0.6 PV| -3.6Kwh/$0.5 PG&E|
    13~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.2 HouseNoAC| -4.4Kwh/$1.3 PV| -3.5Kwh/$1.0 PG&E|
    14~:  0.8Kwh/$0.2 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.2 HouseNoAC| -4.1Kwh/$1.2 PV| -3.2Kwh/$0.9 PG&E|
    15~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -3.3Kwh/$1.0 PV| -2.4Kwh/$0.7 PG&E|
    16~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -2.0Kwh/$0.6 PV| -1.1Kwh/$0.3 PG&E|
    17~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -0.8Kwh/$0.2 PV|  0.1Kwh/$0.0 PG&E|
    18~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -0.2Kwh/$0.1 PV|  0.7Kwh/$0.2 PG&E|
    19~:  1.0Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  1.0Kwh/$0.3 HouseNoAC| -0.1Kwh/$0.0 PV|  0.9Kwh/$0.3 PG&E|
    20-:  1.0Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  1.0Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  1.0Kwh/$0.1 PG&E|
    21-:  1.1Kwh/$0.2 House|  0.0Kwh/$0.0 AC|  1.1Kwh/$0.2 HouseNoAC|  0.0Kwh/$0.0 PV|  1.1Kwh/$0.2 PG&E|
    22_:  1.0Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  1.0Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  1.1Kwh/$0.1 PG&E|
    23_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    ----------------------------------------------------------------------------------------------------
    Wed: 22.6Kwh/ $3.4House|  0.1Kwh/ $0.0AC| 22.5Kwh/ $3.4HouseNoAC| 34.7Kwh/-$6.7PV|-12.1Kwh/-$3.3PG&E|
    
    Split per rate:
    $.08 11.0Kwh/$0.93House|  0.0Kwh/$0.00AC| 10.9Kwh/$0.92HouseNoAC| -6.2Kwh/$0.52PV|  4.9Kwh/$0.41PG&E|
    $.14  4.6Kwh/$0.67House|  0.0Kwh/$0.00AC|  4.6Kwh/$0.66HouseNoAC|-12.7Kwh/$1.83PV| -8.0Kwh/$1.16PG&E|
    $.29  6.2Kwh/$1.83House|  0.0Kwh/$0.00AC|  6.2Kwh/$1.82HouseNoAC|-14.8Kwh/$4.35PV| -8.6Kwh/$2.52PG&E|
    
    Solar panels produced  34.7Kwh during 12.10h, between 06:46:28 and 18:50:28
    

    Yellow shows partial peak rates, where it's good to have the meter run backwards, and red for peak rates when it's even better. Unfortunately the solar panels are facing south east and south instead of south west where they would produce more when electricity is worth more.

    That is a more interesting example in September showing that despite having used more electricity in a day than what was produced, the daily bill was still negative thanks to the time of use magic, even it our case where we only get partial benefit from TOU due to the sub optimal south east angle for some of our panels:

    
    Hourly Differences
    00_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    01_:  1.0Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  1.0Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  1.0Kwh/$0.1 PG&E|
    02_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    03_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    04_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    05_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    06_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    07_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -0.1Kwh/$0.0 PV|  0.8Kwh/$0.1 PG&E|
    08_:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC| -1.5Kwh/$0.1 PV| -0.7Kwh/$0.1 PG&E|
    09_:  0.8Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -2.8Kwh/$0.2 PV| -1.9Kwh/$0.2 PG&E|
    10-:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -3.5Kwh/$0.5 PV| -2.6Kwh/$0.4 PG&E|
    11-:  0.8Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -3.9Kwh/$0.6 PV| -3.1Kwh/$0.4 PG&E|
    12-:  0.8Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.1 HouseNoAC| -4.1Kwh/$0.6 PV| -3.2Kwh/$0.5 PG&E|
    13~:  0.8Kwh/$0.2 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.2 HouseNoAC| -4.0Kwh/$1.2 PV| -3.2Kwh/$0.9 PG&E|
    14~:  0.8Kwh/$0.2 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.2 HouseNoAC| -3.6Kwh/$1.0 PV| -2.8Kwh/$0.8 PG&E|
    15~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.8Kwh/$0.2 HouseNoAC| -2.2Kwh/$0.6 PV| -1.3Kwh/$0.4 PG&E|
    16~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -1.0Kwh/$0.3 PV| -0.1Kwh/$0.0 PG&E|
    17~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -0.1Kwh/$0.0 PV|  0.8Kwh/$0.2 PG&E|
    18~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC| -0.1Kwh/$0.0 PV|  0.8Kwh/$0.2 PG&E|
    19~:  0.9Kwh/$0.3 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.3 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.3 PG&E|
    20-:  0.9Kwh/$0.1 House|  0.0Kwh/$0.0 AC|  0.9Kwh/$0.1 HouseNoAC|  0.0Kwh/$0.0 PV|  0.9Kwh/$0.1 PG&E|
    21-:  2.6Kwh/$0.4 House|  1.1Kwh/$0.2 AC|  1.5Kwh/$0.2 HouseNoAC|  0.0Kwh/$0.0 PV|  2.7Kwh/$0.4 PG&E|
    22_:  3.2Kwh/$0.3 House|  1.1Kwh/$0.1 AC|  2.0Kwh/$0.2 HouseNoAC|  0.0Kwh/$0.0 PV|  3.2Kwh/$0.3 PG&E|
    23_:  3.8Kwh/$0.3 House|  1.8Kwh/$0.2 AC|  2.0Kwh/$0.2 HouseNoAC|  0.0Kwh/$0.0 PV|  3.8Kwh/$0.3 PG&E|
    ----------------------------------------------------------------------------------------------------
    Thu: 29.0Kwh/ $4.0House|  4.4Kwh/ $0.4AC| 24.7Kwh/ $3.6HouseNoAC| 27.6Kwh/-$5.2PV|  1.5Kwh/-$1.2PG&E|
    
    Split per rate:
    $.08 15.8Kwh/$1.34House|  3.0Kwh/$0.25AC| 12.9Kwh/$1.09HouseNoAC| -4.4Kwh/$0.37PV| 11.5Kwh/$0.97PG&E|
    $.14  6.0Kwh/$0.87House|  1.1Kwh/$0.17AC|  4.9Kwh/$0.70HouseNoAC|-11.5Kwh/$1.66PV| -5.4Kwh/$0.78PG&E|
    $.29  6.1Kwh/$1.79House|  0.0Kwh/$0.00AC|  6.1Kwh/$1.78HouseNoAC|-10.9Kwh/$3.19PV| -4.8Kwh/$1.40PG&E|
    
    Solar panels produced  27.6Kwh during 10.20h, between 07:34:28 and 17:48:28
    

    Now, a per hour text output is useful to see how we did on a given day, but it does not let you see your power usage in the last 10mn after you turned something big on or off, or how all of last week looked, or see a month's trend at a glance.

    This is where cacti comes in. I spent a fair amount of time looking for a graphing solution that would keep all my data and let me zoom on any portions I wish. Quite frankly, the fancy widget that google uses in google finance would have been what I was really hoping for, but baring that, cacti came like a reasonable alternative.

    So, I came up with a compound graph that looked reasonable, and the option to see all the graph items separately.

    So since this is about solar panels, one of my questions to Cobalt Power was why my system was spec'ed for 5Kwh at peak and why I was typically seeing 4.5-4.7Kwh at best. The reason is that 2/3rd of the panels are pointing south-south-east and the remaining 3rd is pointing due south.
    What this means is that our system doesn't actually peak at one time and then drop off. The graph clear shows that the PV production takes longer to peak and then stays at that lower peak a bit longer before dropping off more sharply. So, the production at the end of the day is still the same, but just with a slightly longer and slightly lower peak. Too bad the peak is on the morning side as opposed to the afternoon side when the electricity is worth more.
    You'll also notice the sharp start which is when the sun goes high enough to reach the roof over the neighbours' houses across the street. You'll also notice the jigsaw drop on the way down as the sun starts to get hidden behind some branches in the high trees blocking our west view.

    This graph and the graphs below are selected in zoom mode, so you can use the mouse cursor to draw a rectangle on a time region and the graph will refresh on the time slice you selected.



    Below is a closeup of all the colors showing AC working hard in bursts while the black PG&E meter line goes from sometimes negative to always positive the green area of solar panel energy offset goes down to 0. Blue then shows the basic house energy usage with the red peaks on top showing AC tripling the house electricity use when it's running.



    In other words: the red line is the AC use, the blue is the rest of the house use, red line goes on top of house use gives the red area which is total house use. You then remove green which is production from the solar panels and you end up with the black line which is what the PG&E meter actually sees. Confused yet? :)

    Here's a typical day without AC use since we weren't home:



    Here's a very warm day with AC (keep in mind that you can zoom in by selecting a time slice with the mouse):



    and a glance at just AC use during a few hot days in July:


    Here is a link to an historical view of this graph at multiple time sample levels. Try the zoom function (magnifying mirror next to the graph) on the yearly graph at the bottom and you'll be able to zoom on random time in the past.

    Another view is each probe graphed separately for a less cluttered view. Note that the AC view is pretty useless right now as it's only showing noise picked up by the coils, but if you click on it, you'll get the multiple timerange view as above and can view more interesting months, like the July zoom above.

    What else?
    Well, I had written some somewhat complex code to actually keep up of production for each tier and find out if I went into tier 2 to 5 (which pay or cost more per unit of energy), but because the One Meter gives me somewhat inaccurate readings, especially on the PG&E side, the numbers were just too far off to compute a bill that was close enough to the actual bill I was getting. So, I unfortunately had to give that part up.
    It would otherwise have been nice to know in advance if my use or production for a given tier was going to exceed tier 1 and possibly adjust electricity use accordingly, but I'll need a more accurate measuring device than the One Brand one.

    All this ended up being a fair amount of work, which with not that much extra work could have been a service that all solar companies sell. I think a few do, but I'm not sure if it's as complete as what I did, or if it is, please let me know so that I can compare with their work.

    Anyway, if it's useful to you, here's the parsebrandpower script. Please note that if you were planning on taking it and selling service based on my work, it is protected by the GPL 3 copyright which you must understand and apply if you are going to use it. I also request that you contact me and let me know if you're going to use the code.
    For more details on cacti integration, see my Gatewaying 1-wire, XPL (Oregon Scientify Weather), Brultech ECM1240 Power Data, and Brand OneMeter Data to cacti page.

    2009/12/23 Temperature monitoring and graphing with 1wire devices, digitemp, misterhouse, and cacti
    π 2009-12-23 00:00 in Linuxha
    If you are interested in this page, you should also refer to my later Temperature, moisture, humidity, and UV monitoring and graphing with 1wire devices, owfs, and cacti blog post.

    Temperature logging

    I had basic temperature logging via the HAI RC-80 thermostat code I co-maintain which polls our thermostats for temperature (along with other settings like whether they are running). Other info on the RC-80 thermostat can be found here, just note that they cost about $50 used on Ebay.
    Our house is a little different from the average: we have a sub-zone in the master bedroom which is basically a second big vent going directly from the HVAC system to the bedroom. The bedroom has an RC-80 which turns on the HVAC system and opens the bypass vent when the master bedroom temperature needs to be adjusted, however there is still air going to the rest of the house too, but since a lot goes to the bedroom, it gets to temperature more quickly. So you may ask why the subzone is not just a separate zone and that's because our HVAC system is too old, cannot be run a less than full power and would get damaged if its output was only sent to our bedroom.

    The RC-90 looks pretty simple
    The RC-90 looks pretty simple

    the interesting part is the added wires for the serial port
    the interesting part is the added wires for the serial port

    The main zone is controlled by an RC-90 (which I use as a regular RC-80). When it turns on, the entire house gets air, including the master bedroom through its smaller vents.
    The little trick is that the zone board (which gets input from both the RC-90 and RC-80) is configured to run both zones for 2 minutes after the heating or cooling has stopped (probably to recirculate the air, even in the unused zone).

    HVAC zone board
    HVAC zone board

    The one nice thing is that the HAI thermostats tell me what they are telling the hvac zone board, so I can tell when the command was sent, for how long and compare with the HVAC output with temp sensors. The thing that is not as good is that the temperature I get back from the HAI thermostats does not have any decimals (as much as I hate Fahrenheit, I log temps in Fahrenheit because with integer only temperatures I get somewhat better resolution in Fahrenheit than in Celsius).

    Here's a good example graph showing combined data:


    The graph shows the bedroom HVAC being activated (orange) with the resulting rise of both temperature probes since the subzone has to activate the main zone too). When the main zone is turned on (red), the subzone vent only shows a slight rise in temperature due to leakage in the valve, except in the last 2 minutes right after the HVAC system is turned off but the fan left on: you can see the vent being opened right after the HVAC is turned off.

    You can compare with the simpler graph based just off data from the HAI RC-90 and RC-80 and data gathered from the misterhouse HAI code I improved. The following graph shows AC being turned on for the main house and the master bedroom after that:


    Since the 1°F resolution of the HAIs is not good enough for nice graphs, this is where the 1-wire DS18B20 temp sensors come in. In most rooms I just have them plugged into the wall via Cat-5 (more details below) and in order to save having to make another hole in our ducts, this is how I measure the main duct temperatures when air is being blown :)


    Findings

    So that's for the HVAC system but after that I was curious to know:

  • how balanced or misbalanced the hvac system was (which rooms get warmer or colder). In our case, we're actually happy to have a misbalance as we don't need to heat up or cool down all the house evenly. The following graph is telling, it shows that using the main HVAC system gets our main corridor (where the thermostat temp is sampled) warmer than than our master bedroom with the family room being warmer than our living room (which is good since we spend more time in the family room than the living room). Of course, it also shows our family room has more leakage, likely through the fireplace vent. The good news is that the wine closet is well insulated and shows a relatively constant temperature, so I am hopeful that we may be able to hack in an insteon controlled AC system that exhausts to the attic and cools down the wine closet (the only issue is controlling the humidity since an AC system will get the temperature to a nice value, but also dry up the air).

  • the temperature under the house in the crawl space to know if we can get air from it to cool down the house more cheaply during the summer by grabbing air from under the house during the night. The first graph shows temperatures during the winter on sunless days (roof shingles temps otherwise still get over 90 degrees in plain sun during the winter). The second graph during warmer end of summer days shows that we may be able to get cool air from under the house instead of running the AC (will need HVAC modifications).
  • If you wonder why the attic and garage lines are squiggly, that's because of the computer closet exhaust fan to the attic and the heat from the fridge compressor in the garage.



  • how warm the roof and attic get during the summer is also interesting (the above graphs both show how warm the roof shingles get, how it wouldn't be hard to heat water there, and how attic temperature closely follows the roof temperature even with the exhaust fans we have in the attic)
  • outside air temperature at the top of the house vs at its base in the shade. It make sense that the air by the crawlspace is less variant and more stale, keeping a more constant temperature, while the air by the roof (sampled under the roof to negate roof sun heating) moves around more with wind.
  • the temperature in our lesser insulated garage and whether that's influencing temperatures in our family room on the other side of the wall, or not. One night, we kind of forgot to close the garage door. This zoom on the Garage vs Family Room vs Outside temperatures graph is relatively good news: the garage temperatures dipped a lot, but thankfully the family room on the other side of the insulated door, did pretty well.

  • for fun, I looked at how hot my computer closet is getting, and used that temperature to turn the exhaust fan on and off via insteon and X10. You can see the closet temperature cycle between the 2 boundaries I set for the fan. You can also see smaller peaks that are due to my failsafe of turning the fan on every hour regardless of temperature (I have code in misterhouse that checks if the temperature is low enough and turns the fan off, as well as turns it on when it reaches 85F, but it also gets turned on from cron on the hour as a backup if misterhouse or temperature sampling craps out).
  • It's also fun to see how the attic temperature changes as I exhaust heat from the computer closet into it, and how it even affects the HVAC duct a little bit, showing how those ducts, despite all their insulation, still leak temperature somewhat (the big peak in the duct is of course the HVAC system turning on).


  • measure the temperature in the main HVAC zone to see how hot the air I get from it is, or how cold air from our AC system is (and do the same for master bedroom subzone). For that, I have the hot air side (115F, which is lower than I thought) but not the cold air side yet since we haven't run the air conditioning since I've had the duct temperature monitoring.
  • Anyway, that's enough graphs for now, if you want more (and make your own), here is a link to a list of all the graphs.

    1-Wire Setup

    For temperature logging throughout the house and outside, the recommended solution is to use Maxim/Dallas 1-wire network (which is really 3 wires: ground, signal, and 5V which can be shunted back to ground if you don't need to measure extreme temperatures).

    I'm not going to give a full description of everything since others have already done this better than me, but there is a fair amount of outdated information out there, so let me fix some of it (written as of 2009/12):

  • I went with a DS9097U maxim/dallas 1-wire serial adapter (I originally got the USB based DS9490R-A which is really a DS2490 chip, but I found it was less reliable with long networks, and it would just lock up and require a full power cycle with it had errors). If you decide to go with the USB version, since it is known to lockup with at least digitemp (maybe owfs is able to recover it), you will need to detect lockups and do a full USB power cycle to come back to life (i.e. you need to get a rare USB hub that is externally powered and allows power cycling. See my friend Andrew's blog if you need to get a USB hub that can power cycle ports).
  • DS9490R-A aka DS2490 USB 1wire adapter plugged in powered USB hub, and DS9097U serial adapter plugged into USB to serial adapter
    DS9490R-A aka DS2490 USB 1wire adapter plugged in powered USB hub, and DS9097U serial adapter plugged into USB to serial adapter

  • If you think you should get the USB version because you don't have serial ports, a USB-serial adapter like in the picture above is only $20 or so. I really do prefer the reliability of the serial adapter and picked up a USB to 4 serial port adapter for $45 on ebay.
  • As far as software goes, you can use both digitemp or owfs. Owfs supports a few more devices and uses a cool filesystem interface, but this requires kernel support. Digitemp works well enough for most cases and is more portable to random devices, including my linksys router. I picked digitemp and will give examples for it below, but owfs is a fine choice too if it works for you.
  • Where to buy from?
  • First, you have the option of buying $20 modules that have the transistor looking temperature sensor inside (easier to wire) to just the temp sensor part for less than $5 and you have to wire it yourself. Your call.

    A few places I found:

  • For temperature sensors, I started with the oft recommended DS18S20, but found out that the DS18B20 are actually much quicker to poll, so this is what people should buy today (they are fully compatible with digitemp and owfs). Oh, and the -PAR models are the same but with pins 1 and 3 hotwired so that you don't have to do it yourself (I've found it not necessary to use a more complicated powered network even for my long network, it's only required to sense extreme temperatures which you are unlikely to care about).
  • Note that all 4 kinds (DS18S20, DS18S20-PAR, DS18B20, and DS18B20-PAR) look exactly the same and work the same with digitemp and owfs. See this page for a comparison of the different sensors and you can read this page on PAR vs non -PAR.

  • for debugging, I used those cat-5 splitters, which do come in handy when I have to debug the network (unfortunately, the whole 1-wire network can go bad if something is wired backwards or there is a short, and you will lose part of the network if a miswire causes the circuit to be open). This is where they come in handy, the picture below shows 3 temp sensors wired in parallel to the splitter (I also label their serial number on a piece of tape for easier reading).

  • There is a big warning: all phone cords I've found are crossover cables as opposed to straight through, so if you use one, your pins will be reversed and you'll have to wire accordingly. See this picture of the USB 1wire adapter plugged into a DS18S20 where I had to reverse the pins for it to work due to the crossed phone cable:
  • the center pair is reversed due to the phone cable, the middle pin is actually signal, while 1 and 3 are ground and power shunted together
    the center pair is reversed due to the phone cable, the middle pin is actually signal, while 1 and 3 are ground and power shunted together

    .


    You can find wiring details on this page, or in a nutshell, my cheat sheet below:

    pin 2 (RJ11)/pin 4 (RJ45) -> 1-W/DATA (DS18B20 pin  2 )	blue wire
    pin 3 (RJ11)/pin 5 (RJ45) -> GND+VDD  (DS18B20 pin 1+3)	white wire
    

    Cat 5 wiring to a plug where 1-wire is looped back from the blue pair to the green pair: 3 1-W back -> green/white 4 1-W -> blue 5 GND -> blue/white 6 Gnd back -> green

    Note that the Maxim documentation gives you incorrect pin numbers because they count RJ11 pins in the opposite order from what's standard as per wikipedia.
    I personally made my own cat-3 cable with my crimping tool and simple wire. That's the best way to know it's wired right (and you only need 2 wires anyway, the center pair)

  • I built a network that's about 1000ft long by using existing cat5 cables in our house, sending the signal down one pair, and bringing it back another pair (this doubles the distance, but works for me and saves my buying a 1-wire hub which would otherwise be required for this).
  • you can see my Cat-5 cables coming from multiple places in the house and being daisy chained together (I use the blue pair to get there and the green pair to come back
    you can see my Cat-5 cables coming from multiple places in the house and being daisy chained together (I use the blue pair to get there and the green pair to come back

  • The other trick is to keep good track of the DS18B20s serial numbers as you install them since it will be hard to make out what is what otherwise when everything is installed later.
  • useful links
  • Digitemp Setup

    Update at this point, I would not recommend using digitemp anymore unless you only ever plan on using DS18S20 and DS18B20 temp sensors, as this is mostly what digitemp supports (it does support one single humidity sensor too, but only with the serial interface, not the USB one). Long story short, if you're planning on doing anything more with 1-wire, you should invest the little extra time and set yourself up with owfs instead, which I've described in my later Temperature, moisture, humidity, and UV monitoring and graphing with 1wire devices, owfs, and cacti blog post.

    First: why would I use digitemp and log to a file from cron (which I then re-read and process for graphing and other uses) instead of using built in support in misterhouse? The reason turns out to be that I just don't want to lose temperature samples if misterhouse dies or if I'm hacking on it and have it down for a while. Simpler is better and more reliable in this case :)

    USB:

    On linux you may have to unload the kernel support for this USB adapter:
    rmmod ds2490
    

    Then do a quick scan: gargamel:/tmp# digitemp_DS2490 -w DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490 device #1 at 003/005 Turning off all DS2409 Couplers ... Devices on the Main LAN 1080BAED010800EA : DS1820/DS18S20/DS1920 Temperature Sensor 28D813060200000F : DS18B20 Temperature Sensor 812C282900000044 : Unknown Family Code

    Then generate a config file: gargamel:/tmp# digitemp_DS2490 -i DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490 device #1 at 003/005 Turning off all DS2409 Couplers ... Searching the 1-Wire LAN 1080BAED010800EA : DS1820/DS18S20/DS1920 Temperature Sensor 28D813060200000F : DS18B20 Temperature Sensor ROM #0 : 1080BAED010800EA ROM #1 : 28D813060200000F Wrote .digitemprc

    Here you can edit/save the file, and running -a will use the config file in the current working directory: gargamel:/tmp# digitemp_DS2490 -a DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490 device #1 at 003/005 Dec 26 22:26:05 Sensor 0 C: 24.31 F: 75.76 Dec 26 22:26:07 Sensor 1 C: 26.19 F: 79.14

    The serial adapter works almost the same way, you just have to specify the serial port until it's written in the configuration file:

    gargamel:/tmp# digitemp_DS9097U -s /dev/ttyS1 -w
    DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
    GNU Public License v2.0 - http://www.digitemp.com
    Turning off all DS2409 Couplers
    ............
    Devices on the Main LAN
    10A8D1ED0108009C : DS1820/DS18S20/DS1920 Temperature Sensor
    10A8D1ED0108009C : DS1820/DS18S20/DS1920 Temperature Sensor
    102223EF0108009B : DS1820/DS18S20/DS1920 Temperature Sensor
    1052D1ED01080021 : DS1820/DS18S20/DS1920 Temperature Sensor
    10D1D0ED0108005F : DS1820/DS18S20/DS1920 Temperature Sensor
    10F9F3EE01080076 : DS1820/DS18S20/DS1920 Temperature Sensor
    1045D2ED010800B1 : DS1820/DS18S20/DS1920 Temperature Sensor
    10E5E7ED010800BB : DS1820/DS18S20/DS1920 Temperature Sensor
    285CFC0502000004 : DS18B20 Temperature Sensor
    28DD71C701000024 : DS18B20 Temperature Sensor
    283359C7010000D8 : DS18B20 Temperature Sensor
    2857B65902000062 : DS18B20 Temperature Sensor
    09C7BE600500009E : DS2502/DS1982 1Kbit Add only memory
    

    gargamel:/tmp# digitemp_DS9097U -s /dev/ttyS1 -i DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Turning off all DS2409 Couplers ........... Searching the 1-Wire LAN 10A8D1ED0108009C : DS1820/DS18S20/DS1920 Temperature Sensor 1094A2ED0108002F : DS1820/DS18S20/DS1920 Temperature Sensor 102223EF0108009B : DS1820/DS18S20/DS1920 Temperature Sensor 1052D1ED01080021 : DS1820/DS18S20/DS1920 Temperature Sensor 10D1D0ED0108005F : DS1820/DS18S20/DS1920 Temperature Sensor 10F9F3EE01080076 : DS1820/DS18S20/DS1920 Temperature Sensor 10E5E7ED010800BB : DS1820/DS18S20/DS1920 Temperature Sensor 285CFC0502000004 : DS18B20 Temperature Sensor 28DD71C701000024 : DS18B20 Temperature Sensor 283359C7010000D8 : DS18B20 Temperature Sensor 2857B65902000062 : DS18B20 Temperature Sensor ROM #0 : 10A8D1ED0108009C ROM #1 : 1094A2ED0108002F ROM #2 : 102223EF0108009B ROM #3 : 1052D1ED01080021 ROM #4 : 10D1D0ED0108005F ROM #5 : 10F9F3EE01080076 ROM #6 : 10E5E7ED010800BB ROM #7 : 285CFC0502000004 ROM #8 : 28DD71C701000024 ROM #9 : 283359C7010000D8 ROM #10 : 2857B65902000062 Wrote .digitemprc gargamel:/tmp# digitemp_DS9097U -s /dev/ttyS1 -a DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Dec 26 22:30:39 Sensor 0 C: 16.88 F: 62.38 Dec 26 22:30:40 Sensor 1 C: 8.69 F: 47.64 Dec 26 22:30:41 Sensor 2 C: 13.44 F: 56.19 Dec 26 22:30:43 Sensor 3 C: 16.19 F: 61.14 Dec 26 22:30:44 Sensor 4 C: 10.69 F: 51.24 Dec 26 22:30:45 Sensor 5 C: 13.25 F: 55.85 Dec 26 22:30:46 Sensor 6 C: 9.06 F: 48.31 Dec 26 22:30:47 Sensor 7 C: 15.44 F: 59.79 Dec 26 22:30:48 Sensor 8 C: 5.25 F: 41.45 Dec 26 22:30:49 Sensor 9 C: -8.75 F: 16.25 Dec 26 22:30:50 Sensor 10 C: 17.25 F: 63.05

    The trick is to save your .digitemprc in /etc/digitemprc, and then I call digitemp_DS9097U -a -c /etc/digitemprc | /var/local/scr/digitemp_rename.
    Below are my configs:

    gargamel:/tmp# cat /etc/digitemprc
    TTY /dev/DS9097U
    READ_TIME 1000
    LOG_TYPE 1
    #LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
    LOG_FORMAT "%Y/%m/%d %H:%M:%S Sensor %s F: %.2F"
    CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
    HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
    SENSORS 14
    ROM 0 0x10 0x22 0x23 0xEF 0x01 0x08 0x00 0x9B
    ROM 1 0x10 0xA8 0xD1 0xED 0x01 0x08 0x00 0x9C
    ROM 2 0x10 0x94 0xA2 0xED 0x01 0x08 0x00 0x2F
    ROM 3 0x10 0x52 0xD1 0xED 0x01 0x08 0x00 0x21
    ROM 4 0x10 0xD1 0xD0 0xED 0x01 0x08 0x00 0x5F
    ROM 5 0x10 0xF9 0xF3 0xEE 0x01 0x08 0x00 0x76
    ROM 6 0x10 0x45 0xD2 0xED 0x01 0x08 0x00 0xB1
    ROM 7 0x10 0xE5 0xE7 0xED 0x01 0x08 0x00 0xBB
    ROM 8 0x10 0x5D 0xE1 0xED 0x01 0x08 0x00 0x81
    ROM 9 0x28 0x5C 0xFC 0x05 0x02 0x00 0x00 0x04
    ROM 10 0x28 0x36 0xA3 0x59 0x02 0x00 0x00 0x38
    ROM 11 0x28 0xDD 0x71 0xC7 0x01 0x00 0x00 0x24
    ROM 12 0x28 0x33 0x59 0xC7 0x01 0x00 0x00 0xD8
    ROM 13 0x28 0x57 0xB6 0x59 0x02 0x00 0x00 0x62
    

    gargamel:/tmp# cat /var/local/scr/digitemp_rename #!/bin/bash

    # the 2nd sed of seds does nothing, it's just there for me to keep track of mappings

    sed -e "s/Sensor 10/13 MBR_ZoneVent/" -e "s/#10 : 2836A34902000038//" -e "s/Sensor 11/51 Garage_Fridge/" -e "s/#11 : 28DD71C701000024//" -e "s/Sensor 12/52 Garage_Freezer/" -e "s/#12 : 283359C7010000D8//" -e "s/Sensor 13/56 Hall_Closet/" -e "s/#13 : 2857B65902000062//" -e "s/Sensor 0/15 Garage/" -e "s/#0 : 102223EF0108009B//" -e "s/Sensor 1/11 Family_Room/" -e "s/#1 : 10A8D1ED0108009C//" -e "s/Sensor 2/22 Roof/" -e "s/#2 : 1094A2ED0108002F//" -e "s/Sensor 3/12 Living_Room/" -e "s/#3 : 1052D1ED01080021//" -e "s/Sensor 4/32 Outdoors_Crawlspace/" -e "s/#4 : 10D1D0ED0108005F//" -e "s/Sensor 5/31 Crawlspace/" -e "s/#5 : 10F9F3EE01080076//" -e "s/Sensor 6/55 Computer_Closet/" -e "s/#6 : 1045D2ED010800B1//" -e "s/Sensor 7/23 Outdoors_Roof/" -e "s/#7 : 10E5E7ED010800BB//" -e "s/Sensor 8/21 Attic/" -e "s/#8 : 105DE1ED01080081//" -e "s/Sensor 9/14 MBR_FloorVent/" -e "s/#9 : 285CFC0502000004//"

    If you ever see this:

    gandalf:~# digitemp_DS2490 -a
    DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
    GNU Public License v2.0 - http://www.digitemp.com
    Found DS2490 device #1 at 001/018
    Oct 10 21:22:39 Sensor 0 C: 26.44 F: 79.59
    CRC Failed. CRC is 63 instead of 0x00
    CRC Failed. CRC is 63 instead of 0x00
    CRC Failed. CRC is 63 instead of 0x00
    It is likely because the digitemprc you are using is listing a 1wire device that is not visible on the network.

    This is my somewhat complicated cronjob to gather digitemp temps and HVAC status and temp from misterhouse:

     * * * * * root alarm 25 digitemp -q -a -c /etc/digitemprc | grep Sensor | digitemp_rename | sort >> /var/log/temperatures
    

    * * * * * root DATE=`date "+\%Y/\%m/\%d\ \%H:\%M"`; sleep 45; (tail -100 /var/local/src/misterhouse/data/logs/thermostat.log | grep 'Omnistat RC' | tail -2 | sed -e "s#^\(..\)/\(..\)/\(....\)#\3/\2/\1#" -e "s/, HVAC.*//" -e "s/ Main Omnistat RC-90: Indoor temp is /01 Corridor F: /" -e "s/ MBR Omnistat RC-80: Indoor temp is /02 MasterBR F: /" ; tail -100 /var/local/src/misterhouse/data/logs/thermostat.log | grep 'Omnistat RC' | tail -2 | sed -e "s#^\(..\)/\(..\)/\(....\)#\3/\2/\1#" -e "s/ Main Omnistat RC-90:.*HVAC Command: /05 Corridor_HVAC: /" -e "s/ MBR Omnistat RC-80:.*HVAC Command: /06 MBR_HVAC: /" -e "s/,.*//" -e "s#fan/##" -e "s#off/##" -e "s/off/0/" -e "s/fan/0/" -e "s/cool/-1/" -e "s/heat/1/" )| grep "$DATE" | sort >> /var/log/temperatures

    End result looks like this:

    2009/12/27 08:44:03 15 Garage F: 54.27
    2009/12/27 08:44:04 11 Family_Room F: 62.26
    2009/12/27 08:44:06 22 Roof F: 55.96
    2009/12/27 08:44:07 12 Living_Room F: 61.02
    2009/12/27 08:44:08 32 Outdoors_Crawlspace F: 49.89
    2009/12/27 08:44:09 31 Crawlspace F: 56.08
    2009/12/27 08:44:10 55 Computer_Closet F: 75.76
    2009/12/27 08:44:11 23 Outdoors_Roof F: 48.09
    2009/12/27 08:44:12 21 Attic F: 57.42
    2009/12/27 08:44:13 14 MBR_FloorVent F: 69.69
    2009/12/27 08:44:14 13 MBR_ZoneVent F: 70.47
    2009/12/27 08:44:15 51 Garage_Fridge F: 40.77
    2009/12/27 08:44:17 52 Garage_Freezer F: 16.81
    2009/12/27 08:44:18 56 Hall_Closet F: 62.71
    2009/12/27 08:44:00 01 Corridor F: 65
    2009/12/27 08:44:00 05 Corridor_HVAC: 0
    2009/12/27 08:44:30 02 MasterBR F: 64
    2009/12/27 08:44:30 06 MBR_HVAC: 0

    Here is a link to my cacti_owfs script I use to read the above log and for graphing in cacti or rrdtool, or for getting a data sample that I can use in misterhouse (more generally, you want to see my Temperature, moisture, humidity, and UV monitoring and graphing with 1wire devices, owfs, and cacti page as well as my Gatewaying 1-wire, XPL (Oregon Scientify Weather), Brultech ECM1240 Power Data, and Brand OneMeter Data to cacti page for cacti integration page.

    1-Wire Applications

    I keep track of my fridge vs freezer temperatures, which is hard to otherwise get on most fridges.



    For now I only use the temperature to turn the fan in the computer closet on and off (with a backup that turns it back on every hour just in case misterhouse died), but I am hoping to get more automation of the sort like getting outside air in at the right times of the day to regulate temperature for virtually free when possible (as well as recirculate the air).
    You can see the graph above for my computer closet temperature as controlled by an exhaust fan.
    Update: I did get around to installing an outside air cooling/heating system, the details are on my Booster Fans and Heating/Cooling with Outside Air with Misterhouse page.

    Ideally, instead of using a zone board to turn on the HVAC when the subzone thermostat wants to cool/heat the master bedroom, I would have used misterhouse to tell the secondary thermostat to trigger the HVAC through the first one, but my code wasn't ready then and more importantly I felt that maybe basic functionality in the house should not rely on a computer that I'm the only one who can fix :) (it would also have sucked for the next people if we sell the house and had moved out since the HVAC system would have not worked properly without my computer).

    2010/02/14 Daily Power and Solar Stats
    π 2010-02-14 00:00 in Linuxha, Solar
    It's not quite a year yet, but I've recently worked on daily stats for our solar panels. If you go to the Solar and Power Monitoring post, you get all the stats that are gathered every few minutes.
    I was however missing daily stats showing for each day what time production started, what time it stopped (depending on dailight savings time of course), how many hours of sun we got. I also added a repeat of how many Kwh were produced that day.

    Here are the resulting graphs (as a reminder you can zoom in by selecting a rectangle with the first mouse button and zoom out with the second button).

    The good news from that data is that even the worst day, we made at least 3Kwh, which is what some small apartments use in a day. The average at the end of a year cycle should be around 24Kwh/day, which is 80% of what we end up using and less that what we'll end up paying once you figure out time of use offsets (i.e. the average electricity we make is worth more than the electricity we use).

    Below is a graph with production start and end (hour the sun starts hitting the panels and when it sets past the roof). Note the one hour jump on Nov 1st because of the daily savings change.


    Production hours:


    Production Kwh:


    Last, but not least this page lets you get all the daily starts (note, you need to change the top preset to 3, 6, or 12 months to get useful data, last day doesn't show anything).

    See more images for Daily Power and Solar Stats
    2010/03/11 One Year Of Solar Panels
    π 2010-03-11 00:00 in Linuxha, Solar
    Today is the one year anniversary of the Solar Panels Turnup, so I thought I'd gather a few stats to see how they did (unfortunately the full house monitoring system only became active more than 2 months later, so I don't have full stats).

  • Cobalt Power Estimated the panels yearly production at 8114Kwh for a year. I was a bit apprehensive during the quotes because of our weirdly shaped roof and shading issues from nearby trees, but in the end we got exactly 8700Kwh a year later, or almost a 600Kwh production beyond the estimate. Great!
  • Cobalt Power estimated our federal tax credit to $11,235 (the CA tax rebate is directly taken off the initial bill). I just got my taxes done and our tax credit was $11,746. this made the panels around $500 cheaper than quoted. Great again! :)
  • According to PG&E, we used around 1600Kwh since last year (i.e. we used about 1.5 months' worth of electricity), but due to the time of use credits (summer daytime electricity that we mostly produce is worth more than night and winter electricity), we actually got a $40 credit for the year, so we won't owe them anything outside of the monthly connection charge ($10, which is much cheaper than batteries and being off-grid). This year the $40 is lost but next year, they'll actually owe us whatever credit we get (i.e. we get a check back).
  • At this rate, we should break even in 5 years.
  • So in a nutshell, the system performed great so far. Cobalt Power definitely underpromised and over delivered and we're apparently done paying electricity bills from now on.

    Here are the not quite yearly graphs (as a reminder you can zoom in by selecting a rectangle with the first mouse button and zoom out with the second button).

    As a slight repost, below is a graph with production start and end (hour the sun starts hitting the panels and when it sets past the roof). Note the one hour jump on Nov 1st because of the daily savings change.


    Production hours:


    Production Kwh (nice to see that March is getting a lot more sun):


    Last, but not least this page lets you get all the daily starts (note, you need to change the top preset to 3, 6, or 12 months to get useful data, last day doesn't show anything).

    See more images for One Year Of Solar Panels
    2010/06/17 Dealing with many USB to Serial Port Converters on linux and device naming
    π 2010-06-17 00:00 in Linux, Linuxha
    So, if you have more than one USB to serial adapter, you might have issues with which order they load in, causing the serial port numbers (/dev/ttyUSB0 .. x) to change pseudo randomly at boot, it's pretty annoying.

    In my case, I picked up an 8 port ftdi usb to serial converter for only $15 on Ebay (woot!) but even its ports may not come up in sequence at boot time if other modules are loaded at the same time (a race condition can cause the pl2303 port to be in between one of the 8 ports from the ftdi hub).

    Turns out there is a solution to this problem with udev, iff your usb to serial adapters have serial numbers (my ftdi ones did, but my pl2303 ones did not), or if you only have one serial adapter of each brand (like ftdi, pl2303, keyspan).

    In my case, I have (don't laugh), 11 serial devices on my server:

  • Server serial console
  • 1-wire serial adapter
  • Insteon PLM
  • APC ups
  • W800 X10RF and X10sec gateway
  • X10 MR26a X10RF gateway
  • First ECM 1240 power meter
  • Second ECM 1240 power meter
  • Brand One Meter serial adapter
  • HAI thermostats (2 on one line)
  • Rfxcom 433.92Mhz (433.92Mhz RF gateway for Oregon Scientific Weather Sensors)
  • This is what you do with udev:

    gargamel:~# cat /etc/udev/rules.d/50-local-usb-serial.rules 
    # /etc/udev/rules.d/50-local-usb-serial.rules
    

    # http://www.reactivated.net/writing_udev_rules.html#udevinfo # was udevinfo -a -p /class/tty/ttyUSB0 # now udevadm info --attribute-walk -p /class/tty/ttyUSB0

    SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvN", SYMLINK+="usb-serial-ftdi-8_1" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvO", SYMLINK+="usb-serial-ftdi-8_2" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvP", SYMLINK+="usb-serial-ftdi-8_3" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvR", SYMLINK+="usb-serial-ftdi-8_4" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvQ", SYMLINK+="usb-serial-ftdi-8_5" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvS", SYMLINK+="usb-serial-ftdi-8_6" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvT", SYMLINK+="usb-serial-ftdi-8_7" SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A7006gvU", SYMLINK+="usb-serial-ftdi-8_8"

    SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{serial}=="A800dMFk", SYMLINK+="rfxcom"

    SUBSYSTEMS=="usb", ATTRS{product}=="USB-Serial Controller", ATTRS{manufacturer}=="Prolific Technology Inc.", SYMLINK+="usb-serial-pl2303"

    After making a change udevadm trigger will update symlinks.

    2010/06/18 Powering UPSes with Marine or AGM batteries
    π 2010-06-18 00:00 in Linuxha, Solar
    So, isn't it a bit ironic that if I have solar panels that power my entire house and then some during the day, if PG&E power goes off, my inverter has no choice but to shut off too, likely both because it uses PG&E as a phase offset source, and because it would likely be bad to feed power on a down PG&E line (or at least would make it harder for PG&E to diagnose, not counting the fact that the power grid acts as a regulator in case there is too much or not enough power).

    Anyway, I wanted to have power a bit longer than 10mn when PG&E power went out, so I looked into UPS solutions while powering from a Marine or a AGM (Absorbed Glass Material) battery, both being better options than a car battery (car batteries are not meant to be deep cycled or use for extended periods of time and they do put out hydrogen when you charge them, which is undesireable inside a house).

    Interesting bits I found out:

  • This page http://www.type2.com/library/electrip/battbas.htm has decent battery info, and this one gives a bit more about AGM batteries http://www.windsun.com/Batteries/Battery_FAQ.htm . Yet, even marine or AGM batteries are not meant to be discharged at high rate. If you do, they may not even put out half their rated capacity.
  • UPSes aren't meant to be used as inverters for long time power off situations. Some will actually use more than one battery (increases voltage, decreases amps, which is good for lowering draw, but makes it a pain when you need multiple big matching marine batteries).
  • Drawing 1400VA from an APC UPS at 24V is about 60A! That's about 3-4 times what the average copper wire going to your house outlet is supposed to carry. These pages: http://en.wikipedia.org/wiki/American_wire_gauge and http://www.powerstream.com/Wire_Size.htm give some guidelines, but long story short, you need a very thick wire to carry that many amps over more than 10cm without heating up your wires (never good) and wasting a lot of power through resistive loss.
    I first quadrupled up my initial wire but then realized that it only took me from 18 gauge to 12 gauge, which was a bit low, so doubled that up with a cable I cut off from a jumpstart cable (that one was plenty thick, it was more an issue to solder it to the rest due to how massive it was and how underpowered my soldering iron was for the job).
  • In the end, I got a couple of mostly matching AGM batteries and went ahead with those for my 24V APC 1400 SmartUPS. I know my runtime wouldn't be fantastic but good enough considering (at least until I can find another free marine battery :) ).

    At 400W of actual use, that was 40% of the load for the APC 1400 inverter and a self test estimated that I would get about 1H of runtime, which gave 16Ah usable for my AGM batteries instead of about 55Ah at a lower draw (when new, and they were not new). It's a bit disappointing on one side, but on the other side, 1H of runtime for my computer gear ain't too bad, especially for AGM batteries that cost $20 a pieces (cheaper than the stock 7Ah batteries).


    first I quadrupled the wire.
    first I quadrupled the wire.

    this is a big ass gauge jumper cable
    this is a big ass gauge jumper cable

    what it looks like connected
    what it looks like connected


    Anyway, even if this isn't quite the runtime I was hoping for, and it seems hard to find any UPS with a good VA rating by using a single 12V battery (not too surprising due to the amp problem I pointed out), this is still pretty cool.


    More pages: March 2004 March 2009 May 2009 August 2009 November 2009 December 2009 February 2010 March 2010 June 2010 August 2010 March 2011 July 2011 August 2011 November 2011 January 2013 November 2013 December 2013 July 2014