Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'vendor/autoload.php';
- use Phpmodbus\Phpmodbus\ModbusMaster;
- $ip = "192.168.1.1"; // Modbus IP device address
- $modbus = new ModbusMaster($ip, "TCP");
- try {
- $registers = $modbus->readMultipleRegisters(0, 0, 10); // Read 10 registers starting from address 0
- print_r($registers);
- } catch (Exception $e) {
- echo "Error: " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement