Wednesday, December 6, 2017

PHP Scripts: Control KMtronic LAN WEB Relay board via PHP

PHP Scripts: Control KMtronic LAN WEB Relay board via PHP 
PHP Scripts: Control KMtronic LAN WEB Relay board via PHP

PHP code for STATUS Read WEB Relay board connected to


 IP: 192.168.1.199 PORT:80 
 USER: admin 
 PASSWORD: admin   

 1. Create a new file.

<?php

$url = "http://192.168.1.199:80/status.xml";
$username = "admin";
$password = "admin";

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

//execute post
$result = curl_exec($ch);

print $result;

?>



 2. Save the file as web_8relay_status.php and run. ( $ php web_8relay_status.php )  

 3. Result:

$ php web_8_relay_status.php 

0
0
0
0
0
0
0
0
0





 


PHP code for CONTROL WEB Relay board connected to

IP: 192.168.1.199
PORT:80
USER: admin
PASSWORD: admin

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

 4. Create a new file.


<?php

$url = "http://192.168.1.199:80/FF0101";  // TURN ON Relay 1
$username = "admin";
$password = "admin";

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

//execute post
$result = curl_exec($ch);

print $result;

?>

5. Save the file as web_relay_1_on.php and run. ( $ php web_relay_1_on.php )

  




PHP Scripts: Control KMtronic LAN WEB Relay board via PHP



https://web-relays.com/en/blog/kmtronic-lan-ethernet-ip-8-channels-web-relay-board-box/