
Temperature Monitor STATUS XML data
http://XXX.XXX.XXX.XXX/status.xml
XXX.XXX.XXX.XXX is IP ADDRESS Temperature monitor
MySQL table


Cron is a system daemon used to execute desired tasks (in the background) at designated times.
A crontab file is a simple text file containing a list of commands meant to be run at specified times. It is edited using the crontab command. The commands in the crontab file (and their run times) are checked by the cron daemon, which executes them in the system background.
Crontab PHP file:
<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "temperature_database"; // Loading the XML file $xml = simplexml_load_file("http://XXX.XXX.XXX.XXX/status.xml"); // XXX.XXX.XXX.XXX is IP ADDRESS Temperature monitor foreach($xml->children() as $sensor) { if ($sensor->id == "2874EDD0040000F3" ) { $temp_value = $sensor->temp; } } // "2874EDD0040000F3" is ID DS18B20 sensor // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "INSERT INTO km_temperature (temp_id, temp_value, temp_time ) VALUES ('2874EDD0040000F3', $temp_value , NOW())"; // "km_temperature" is TABLE name if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?>