- Simple to create
- Useful to check states of sensors/devices
How to Monitor via HTTP Request
This kind of method does NOT require any code run in system loop. It just needs to:
- Create a PHP file (For example, my_file.php).
- Write the code.
- Upload it to PHPoC devices.
- Access webpage via Web Browser on your PC or smart phone (See How To).
Source code will includes:
- PHPoC code: Required. This code read state/value from sensors/devices and print the state/value to webpage (to update HTML or JavaScript code)
- HTML code: Required. This code describes the structure of Web pages. Content of HTML code may be changed or updated by PHPoC code.
- CSS code: Optional. This code describes how HTML elements are to be displayed.
- JavaScript code: Optional. This code can visualize states of sensors/devices on Web page.
Example
The below code show how to check ON/OFF state of a devices, which connect to an IO pin of PHPoC.
PHP Code:
<html>
<head>
<title>PHPoC Tutorial</title>
<style> body { text-align: center; } </style>
</head>
<body>
<h2>
Monitoring ON/OFF state<br>
<br>
State:
<span style="color:blue">
<?php
include_once "/lib/sd_340.php";
define("IN_PIN", 0);
uio_setup(0, IN_PIN, "in");
$touch = uio_in(0, IN_PIN);
if($touch)
echo "ON";
else
echo "OFF";
?>
</span>
</h2>
</body>
</html>
Webpage looks like below

It can use query string (name/value pairs) in the URL of a GET request to optionally monitor sensors/devices.
See Also