Kegconnection Complete Starter Kit and More Giveaway!


Home Brew Forums > Home Brewing Beer > DIY Projects > Arduino temp controller

Reply
 
LinkBack Thread Tools
Old 06-11-2014, 05:26 PM   #1
jakwi
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2013
Posts: 16
Default Arduino temp controller

Hi all,

I've been trying to duplicate the arduino based pid temperature controller that is described over at fermentation riot. So far I've installed wamp, setup the mysql table and edited the php code to reflect my login info etc.

I'm excited to set this up to control my HLT temp, but I seem to be stuck. When I pull up the dashboard.php I get a couple of indications that the commands I am using are deprecated and will be removed in the future, mysql* vs mysqli*. In my mind that means that it should still work, and yet I don't get a graph. I have data in my table, so as far as I can tell this should work. I have tried using the mysqli commands, but it doesn't make any difference, actually when I do that my web page is completely blank.

Have any of you built this or are you familiar with this type of setup? I have about two days invested in solving this last problem, but I'm not getting anywhere.

thanks for the help

dashboard.jpg  
__________________
jakwi is offline
 
Reply With Quote Quick reply to this message
Old 06-20-2014, 03:27 AM   #2
ellisgl
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2013
Location: Fort Worh, TX
Posts: 6
Likes Given: 12

Default

Add the following to the index.php:

error_reporting(E_ERROR);

__________________
ellisgl is offline
 
Reply With Quote Quick reply to this message
Old 06-20-2014, 03:52 PM   #3
jakwi
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2013
Posts: 16
Default

You are a genius thank you

__________________
jakwi is offline
 
Reply With Quote Quick reply to this message
Old 06-21-2014, 03:21 PM   #4
jakwi
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2013
Posts: 16
Default

So to be honest, I'm not sure why this fixed it, but I can't argue with the results. Thanks again for the help. Below is my dashboard.php for anyone in the future who may be trying to do this.

Code:
<html>
<head>
<meta http-equiv="refresh" content="30">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Time');
data.addColumn('number', 'Temp');
data.addColumn('number', 'Input');
data.addColumn('number', 'Setpoint');

