PHP Scripts: Control KMtronic LAN UDP Relay board via PHP

KMtronic UDP LAN Controled Internet relay board

 

 

http://www.info.kmtronic.com/km-udp-eight-relay-box.html

 

 

PHP code for STATUS Read UDP Relay board connected to

IP: 192.168.1.199

PORT:12345

 

UDP COMMAND: FF0000

 

Create a new file.

<?php

$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 

$msg = "FF0000";

$len = strlen($msg);

socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345); socket_recvfrom($sock, $buf, 12, 0, $from, $port);

echo $buf; socket_close($sock);

?>

 

Save the file as status.php and run. ( $ php status.php )

 

Result:

$ php list.php





 

 

PHP code for CONTROL UDP Relay board connected to

IP: 192.168.1.199

PORT:12345

 

UDP COMMANDS:
FF0101  // TURN ON Relay 1
FF0100  // TURN OFF Relay 1
FF0201  // TURN ON Relay 2
FF0200  // TURN OFF Relay 2
...

FF0801  // TURN ON Relay 8
FF0800  // TURN OFF Relay 8

 

Create a new file.

<?php

$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

$msg = "FF0101"; // TURN ON Relay 1

$len = strlen($msg);

socket_sendto($sock, $msg, $len, 0 ,'192.168.1.199', 12345);

socket_recvfrom($sock, $buf, 12, 0, $from, $port);

echo $buf;

socket_close($sock);

?>

Save the file as relay_1_on.php and run. ( $ php relay_1_on.php )

Read 651 times