Skip to content

Commit

Permalink
Adding some entries from the brewery Wordpress blog
Browse files Browse the repository at this point in the history
  • Loading branch information
z3ugma committed Dec 11, 2014
1 parent 29ab547 commit 3486cd6
Show file tree
Hide file tree
Showing 24 changed files with 1,118 additions and 182 deletions.
59 changes: 59 additions & 0 deletions _posts/2013-10-24-homebrew-temperature-monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
layout: post
title: "Homebrew Temperature Monitoring"
date: 2013-10-24 20:50:55 -0500
comments: true
published: true
---

A few weeks ago, I embarked on a project to monitor the temperature of my homebrews as they ferment and bottle-age.

###The Data###

In order to record temperatures, I ordered 3 TEMPer temperature-logging modules from eBay. These were recommended by lots of homebrewers on HomeBrewTalk as cheap and effective, although occasionally users reported large variances in temperatures and DOA sensors.

![The product ad](//images/usbtemper.png)

These are manufactured by PCsensor.com, which provides a linux command-line client to read the data of the thermometer.

I ordered three, and hooked them up to my brewery server.

###The First Hiccup###

The problem I encountered is that the pcsensor software was only designed to display one result at a time, and wasn't configured for displaying multiple sensors. Luckily, I found a fork of the project that had been edited to allow that: http://momtchil.momtchev.com/node/6. Here's a good guide I followed: http://www.penguinsunbound.com/User:goeko/Temp_Sensor

Using lsusb | grep TEMPer, I was able to confirm that the computer was reading my sensors. I installed the pcsensor-multi software:

{% highlight bash %}
wget http://momtchil.momtchev.com/files/pcsensor-1.0.0-multi.tgz
tar -zxvf pcsensor-1.0.0-multi.tgz
cd pcsensor-1.0.0
make
{% endhighlight %}

And moved it into /usr/bin/local.

###Logging Temperatures###

At this point, I could enter the pcsensor command and get output:

2011/12/08 14:09:16 Temperature 65.19F 18.44C
2011/12/08 14:09:16 Temperature 61.59F 16.44C

But I wouldn't be around all day to check out the temperatures. I set up a cron job to write the temperatures to a log:

{% highlight text %}
# m h dom mon dow command
* * * * * /usr/local/bin/pcsensor >> /home/fred/temperatures.log
{% endhighlight %}

This reads as: ALL minutes (m) of ALL hours (h) of ALL days of the month on ALL days of the week, run the pcsensor program and add the output to the file "temperatures.log".
So, every minute, the server adds temperature data to the log.

###Graphing the Data###

![A Google Chart graph](//images/googlechart.png)

The Penguins Unbound link uses gnuplot to graph the data, an approach that I might take up in the future. However, I wanted to use the Google Charts API to generate my graphs.

Since the temperature sensors work as USB Human Input devices.
61 changes: 61 additions & 0 deletions _posts/2013-10-24-homebrew-temperature-monitoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
layout: post
title: "Homebrew Temperature Monitoring"
date: 2013-10-24 20:50:55 -0500
comments: true
published: true
---

A few weeks ago, I embarked on a project to monitor the temperature of my homebrews as they ferment and bottle-age.

###The Data###

In order to record temperatures, I ordered 3 TEMPer temperature-logging modules from eBay. These were recommended by lots of homebrewers on HomeBrewTalk as cheap and effective, although occasionally users reported large variances in temperatures and DOA sensors.

![The product ad](/images/usbtemper.png)

These are manufactured by PCsensor.com, which provides a linux command-line client to read the data of the thermometer.

I ordered three, and hooked them up to my brewery server.

###The First Hiccup###

The problem I encountered is that the pcsensor software was only designed to display one result at a time, and wasn't configured for displaying multiple sensors. Luckily, I found [a fork of the project that had been edited to allow that](http://momtchil.momtchev.com/node/6) by following [this guide](http://webcache.googleusercontent.com/search?q=cache:www.penguinsunbound.com/User:goeko/Temp_Sensor)

Using lsusb | grep TEMPer, I was able to confirm that the computer was reading my sensors. I installed the pcsensor-multi software:

{% highlight bash %}
wget http://momtchil.momtchev.com/files/pcsensor-1.0.0-multi.tgz
tar -zxvf pcsensor-1.0.0-multi.tgz
cd pcsensor-1.0.0
make
{% endhighlight %}

*(note: a backed-up copy of the pcsensor program can be found [here](/files/pcsensor-1.0.0-multi.tgz))*

And moved it into /usr/bin/local.

###Logging Temperatures###

At this point, I could enter the pcsensor command and get output:

2011/12/08 14:09:16 Temperature 65.19F 18.44C
2011/12/08 14:09:16 Temperature 61.59F 16.44C

But I wouldn't be around all day to check out the temperatures. I set up a cron job to write the temperatures to a log:

{% highlight text %}
# m h dom mon dow command
* * * * * /usr/local/bin/pcsensor >> /home/fred/temperatures.log
{% endhighlight %}

This reads as: ALL minutes (m) of ALL hours (h) of ALL days of the month on ALL days of the week, run the pcsensor program and add the output to the file "temperatures.log".
So, every minute, the server adds temperature data to the log.

###Graphing the Data###

![A Google Chart graph](/images/googlechart.png)

The Penguins Unbound link uses gnuplot to graph the data, an approach that I might take up in the future. However, I wanted to use the Google Charts API to generate my graphs.

To be continued: the exciting saga of why you don't try to parse thousands of lines of text as a time-series database.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
layout: post
title: "Keeping VirtualBox and Vagrant Boxes Alive Through Reboots"
date: 2014-12-10 13:50:55 -0500
comments: true
published: true
---

I recently switched from a dedicated Windows 7 PC for my home server to a Mac Mini, mostly for the better electricity consumption and the fact the the PC was having nightly bluescreen crashes and restarting.

I have always been a fan of RDP, and my office uses PCs - so to keep the convenient RDP access to home, I installed [VirtualBox](www.virtualbox.org) and created a Windows VM. This has a bridged network adapter, so it just looks like another computer on my home network.

However, when Mac OS restarts, or after a power failure, the virtual machine is powered off. This won't do.

##Daemons in Mac OS##

Mac OS has the usual suspects like cron, but has a neat daemon launching system, appropriately called [launchd](https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html), introduced in 10.4.

Launchd works by "loading" (think of it like a soft-install) objects called '''plist'''. Plist is a serialized object format like JSON or XML that tells launchd the properties of how to execute a particular daemon.

If you want to play with creating your own plists, head over to [http://launched.zerowidth.com](http://launched.zerowidth.com), where Nathan Witmer has created a plist generator.

##Automatic Tasks in VirtualBox##

VirtualBox comes with a command-line interface to automate tasks on VMs. My need is simple - just boot the box:

{% highlight bash %}
VBoxHeadless -s Windows -v on
{% endhighlight %}

This follows the syntax for VBoxHeadless:

{% highlight text %}
-s, -startvm, --startvm <name|uuid> Start given VM (required argument)
-v, -vrde, --vrde on|off|config Enable (default) or disable the VRDE server or don't change the setting
{% endhighlight %}

VRDE is the Virtual Remote Desktop extension, which allows RDP out of the box through a special Oracle tool.

##Booting my VM at Login##

launchd has multiple "runlevels" - there are System level daemons, and daemons for whenever a given user logs in. User daemons are stored at ~/Library/LaunchAgents/.

With the help of the launched tool, I made a plist for my command:


{% highlight xml %}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>io.zzzz.z3ugma.launched.windowsvirtualbox</string>
<key>ProgramArguments</key>
<array>
<string>VBoxHeadless</string>
<string>-s</string>
<string>Windows</string>
<string>-v</string>
<string>on</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>fred</string>
<key>WorkingDirectory</key>
<string>/Users/fred</string>
<key>StandardErrorPath</key>
<string>/Users/fred/windowsvm.log</string>
<key>StandardOutPath</key>
<string>/Users/fred/windowsvm.log</string>
</dict>
</plist>
{% endhighlight %}

Notable options in here:

* **KeepAlive = True** - If the VBoxHeadless process crashes for some reason, or someone manually shuts down the box (perhap from within RDP), the box restarts itself
* **RunAtLoad = True** - Run this daemon when the daemon is loaded. "Loading" occurs at login, and when a user manually loads the daemon.
* **WorkingDirectory** & **UserName** - These are special directives needed because of the peculiar way that VirtualBox runs. Just set it to the home folder of the user running the daemon.

This xml is saved into a file in ~/Library/LaunchAgents. Navigate to that directory, and execute

{% highlight text %}
launchctl load <name of plist>
{% endhighlight %}

*launchctl* is the program that Mac OS uses to control launchd processes. Once the plist has been loaded, it should persist after reboot.

A similar plist can be used for the command 'vagrant up' to launch vagrant vms.

179 changes: 179 additions & 0 deletions _site/2013/10/24/homebrew-temperature-monitoring/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">

<head>
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<!-- Enable responsiveness on mobile devices-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

<title>

Homebrew Temperature Monitoring &middot; Python Monty

</title>

<!-- CSS -->
<link rel="stylesheet" href="/public/css/poole.css">
<link rel="stylesheet" href="/public/css/syntax.css">
<link rel="stylesheet" href="/public/css/hyde.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu">

<!-- Icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-144-precomposed.png">
<link rel="shortcut icon" href="/public/favicon.ico">

<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">
</head>


<body class="theme-base-0d">

<div class="sidebar">
<div class="container sidebar-sticky">
<div class="sidebar-about">
<img src="https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/10565135_10103350446465307_2243295731634219240_n.jpg?oh=3ac00bd4b91147d87dcdde0c775d96a2&oe=551C5DF6&__gda__=1426461091_247303f7a3e20c9f3e67cef994dd2bf9" height="200"/>
<h1>
<a href="/">
Python Monty
</a>
</h1>
<p class="lead">Explaining the terrible code I write as I go. Mostly in Python</p>
</div>

<nav class="sidebar-nav">
<a class="sidebar-nav-item" href="/">Home</a>















<a class="sidebar-nav-item" href="/archive/">Archive</a>













</nav>

<p>&copy; 2014. All rights reserved.</p>
</div>
</div>


<div class="content container">
<div class="post">
<h1 class="post-title">Homebrew Temperature Monitoring</h1>
<span class="post-date">24 Oct 2013</span>
<p>A few weeks ago, I embarked on a project to monitor the temperature of my homebrews as they ferment and bottle-age.</p>

<h3>The Data</h3>

<p>In order to record temperatures, I ordered 3 TEMPer temperature-logging modules from eBay. These were recommended by lots of homebrewers on HomeBrewTalk as cheap and effective, although occasionally users reported large variances in temperatures and DOA sensors.</p>

<p><img src="/images/usbtemper.png" alt="The product ad"></p>

<p>These are manufactured by PCsensor.com, which provides a linux command-line client to read the data of the thermometer.</p>

<p>I ordered three, and hooked them up to my brewery server.</p>

<h3>The First Hiccup</h3>

<p>The problem I encountered is that the pcsensor software was only designed to display one result at a time, and wasn&#39;t configured for displaying multiple sensors. Luckily, I found <a href="http://momtchil.momtchev.com/node/6">a fork of the project that had been edited to allow that</a> by following <a href="http://webcache.googleusercontent.com/search?q=cache:www.penguinsunbound.com/User:goeko/Temp_Sensor">this guide</a></p>

<p>Using lsusb | grep TEMPer, I was able to confirm that the computer was reading my sensors. I installed the pcsensor-multi software:</p>

<div class="highlight"><pre><code class="language-bash" data-lang="bash">wget http://momtchil.momtchev.com/files/pcsensor-1.0.0-multi.tgz
tar -zxvf pcsensor-1.0.0-multi.tgz
<span class="nb">cd </span>pcsensor-1.0.0
make</code></pre></div>

<p><em>(note: a backed-up copy of the pcsensor program can be found <a href="/files/pcsensor-1.0.0-multi.tgz">here</a>)</em></p>

<p>And moved it into /usr/bin/local.</p>

<h3>Logging Temperatures</h3>

<p>At this point, I could enter the pcsensor command and get output:</p>

<p>2011/12/08 14:09:16 Temperature 65.19F 18.44C
2011/12/08 14:09:16 Temperature 61.59F 16.44C</p>

<p>But I wouldn&#39;t be around all day to check out the temperatures. I set up a cron job to write the temperatures to a log:</p>

<div class="highlight"><pre><code class="language-text" data-lang="text"># m h dom mon dow command
* * * * * /usr/local/bin/pcsensor &gt;&gt; /home/fred/temperatures.log</code></pre></div>

<p>This reads as: ALL minutes (m) of ALL hours (h) of ALL days of the month on ALL days of the week, run the pcsensor program and add the output to the file &quot;temperatures.log&quot;.
So, every minute, the server adds temperature data to the log.</p>

<h3>Graphing the Data</h3>

<p><img src="/images/googlechart.png" alt="A Google Chart graph"></p>

<p>The Penguins Unbound link uses gnuplot to graph the data, an approach that I might take up in the future. However, I wanted to use the Google Charts API to generate my graphs.</p>

<p>To be continued: the exciting saga of why you don&#39;t try to parse thousands of lines of text as a time-series database.</p>

</div>

<div class="related">
<h2>Related Posts</h2>
<ul class="related-posts">

<li>
<h3>
<a href="/2014/12/10/keeping-virtualbox-and-vagrant-boxes-alive-through-reboots/">
Keeping VirtualBox and Vagrant Boxes Alive Through Reboots
<small>10 Dec 2014</small>
</a>
</h3>
</li>

<li>
<h3>
<a href="/2014/12/10/keeping%20virtualbox%20and%20vagrant%20boxes%20alive%20through%20reboots/">
Keeping VirtualBox and Vagrant Boxes Alive Through Reboots
<small>10 Dec 2014</small>
</a>
</h3>
</li>

<li>
<h3>
<a href="/2014/12/07/A-new-platform/">
A new platform
<small>07 Dec 2014</small>
</a>
</h3>
</li>

</ul>
</div>

</div>

</body>
</html>
Loading

0 comments on commit 3486cd6

Please sign in to comment.