Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550

Deprecated: (yfarjoun) preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /afs/athena.mit.edu/user/y/f/yfarjoun/web_scripts/homepage/includes/Sanitizer.php on line 1550
House Sensors - Yossi Farjoun's Homepage

House Sensors

From Yossi Farjoun's Homepage
(Difference between revisions)
Jump to: navigation, search
Line 12: Line 12:
  
 
1. As [http://www.maximintegrated.com/app-notes/index.mvp/id/203 here] and [http://ww.hobby-boards.com/store/pages/Wiring-Diagram.html here], I connected the two left pins to  the middle wires in a rj12 cable.
 
1. As [http://www.maximintegrated.com/app-notes/index.mvp/id/203 here] and [http://ww.hobby-boards.com/store/pages/Wiring-Diagram.html 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 installed...so I installed them using apt-get install.  
 
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 installed...so I installed them using apt-get install.  
 
   sudo apt-get install libfuse-dev libusb php5 libfuse-dev php5-dev
 
   sudo apt-get install libfuse-dev libusb php5 libfuse-dev php5-dev
Line 17: Line 18:
 
   opt/owfs/bin/owfs -u /mnt/1-wire/ --allow-other  
 
   opt/owfs/bin/owfs -u /mnt/1-wire/ --allow-other  
 
to rc.local so that it is started up everytime I booted.
 
to rc.local so that it is started up everytime I booted.
 +
 
3. At this point, I could already see the sensors:  
 
3. At this point, I could already see the sensors:  
 
   ~$ ls /mnt/1-wire/
 
   ~$ ls /mnt/1-wire/
Line 26: Line 28:
 
       -21.1875  
 
       -21.1875  
 
Telling me that the current temperature (inside the freezer) is -21C
 
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  
 
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
 
   thermd -daemon
 
I then added that line to the /etc/rc.local as well.
 
I then added that line to the /etc/rc.local as well.
6. I changed the hostname in /etc/hostname (to snowy) and added a line in /etc/hosts:
+
 
 +
5. I changed the hostname in /etc/hostname (to snowy) and added a line in /etc/hosts:
 
   192.168.15.7    snowy snowy.
 
   192.168.15.7    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.
 
Since I decided to name the machine snowy and I've decided on the fixed internal address it will have on the router.
7. The router also needed to be told to route port 22 and 80 to that machine.  
+
 
8. I opened a free "no-ip" account and created a hostname snowy-farjoun.no-ip.org 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 snowy.farjoun.org to snowy-farjoun.no-ip.org. I tested this with ping (I think).
+
6. The router also needed to be told to route port 22 and 80 to that machine.
9. sshd needs to be installed (for remote administration) apt-get install sshd (probably needs hardening..but "I'll do that later")
+
10. The computer needs to be told not to use DHCP, what are its address, router, network mask and some DNS servers.  
+
7. I opened a free "no-ip" account and created a hostname snowy-farjoun.no-ip.org 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 snowy.farjoun.org to snowy-farjoun.no-ip.org. I tested this with ping (I think).
11. apache2 was installed (apt-get install apache2?) and configured the default site in /etc/apache2/sites-available/default:
+
 
 +
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)
 
(only changes shown)
 
     ServerAdmin farjoun@gmail.com
 
     ServerAdmin farjoun@gmail.com
Line 48: Line 58:
 
         </Directory>
 
         </Directory>
 
At this point, the website should be visible. Check /var/log/apache2/error.log for hints if it isn't working.
 
At this point, the website should be visible. Check /var/log/apache2/error.log for hints if it isn't working.
12. For mailing me when alert conditions happen I installed sSMTP ( apt-get install ssmtp ) and configured it with the following configuration file:
+
 
 +
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  
 
  ~$ cat /etc/ssmtp/ssmtp.conf  
 
   mailhub=mail.farjoun.org:465
 
   mailhub=mail.farjoun.org:465

Revision as of 04:08, 26 November 2012

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 installed...so I installed them using apt-get install.

  sudo apt-get install libfuse-dev libusb php5 libfuse-dev php5-dev

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
      -21.1875 

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:

  192.168.15.7    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 snowy-farjoun.no-ip.org 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 snowy.farjoun.org to snowy-farjoun.no-ip.org. 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 farjoun@gmail.com
    ...  
          ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
         <Directory "/usr/lib/cgi-bin">
               AllowOverride None
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all
        </Directory>

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 
  mailhub=mail.farjoun.org:465
  UseTLS=YES                             # Secure connection (SSL/TLS)
  FromLineOverride=YES                   # Force the From: line
  Hostname=snowy.farjoun.org       # The name of this host
  RewriteDomain=farjoun.org        # 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  
  FromLineOverride=YES

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

Personal tools