LAN DS18B20 WEB Temperature Monitor 1 meter Cable
www.WEB-Relays.com
www.Facebook.com/KMtronic

Raspberry Pi: Reading ModBus data from Huawei inverter SUN 2000

PHP file: require_once dirname(FILE) . ‘/Phpmodbus/Phpmodbus/ModbusMaster.php’; // Create Modbus object$modbus = new ModbusMaster(“192.168.1.199”, “TCP”); try {// FC 3$recData = $modbus->readMultipleRegisters(1, 32262, 1); // PV1 voltage }catch (Exception $e) {// Print error information if anyecho $modbus;echo $e;exit;} // Print status informationecho “Status: ” . $modbus; // Print read dataecho “Data: “;print_r($recData);echo ““; $data = (256*$recData[0]) + . . .

Read More

USB Relay Module for Windows, Linux, Raspberry Pi

include ‘PhpSerial.php’; // Let’s start the class$serial = new PhpSerial; // First we must specify the device. This works on both Linux and Windows // (if your linux serial device is /dev/ttyS0 for COM1, etc)$serial->deviceSet(“/dev/ttyUSB0“); // We can change the baud rate, parity, length, stop bits, flow control$serial->confBaudRate(9600);$serial->confParity(“none”);$serial->confCharacterLength(8);$serial->confStopBits(1);$serial->confFlowControl(“none”); // Then we need to open it$serial->deviceOpen(); . . .

Read More

Receive UDP packet datagrams in PHP ( UDP server socket)

  PHP file: <?php $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);if (!$socket) { die(“socket_create failed.n”); }   //Set socket options.socket_set_nonblock($socket);socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, 1);socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1); if (defined(‘SO_REUSEPORT’))socket_set_option($socket, SOL_SOCKET, SO_REUSEPORT, 1); //Bind to any address & port 12345.if(!socket_bind($socket, ‘0.0.0.0’, 12345))    die(“socket_bind failed.n”);   //Wait for data.$read = array($socket); $write = NULL; $except = NULL; while(socket_select($read, $write, . . .

Read More

KMtronic LAN WEB 8 Channel Relay board