PHP sample to readout Modbus Wemos with json

Info about Mod-bus and Mod bus Programming.
BUTTON_POST_REPLY
admin
Site Admin
BerichtenCOLON 27
GeregistreerdCOLON 27 Jan 2022 09:52

PHP sample to readout Modbus Wemos with json

Bericht door admin »

This is a sample how to use it on Modbus WeMos how to readout with json.

Download source
Read_EasyESP.7z
(577 Bytes) 842 keer gedownload

<?php

$Server = "http://192.168.9.104:8084"; // Domoticz IP
$Pad = "/json.htm?type=command&param=udevice&idx="; // Path for Domoticz

$json = file_get_contents('http://192.168.9.164/json'); // Read json Modbus Wemos

$obj = json_decode($json); // Decode

$TotalSensors = count($obj->Sensors); // Get total of sensors

for ($x = 0; $x < $TotalSensors; $x++) { // All Sensors
$TotalVal = count($obj->Sensors[$x]->TaskValues); // Get count of values
$TaskN = $obj->Sensors[$x]->TaskName; // Get Sensor Name
print("\n"); // print blank line
print($TaskN ."\n"); // print actual task name
for ($y = 0; $y < $TotalVal; $y++) { // All values
$Task1v1 = $obj->Sensors[$x]->TaskValues[$y]->Value; // Get value
$Task1v1n = $obj->Sensors[$x]->TaskValues[$y]->Name; // Get name value
print($Task1v1 . ' ' . $Task1v1n ."\n"); // print value and name
}
}

?>
BUTTON_POST_REPLY