• Cart0
    Total 0.00 DKK
    Your shopping cart is empty!
    Tax:
    Discount:
    Total:
Thursday, 28 March 2019 00:23

Retrieve and display multiple measurements using PHP

Written by
Rate this item
(0 votes)

Acquire measurements from multiple devices and disply them on a single Web page useng PHP.

When using more than one Web-IO Analog-In in one location, it may be desirable to display the data from the individual devices on a single Web page. Here PHP can be useful.

Using the following copy&paste example you can display the measurements from different devices (here two Web-IO Analog-In 2x 0..10V) on one Web page.

For this example you need a Web server with PHP interpreter.

Get started - order a trial version for 30 days

With few exceptions, all products from Wiesemann & Theis can be offered as trial versions in one copy or set.
Ordering a trial version is like a normal purchase on a webshop. In the note box, type "Test version and product number" that you want to test for 30 days.
Upon returning, we will send a credit note. Of course, we also receive a test version of the phone or e-mail.

Order your Trial Version here

Preparations

You have already provided your Web-IO Analog-In

  • with power,
  • connected it to your network,
  • assigned it an IP address - which with WuTility is no problem.

1. HTTP GET Header enable disable

To prevent the device from returning the entire reply header (IP address, system name, sensor name, measured value) and have it send just the measured value, you must first turn this option off in the device configuration:

2. Incorporate PHP script into the Web page

Copy the JavaScript (shown in gray) from the following example
e.g. into the <body> area of your Web page (PHP commands are interpreted at any desired location on the page).

Modify the red IP address, the green HTTP port and the yellow query command to your purposes.

<html>
	<head>
		<title>Level</title>
	</head>
	<body bgcolor="#FFFFFF" text="#000000">
		<?
		function getvalue($address,$sensorno)
			{
			$datei = fsockopen($address,80);
			$out = "GET /Single".$sensorno."HTTP/1.1\r\n\r\n";
			fwrite($datei, $out);
			while (!feof($datei))
				{
				$data = fgets($datei);
				}
			$find = "/r/n";
			$pos = strpos($data, $find);
			$value = substr($data,$pos);
			echo $value;
			fclose($datei);
			}
		?>
	<br>
		<?
		getvalue ("192.168.0.2","1");
		?>
	<br>
		<?
		getvalue ("192.168.0.3","1");
		?>
	</body>
</html>

3. Output

If you save the above PHO page on a PHP server and open it using a Web browser, you get the following view:


4. Automatic updating

To update the page cyclically, insert the following line into the <head> area of the page.

The interval is given in seconds (shown here in red: 60 seconds

<html>
	<head>
		<title>Level</title>
		<meta http-equiv=refresh content=60>
	</head>
	<body bgcolor="#FFFFFF" text="#000000">
...

5. Modify the page to your purposes

Using the above procedure you can simply create overview pages which can include any number of measurements:

Get started - order a trial version for 30 days

With few exceptions, all products from Wiesemann & Theis can be offered as trial versions in one copy or set.
Ordering a trial version is like a normal purchase on a webshop. In the note box, type "Test version and product number" that you want to test for 30 days.
Upon returning, we will send a credit note. Of course, we also receive a test version of the phone or e-mail.

 Order your Trial Version here

 

Read 132 times Last modified on Thursday, 28 March 2019 00:42

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.