The Great Bottle Opener Giveaway

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

Reply
 
LinkBack Thread Tools
Old 12-07-2012, 03:42 AM   #241
bfinleyui
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2012
Posts: 340
Liked 13 Times on 13 Posts
Likes Given: 44

Default

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: Nothing
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning: Russian Imperial Stout
On Deck: DIPA w/Heady Topper Yeast
bfinleyui is offline
 
Reply With Quote Quick reply to this message
Old 12-07-2012, 03:47 PM   #242
bikesnbeers
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: May 2009
Location: Sacramento, CA
Posts: 112
Liked 5 Times on 5 Posts

Default

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!

__________________
bikesnbeers is offline
 
Reply With Quote Quick reply to this message
Old 12-07-2012, 04:23 PM   #243
bfinleyui
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2012
Posts: 340
Liked 13 Times on 13 Posts
Likes Given: 44

Default

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: Nothing
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning: Russian Imperial Stout
On Deck: DIPA w/Heady Topper Yeast
bfinleyui is offline
 
Reply With Quote Quick reply to this message
Old 12-07-2012, 04:33 PM   #244
mrgstiffler
HBT_SUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: May 2009
Location: Newberg, OR, Cascadia
Posts: 1,088
Liked 92 Times on 77 Posts
Likes Given: 1

Default

Heh, I saw what you did... I've made the same mistake before.

__________________
Simple BIAB Calculator
mrgstiffler is offline
 
Reply With Quote Quick reply to this message
Old 12-07-2012, 05:18 PM   #245
bfinleyui
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2012
Posts: 340
Liked 13 Times on 13 Posts
Likes Given: 44

Default

Lol. The host limiting would have saved me anyway, it's only accepting connections from localhost or my home isp

__________________
Primary: Nothing
Bottled: Cinnamon Apple Cider, Two Hearted Clone, FW Double Jack Clone
Kegged: Milk Chocolate Stout/Porter Partigyle, Graff
Conditioning: Russian Imperial Stout
On Deck: DIPA w/Heady Topper Yeast
bfinleyui is offline
 
Reply With Quote Quick reply to this message
Old 12-07-2012, 08:09 PM   #246
bikesnbeers
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: May 2009
Location: Sacramento, CA
Posts: 112
Liked 5 Times on 5 Posts

Default

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.

__________________
bikesnbeers is offline
 
Reply With Quote Quick reply to this message
Old 12-19-2012, 04:47 PM   #247
GatorDad
Feedback Score: 0 reviews
Recipes 
 
Join Date: Mar 2011
Location: Brandon, Florida
Posts: 234
Liked 5 Times on 4 Posts
Likes Given: 20

Default

nice work guys...

__________________

cheers & beers,
Chris

Monitor/control with Linux
You know your IPA - do you know your PSA?

GatorDad is offline
 
Reply With Quote Quick reply to this message
Old 06-11-2013, 06:00 PM   #248
Yuri_Rage
Gritty.
HBT_MODERATOR.png
Feedback Score: 0 reviews
 
Yuri_Rage's Avatar
Recipes 
 
Join Date: Jul 2006
Location: Southwest
Posts: 13,893
Liked 598 Times on 370 Posts
Likes Given: 54

Default

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
Yuri_Rage is offline
 
Reply With Quote Quick reply to this message
Reply


Quick Reply
Message:
Options
Thread Tools


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