W&T connects
Interfaces for TCP/IP, Ethernet, RS-232, RS-485, USB, 20mA, glass and plastic fiber optic cable, http, SNMP, OPC, Modbus TCP, I/O digital, I/O analog, ISA, PCI

Application for Web-IO Analog-In:

Retrieve and display multiple measurements using 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.

/
Measurements
Do you not yet have a Web-IO Analog-In but would like to try out the example shown here?

No problem: We will be glad to send you the Web-IO Analog-In 2x 0..10V at no charge for 30 days. Simply fill out a sample ordering form, and we will ship the Web-IO Analog-In for testing on an open invoice. If you return the unit within 30 days, we will simply mark the invoice as paid.

To sample orders

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:

enable HTTP Header

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:

Output

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:

Overview pages
Do you not yet have a Web-IO Analog-In but would like to try out the example shown here?

No problem: We will be glad to send you the Web-IO Analog-In 2x 0..10V at no charge for 30 days. Simply fill out a sample ordering form, and we will ship the Web-IO Analog-In for testing on an open invoice. If you return the unit within 30 days, we will simply mark the invoice as paid.

To sample orders