Php graphics and charts with Arduino

Hi everyone, i use a database to store information about energy consumption in a house.
Now i would like to create a php page that shows database's values in a line chart but i don't know which library i have use....
can yoy help me please?

HTML5 can make charts like this :

Very cool, but can i use php to update the values of the chart?

Yes, but don’t ask me how.
I have seen an example of HTML5 canvas and the data was retrieved in javascript from another source (like the Arduino) to get live updates without refreshing the whole page. I don’t know anymore where I have seen that.

you can use google chart:



    <title>grafico temperatura giornaliera</title>
	<a href=grafici.html>Home Page</a>
    <!-- Load jQuery -->
    <script language="javascript" type="text/javascript" 
    <!-- Load Google JSAPI -->
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        google.load("visualization", "1", { packages: ["corechart"] });
        function drawChart() {
            var jsonData = $.ajax({
                url: "tracker.php",
                dataType: "json",
                async: false

             var obj = jQuery.parseJSON(jsonData);
            var data = google.visualization.arrayToDataTable(obj);

            var options = {
                title: 'Grafico temperatura giornaliera',
				// curveType: 'function'
				backgroundColor:  {fill:'transparent'},
				explorer: { actions: ['dragToZoom', 'rightClickToReset'] },
				reverseCategories: 'true',

            var chart = new google.visualization.LineChart(
            chart.draw(data, options);
			setTimeout(drawChart, 15000 );

    <div id="chart_div" style="width: 1000; height: 600;">


    //$SQLString = 	
    $result = mysql_query("SELECT `ID`, `time`, `temperatura`, `umidita`, `Stato`, `Setpoint` FROM `temperatura` order by time desc limit 327");   
	$num = mysql_num_rows($result);   
	$data[0] = array('time','temperatura');		
   for ($i=1; $i<($num+1); $i++)
		$data[$i] = array(mysql_result($result, $i-1, "time"),
						(float) mysql_result($result, $i-1, "temperatura"));
    echo json_encode($data);

You can look my website here:

I hope this help.


Thank you but i'm looking for some php library so that i can see charts even if i haven't got an internet connection...

You could take a look at FLOT:

I use it and am very happy with it. I store my sensor data in a csv file on the SD card (one file per day), and I use a php file to create the javascript to plot it in the web client.

I've also found this tutorial but i don't know how to install GDLibraries on my yun...