House Sensors

From Yossi Farjoun's Homepage
Jump to: navigation, search

As we have bought a new house with a basement, and we plan to put our chest freezer there, I started worrying about the time it would take us to notice a malfunction in the freezer, the lid left ajar, or a power-outage while we are gone. I decided to monitor the freezer with the following setup:

  • A dedicated "server" (currently acer one running ubuntu desktop, but I'm thinking of changing that)
  • "1-wire" temperature sensor DS18B20 and 1-Wire USB Adaptor from Hobby Boards
  • owfs filesystem to poll the sensor
  • thermd to log the data, present it in a website and issue emails in case of problems
  • sSMTP on the server to take care of the email.
  • DNS records updated using a DreamHost hosting and No-Ip free DynDNS service
  • apache2 Server to serve up the website

I'll try to record the steps I took to make it easier for me to do again, and for others to emulate...

1. As here and here, I connected the two left pins to the middle wires in a rj12 cable.

2. I installed owfs by downloading and running configure && make & make install. this had some errors as long as I didn't have enough packages I installed them using apt-get install.

  sudo apt-get install libfuse-dev libusb php5 php5-dev ssh build-essential libusb-dev make libgd-gd2-perl  libhttp-date-perl libconfig-general-perl libgd-graph-perl

I added the command

  /opt/owfs/bin/owfs -u /mnt/1-wire/ --allow_other 

to rc.local so that it is started up everytime I booted.

3. At this point, I could already see the sensors:

  ~$ ls /mnt/1-wire/
  28.06F625030000  81.7F9230000000  alarm  bus.0  settings  simultaneous  statistics  structure  system  uncached
  ~$ ls /mnt/1-wire/28.06F625030000/
  address  crc8    family    id       power      r_id       temperature    temperature11  temperature9  templow
  alias    errata  fasttemp  locator  r_address  r_locator  temperature10  temperature12  temphigh      type
  ~$ cat  /mnt/1-wire/28.06F625030000/temperature

Telling me that the current temperature (inside the freezer) is -21C.

4. For logging this data I downloaded thermd. to install it a few perl packages are needed so I installed them (again using apt-get). After editing the configuration file and putting it in its place ( /etc/thermd.conf ) making a directory for the datafiles (mkdir /var/log/thermd ) and copying the script to its place ( /usr/local/bin/thermd ) one can run it

  thermd -daemon

I then added that line to the /etc/rc.local as well.

5. I changed the hostname in /etc/hostname (to snowy) and added a line in /etc/hosts:    snowy snowy.

Since I decided to name the machine snowy and I've decided on the fixed internal address it will have on the router.

6. The router also needed to be told to route port 22 and 80 to that machine.

7. I opened a free "no-ip" account and created a hostname pointing at snowy. I also installed the client on snowy (apt get didn't work so I did the other way). on my domain registrar I added a CNAME entry pointing from to I tested this with ping (I think).

8. sshd needs to be installed (for remote administration) apt-get install sshd (probably needs hardening..but "I'll do that later")

9. The computer needs to be told not to use DHCP, what are its address, router, network mask and some DNS servers.

10. apache2 was installed (apt-get install apache2?) and configured the default site in /etc/apache2/sites-available/default: (only changes shown)

    ServerAdmin <my gmail address>
          ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
         <Directory "/usr/lib/cgi-bin">
               AllowOverride None
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all

At this point, the website should be visible. Check /var/log/apache2/error.log for hints if it isn't working.

11. For mailing me when alert conditions happen I installed sSMTP ( apt-get install ssmtp ) and configured it with the following configuration file:

~$ cat /etc/ssmtp/ssmtp.conf
  UseTLS=YES                             # Secure connection (SSL/TLS)
  FromLineOverride=YES                   # Force the From: line       # The name of this host        # The host the mail appears to be coming from
  Root=yossi                 # Redirect mail for root@ to postmaster@
  AuthUser=mySMTP User             # Your DreamHost mail account
  AuthPass=mySMTP Password  

I tested the email configuration using thermd -checkconfig -email verifying that I got an email from the daemon.

TODO: add a ping from my hosting service to see if snowy is me if not.

Personal tools