Hi
ich habe erfolgreich meine Temperaturen in Emoncms eingebunden.
Jetzt wollte ich noch drei GPIOś 17,27,22 mit anzeigen lassen.
Da ich WiringPi installiert hab, dachte ich all Variablen sind bekannt
Was mache ich falsch?
Ich habe mein Temperatur script angepasst, jetzt bringt er den Fehler
PHP Notice: Undefinede variable : pin in /home/pi/gpio1.php on line 43
PHP Notice: Undefinede variable : Val in /home/pi/gpio1.php on line 43
[code=php]<?php
// ================ Config ===========================
define("GPIOPATH","/sys/class/gpio/");
function gpio_is_exported($pin)
// prueft, ob der Pin exportiert ist
{
return file_exists(GPIOPATH.'gpio'.$pin.'');
}
function gpio_get_direction($pin)
// gibt die eingestellte Richtung zurueck
{
$Dir = '';
if (gpio_is_exported($pin))
{ $Dir = trim(file_get_contents(GPIOPATH.'gpio'.$pin.'/direction')); }
return $Dir;
}
function gpio_get_value($pin)
// gibt den augenblicklichen Wert (0/1) des Pins zurueck
{
$Val = '';
if (gpio_is_exported($pin) && gpio_get_direction($pin) == 'in')
{ $Val = trim(file_get_contents(GPIOPATH.'gpio'.$pin.'/value')); }
return $Val;
}
// Set the emoncms API Key, the Hostname or IP and the internal Sensor ID (Numeric only)
$EmonCMSApiKey = "a30128415ecbdb1c91291a546142bf3";
$EmonCMSHost = "localhost";
// ==================================================
// Write to emoncms - Example http://192.168.178.24/emoncms/…on?node=1&csv=100,200,300
// You may want to add other parsed values
$url = 'http://' . $EmonCMSHost . '/emoncms/api/post.json?node=' . 'gpio' . $pin . '&csv=' . $Val . '&apikey=' . $EmonCMSApiKey . '';
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
$contents = curl_exec ( $ch );
curl_close ( $ch );
?>[/php]