Skip to content

Instantly share code, notes, and snippets.

@solon
Created July 19, 2010 02:53
Show Gist options
  • Save solon/480961 to your computer and use it in GitHub Desktop.
Save solon/480961 to your computer and use it in GitHub Desktop.
<?php
/*
* Display a sensor value on a webpage
* Uses the Pachube PHP Library - download at http://community.pachube.com/tutorials/php
*/
require_once('pachube_functions.php');
// Obtain your API key here: http://www.pachube.com/users/my_username/settings
$api_key = 'YOUR_API_KEY';
// replace this with the feed you are using
$feed_id = '8909';
$url = 'http://www.pachube.com/api/'.$feed_id.'.csv';
$pachube = new Pachube($api_key);
$environment = $pachube->environment( $feed_id );
$data = $pachube->retrieveData ( $url );
$sensor_readings = explode(",", $data);
//print_r ($sensor_readings);
?>
<html>
<head>
<title>My Sensors</title>
</head>
<body>
<table border="1" cellpadding="5">
<tr>
<th>Sensor</th>
<th>Value</th>
</tr>
<tr>
<td>Light level</td>
<td><?php echo $sensor_readings[0]; ?></td>
</tr>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment