Updates:
Work continues on adding gravity sensor support to Fermentrack -- but there isn't much to show for it just yet. I've spent quite a bit of time over the past few weeks playing with ideas of how gravity sensor support
could work, but finally think I know how to get everything stitched together.
Although work on Fermentrack up until now has focused on BrewPi support, the goal for specific gravity sensor support is to have the sensors be a top-level device -- similar to how BrewPi controllers are now. What this means is that it will be possible to use Fermentrack to track/log/control specific gravity sensors even if you don't have a BrewPi controller built/available. When you set up a specific gravity sensor within Fermentrack a separate script from that which tracks BrewPi temperatures will launch, and separate log files will be written out.
That said, implementing specific gravity sensors in this way means that the SG data won't be available to brewpi-script when writing out
its log files which is a problem for people who would like to track SG alongside the rest of their fermentation data. Initially I wanted to just write out the latest log entry to a file which brewpi-script could read, but after thinking about it I figured this would unnecessarily generate a number of writes to the SD card, which could potentially result in it dying sooner than it otherwise would. Having had to recover dead Raspberry Pis in the past I'd rather avoid this if possible.
The solution I ultimately settled on is a third party program called 'memcached'. As the script that monitors the Tilt (or another SG sensor) receives SG data back it will store the latest data point in memcached. As brewpi-script writes data points out to a file, it will read whatever the latest data point is from memcached and store that alongside the BrewPi-driven temperature data. Added bonus - because memcached stores everything in memory, it won't prematurely kill the SD card. Benefits!
Here's how all that looks in flowchart form:
The only drawback to all this is that - for current users of Fermentrack - the upgrade to add specific gravity sensor support unfortunately won't be seamless. When it's released, you'll need to log into your Raspberry Pi and run a command as root to install memcached (and a handful of other Python packages which can't be installed via PyPi). Should be a pretty simple fix, when the time comes!