Ethernet to Server

Writing temperature and light values to a storage file.

http://www.piuggi.com/sensorData/storage.txt

Php Script

put this script on your server which supports php.

[code]
<html><body>
<?php
$light = $_GET[‘sendLight’]; $temp = $_GET[‘sendTemp’];
$test_string = sprintf("We work work work work work work work, the whole day through…");
//print the date
$day = date(‘m/d’);

//print the time
$time = date(‘H:i:s’);

//format them into an xml style
$data = sprintf("\n<entry> \n <day>%s</day> \n <time> %s </time> \n <light> %s </light> \n <temp> %s </temp> \n</entry>\n",$day, $time , $light, $temp);
//tell the server which file to open
$filename = "storage.txt";
//command it to open in order to append
$file = fopen($filename,"a");
//write our data string…
fwrite($file, $data);
//and we out.
fclose($file); ?>

<p> <?php echo $test_string ?> </p>

</body>
</html>
[/code]

Arduino Side of things
Download here >

Responses

  1. scottpeterman Avatar

    Thanks!!!! Super helpful, the mac seems to be pretty weird with direct fwrite/fread to the arduino over serial (plus a lot of user error as well I’m sure), I kinda want to just pick one of these up…

Leave a Reply

Discover more from Making Toys

Subscribe now to keep reading and get access to the full archive.

Continue reading