data.addRows([
<?php
error_reporting(E_ERROR);
$db="HLT";
$link = mysql_connect('', 'jakwi', 'password');
mysql_query('SET NAMES utf8'); 
mysql_select_db($db , $link) or die("line 21 Couldn't open $db: ".mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT TIMESTAMPDIFF(MINUTE,FROM_UNIXTIME(Time), now()) as Time1, Temp, Setpoint, Input FROM temp WHERE TIMESTAMPDIFF(MINUTE,FROM_UNIXTIME(Time), now()) < 120 Order By Time");
if ($result !== false) {
$num=mysql_numrows($result);

$i=0;

echo"";

while ($i < $num) {

$time=mysql_result($result,$i,"Time1");
$temp=mysql_result($result,$i,"Temp");
$input=mysql_result($result,$i,"Input");
$setpoint=mysql_result($result,$i,"Setpoint");
echo "['";
echo "$time";
echo "',";
echo "$temp";
echo ",";
echo "$input";
echo ",";
echo "$setpoint";
echo "]";
if ($i < ($num - 1)) 
{
echo ",";
}
$i++;


}
}

 

 

?> 
]);

var options = {
width: 1000, height: 300,
hAxis: {title: 'Minutes Ago'},
vAxis: {title: 'Temperature F', maxValue: 100, minValue: 40}
};

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

<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Value');
data.addRows([
<?php
error_reporting(E_ERROR);
$db="HLT";
$link = mysql_connect('', 'jakwi', 'password');
mysql_query('SET NAMES utf8'); 
mysql_select_db($db , $link) or die("line 88 Couldn't open $db: ".mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT Time, Temp, Setpoint, Input, Kp, Ki, Kd FROM temp Order By Time desc limit 1");
if ($result !== false) {
$num=mysql_numrows($result);
$time=mysql_result($result,0,"Time");
$temp=mysql_result($result,0,"Temp");
$input=mysql_result($result,0,"Input");
$setpoint=mysql_result($result,0,"Setpoint");
$ki=mysql_result($result,0,"Ki");
$kp=mysql_result($result,0,"Kp");
$kd=mysql_result($result,0,"Kd");
echo "['Temp',";
echo "$temp";
echo "],";
echo "['PID Temp',";
echo "$input";
echo "],";
echo "['Setpoint',";
echo "$setpoint";
echo "]";
}

?> 
]);

var options2 = {
width: 600, height: 300,
minorTicks: 2, max: 212, min: 60
};

var chart = new google.visualization.Gauge(document.getElementById('chart_div2'));
chart.draw(data, options2);
}
</script>


<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Value');
data.addRows([
<?php
error_reporting(E_ERROR);
$db="HLT";
$link = mysql_connect('', 'jakwi', 'password');
mysql_query('SET NAMES utf8'); 
mysql_select_db($db , $link) or die("line 139 Couldn't open $db: ".mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT Time, Heat FROM temp Order By Time desc limit 1");
if ($result !== false) {
$num=mysql_numrows($result);
$heat=mysql_result($result,0,"Heat");

echo "['Heat %',";
echo "$heat";
echo "]";

}

?> 
]);

var options3 = {
width: 200, height: 300,
minorTicks: 2, max: 100, min: 0
};

var chart = new google.visualization.Gauge(document.getElementById('chart_div3'));
chart.draw(data, options3);
}
</script>


</head>
<body>
<div align="center">
<H1 align="center">PID graph</H1>
<div align="center">
<table width="900" border="1">
<tr>
<td><div align="center">
<table width="1000" border="0">
<tr>
<td width="141">&nbsp;</td>
<td width="10">&nbsp;</td>
<td width="432"><div id="chart_div1"></div></td>
<td width="141">&nbsp;</td>
<td width="144">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>
<div align="center">
<table width="800" border="0">
<tr>
<td width="595"><div id="chart_div2"></div></td>
<td width="195"><div id="chart_div3"></div></td>
</tr>
</table>
</div></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><div align="center">
<?php
error_reporting(E_ERROR);
$db="HLT";
$link = mysql_connect('', 'jakwi', 'password');
mysql_query('SET NAMES utf8'); 
mysql_select_db($db , $link) or die("line 220 Couldn't open $db: ".mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT Time, Temp, Setpoint, Input, Kd, Ki, Kp, Heat FROM temp Order By Time desc limit 1");
if ($result !== false) {
$num=mysql_numrows($result);


$time=mysql_result($result,0,"Time");
$temp=mysql_result($result,0,"Temp");
$input=mysql_result($result,0,"Input");
$setpoint=mysql_result($result,0,"Setpoint");
$ki=mysql_result($result,0,"Ki");
$kp=mysql_result($result,0,"Kp");
$kd=mysql_result($result,0,"Kd");
$heat=mysql_result($result,0,"Heat");

 

echo "Kp = ";
echo $kp;
echo " Ki = ";
echo $ki;
echo " Kd = ";
echo $kd;

 

}

 

 

?>
</div></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</div></td>
</tr>
</table>
</div>
</body>
</html>

- See more at: http://fermentationriot.com/arduinopid.php#sthash.mvNXxNUz.dpuf
File Type: jpg PID.jpg (29.8 KB, 44 views)
__________________
jakwi is offline
 
Reply With Quote Quick reply to this message
Old 06-21-2014, 09:22 PM   #5
ellisgl
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2013
Location: Fort Worh, TX
Posts: 6
Likes Given: 12

Default

No problem. There's a line in the PHP.INI file that sets the level of which to display "errors".

__________________
ellisgl 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
DIY Networked Arduino Dual stage temp. controller w/ logging/graphing timdsmith72 DIY Projects 44 03-19-2014 11:47 PM
Arduino temperature controller? ChshreCat DIY Projects 2 06-12-2013 10:08 PM
DIY PID controller - beginner Arduino project chuckjaxfl DIY Projects 33 09-18-2012 04:05 PM
Arduino questions (mash temp controller) Beezer94 DIY Projects 3 06-12-2012 02:53 PM
Arduino+XBee Dual-stage Temp Controller Chuginator DIY Projects 65 12-18-2011 08:44 AM