Monitoring/controlling with Linux on the cheap - Page 25 - Home Brew Forums

Register Now!
Home Brew Forums > Home Brewing Beer > DIY Projects > Fermenters > Monitoring/controlling with Linux on the cheap

Reply
 
Thread Tools
Old 12-07-2012, 04:42 AM   #241
bfinleyui
Recipes 
 
Nov 2012
Posts: 422
Liked 19 Times on 19 Posts


Not kokomo, but I'm using PHP to pull the data out of a mysql database and display it using a simple line graph from the google chart API. You can check out the code I used (basically copied and pasted, replaced with data) here
__________________
Primary: None
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: House Pale Ale, Russian Imperial Stout, Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning:
On Deck: DIPA w/Heady Topper Yeast, Winter Warmer, Imperial Red

 
Reply With Quote
Old 12-07-2012, 04:47 PM   #242
bikesnbeers
HBT_LIFETIMESUPPORTER.png
Recipes 
 
May 2009
Sacramento, CA
Posts: 119
Liked 5 Times on 5 Posts


bfinleyui- that's pretty much what I'm trying to accomplish. I have no experience with PHP or mysql. I looked at the page source, but I don't see any reference to PHP or mysql. Can you give me a hint? Thanks!

 
Reply With Quote
Old 12-07-2012, 05:23 PM   #243
bfinleyui
Recipes 
 
Nov 2012
Posts: 422
Liked 19 Times on 19 Posts


I don't have the python script handy, I can post that when I get home, but here's what I can show...

- Python script (running on a cron job) polls the temp sensor once a minute, and sends the data t
to a mysql database running on my webhost.

- Then I just have a PHP script that you can hit, and here's the code for that, commented where needed, lemme know if you have issues.

Code:
<?php

// Connec to the database
mysql_connect("DATABASEHOST", "DATABASEUSER", "DATABASEPASSWORD");
mysql_select_db("DATABASENAME");

// Run query for all temp readings, oldest first.
$result = mysql_query("SELECT * FROM readings order by reading_time desc ");

// Initialize a blank array
$temps = array();

// Push those temperatures into the array, using the time as the key
while ($row = mysql_fetch_array($result)) {
        $temps[strtotime($row['reading_time'])] = $row['reading'];

}


?>


<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

        function mysqlTimeStampToDate(timestamp) {
          //function parses mysql datetime string and returns javascript Date object
          //input has to be in this format: 2007-06-05 15:26:02
          var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
          var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
          return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
        }


        // Initialization code from Google
        google.load("visualization", "1", {packages:["corechart"]});
        google.setOnLoadCallback(drawChart);


        function drawChart() {

                //  Setup the column name and types
                var data = new google.visualization.DataTable();
                data.addColumn('datetime','Time');
                data.addColumn('number', 'Temp');

                // Add rows of data
                data.addRows([
                <?php

                        // Iterate through that php array, echoing it out in [date, temp] format, a javascript array.
                        foreach ($temps as $k => $v) {
                                echo "[new Date(" . $k . " * 1000), " . $v ."],\n";
                        }
                ?>
                ]);

                var options = {
                        title: 'Fermentation Chamber'
                };


                var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
                chart.draw(data, options);
      }
    </script>
  </head>

  <body>

    <div id="chart_div" style="width: 100%; height: 600px;"></div>
  </body>
</html>
__________________
Primary: None
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: House Pale Ale, Russian Imperial Stout, Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning:
On Deck: DIPA w/Heady Topper Yeast, Winter Warmer, Imperial Red

 
Reply With Quote
Old 12-07-2012, 05:33 PM   #244
mrgstiffler
 
mrgstiffler's Avatar
Recipes 
 
May 2009
Newberg, OR, Cascadia
Posts: 1,045
Liked 95 Times on 79 Posts


Heh, I saw what you did... I've made the same mistake before.
__________________
Simple BIAB Calculator

 
Reply With Quote
Old 12-07-2012, 06:18 PM   #245
bfinleyui
Recipes 
 
Nov 2012
Posts: 422
Liked 19 Times on 19 Posts


Lol. The host limiting would have saved me anyway, it's only accepting connections from localhost or my home isp
__________________
Primary: None
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: House Pale Ale, Russian Imperial Stout, Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning:
On Deck: DIPA w/Heady Topper Yeast, Winter Warmer, Imperial Red

 
Reply With Quote
Old 12-07-2012, 09:09 PM   #246
bikesnbeers
HBT_LIFETIMESUPPORTER.png
Recipes 
 
May 2009
Sacramento, CA
Posts: 119
Liked 5 Times on 5 Posts


I see that php works on the server side. That's a little out of my league right now. I'm thinking that I can use the spreadsheet and google query to fill in the chart. Thanks for the info. I'd still like to see the python if you get a chance. If you want the chart to auto update, do you have to refresh the page? I'm looking at the gauge chart too. Thanks.

 
Reply With Quote
Old 12-19-2012, 05:47 PM   #247
GatorDad
 
GatorDad's Avatar
Recipes 
 
Mar 2011
Brandon, Florida
Posts: 229
Liked 5 Times on 4 Posts


nice work guys...

 
Reply With Quote
Old 06-11-2013, 06:00 PM   #248
Yuri_Rage
Gritty.
HBT_MODERATOR.png
 
Yuri_Rage's Avatar
Recipes 
 
Jul 2006
Southwest
Posts: 14,289
Liked 808 Times on 512 Posts


I finally discovered the problem with my temperature inaccuracies. My DIY thermowells are causing 100% of the errors. When I took the probes out of the kettles and dunked them in water, they measured exactly the same as my calibrated thermometer. Installing them in the kettles results in a somewhat linear error likely caused by conduction in the kettle walls. The error is likely volume dependent, so I can't just fit a curve to correct the installation error. On one hand, I'm glad all of the electronics are working properly. On the other hand, I guess I'm going to need new thermowells!
__________________
Homebrewed Blog..........YouTube Channel .......... Shirts, posters, etc

 
Reply With Quote
Reply
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Temperature Monitoring and Control with Arduino erock2112 Fermenters 85 04-05-2011 07:46 PM
Controlling Wort Flow capnr0n Brew Stands 12 03-16-2010 04:00 AM
Temperature Controlled Brewcloset with remote monitoring Mista_Sparkle Fermenters 1 11-26-2009 08:53 AM
Monitoring temp on the cheap... tireater Brew Stands 20 04-15-2009 07:06 PM
Basic ambient temperature monitoring jasper9 Fermenters 8 01-01-2009 12:19 AM


Forum Jump