Close

[Rpi server] First launch

A project log for Home automation - Trinket Sensing

TJTJ 06/16/2015 at 12:150 Comments

I've installed the raspbian image on the sd card. https://www.raspberrypi.org/downloads/

With Apache 2, PHPMyAdmin, MySQL (http://elinux.org/RPi_Apache2, http://elinux.org/RPi_MySQL)

The database trinket_sensing now contains the temperature table:

In my case the RPI IP address is 192.168.1.58 (local address)

With the script below (insertTemp.php) I can add a value.

<?php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "trinket_sensing";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO temperature (id, ts, value) VALUES (NULL, CURRENT_TIMESTAMP, '".$_GET['temp']."')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

I now have a working database test link. I will add all others later.

Discussions