On-line Atmospheric Pressure

From ProjectPages
Jump to: navigation, search

UNDER CONSTRUCTION!!!

The Graph

BMP085 Pressure Sensor - GY-65

Pin Connections
BMP085 Pin Name Arduino
1 VCC 3v3
2 SDA A4
3 SCL A5
4 XCLR NC
5 EOC NC
6 GND GND

The Database

Serial Programmer

Store The Pressure

storepress.php

<syntaxhighlight lang="php"> <?php $db = "[database name]"; $user = "[username]"; $password = "[password]"; $server = "[server]"; $mysqli=new mysqli($server,$user,$password,$db);

// Check connection

if ($mysqli->connect_errno) {

   echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

}

if (!$mysqli->query("INSERT INTO tblPressure(pressure) VALUES ({$_POST['pressure']})")){

   echo "Insert failed: (" . $mysqli->errno . ") " . $mysqli->error;

}else{

   echo "SUCCESS";

}

?> </syntaxhighlight>


Arduino Code

<syntaxhighlight lang="c"> </syntaxhighlight>

Pressure Web Service

pressure.php <syntaxhighlight lang="php"> <?php

$db = "[database name]"; $user = "[username]"; $password = "[password]"; $server = "[server]"; $mysqli=new mysqli($server,$user,$password,$db);

// Check connection if ($mysqli->connect_errno) {

   echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

}


// Execute query $res = $mysqli->query("SELECT pressure AS y, date AS x FROM tblPressure ORDER BY x DESC LIMIT 720");

for ($i = 0; $i< $res->num_rows; $i++){ $row[] = $res->fetch_assoc(); }

echo json_encode($row); ?> </syntaxhighlight>


Show The Graph

<syntaxhighlight lang="html5">

<!DOCTYPE HTML> This has all changed now </syntaxhighlight>

Links

*Henley-on-Thames Weather RSS