Skip to content

Instantly share code, notes, and snippets.

@adlerweb
Created February 15, 2015 03:51
Show Gist options
  • Save adlerweb/cbcc3f023ea848697270 to your computer and use it in GitHub Desktop.
Save adlerweb/cbcc3f023ea848697270 to your computer and use it in GitHub Desktop.
ESP8266 -> Volkszäler
<?php
while(true) {
$html = file_get_contents('http://1.2.3.4/dht22.tpl');
if(preg_match('/temperature reading is ([\d\.]+)\*C, humidity is ([\d\.]+) ./', $html, $match)) {
vz_add('**UUID_TEMPERATUR**', $match[1]);
vz_add('**UUID_FEUCHTE**', $match[2]);
}
echo '--'."\n";
sleep(10);
}
function vz_add($id, $val) {
$url='http://vzserver/middleware.php/data/'.$id.'.json?operation=add&value='.$val;
var_dump($url);
$cmd = 'wget -O - '.escapeshellarg($url).' > /dev/null 2>/dev/null &';
exec($cmd);
}
?>
@adlerweb
Copy link
Author

19: wget über exec läuft asynchron, so blockt ein hängender Server nicht den kompletten Prozess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment