House Sensors
Line 11: | Line 11: | ||
I'll try to record the steps I took to make it easier for me to do again, and for others to emulate... | I'll try to record the steps I took to make it easier for me to do again, and for others to emulate... | ||
− | + | # 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. | |
− | + | # 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 | ||
I added the command | I added the command | ||
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. | ||
− | + | # At this point, I could already see the sensors: | |
− | + | ||
~$ ls /mnt/1-wire/ | ~$ ls /mnt/1-wire/ | ||
28.06F625030000 81.7F9230000000 alarm bus.0 settings simultaneous statistics structure system uncached | 28.06F625030000 81.7F9230000000 alarm bus.0 settings simultaneous statistics structure system uncached | ||
Line 28: | Line 26: | ||
-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 | ||
− | + | #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. | ||
− | + | #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. | ||
− | + | # The router also needed to be told to route port 22 and 80 to that machine. | |
− | + | # 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). | |
− | + | # sshd needs to be installed (for remote administration) apt-get install sshd (probably needs hardening..but "I'll do that later") | |
− | + | # The computer needs to be told not to use DHCP, what are its address, router, network mask and some DNS servers. | |
− | + | # 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 | + | ServerAdmin <my gmail address> |
... | ... | ||
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | ||
Line 58: | Line 48: | ||
</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. | ||
− | + | # 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:10, 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...
- As here and here, I connected the two left pins to the middle wires in a rj12 cable.
- 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.
- 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
- 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.
- 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.
- The router also needed to be told to route port 22 and 80 to that machine.
- 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).
- sshd needs to be installed (for remote administration) apt-get install sshd (probably needs hardening..but "I'll do that later")
- The computer needs to be told not to use DHCP, what are its address, router, network mask and some DNS servers.
- 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 </Directory>
At this point, the website should be visible. Check /var/log/apache2/error.log for hints if it isn't working.
- 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.