Announcement

Collapse
No announcement yet.

How to Monitor Sensors/Devices via HTTP Request

Collapse
X
Collapse
  •  

  • How to Monitor Sensors/Devices via HTTP Request

    Advantage of Monitoring via HTTP Request
    • 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(0IN_PIN"in");

    $touch uio_in(0IN_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
    Last edited by support; 02-08-2018, 05:28 PM.
      Posting comments is disabled.

    Categories

    Collapse

    Latest Articles

    Collapse

    • Arduino - RS-485 Expansion Board
      by support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 02:45 PM
    • Arduino - RS-422 Expansion Board
      by support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 02:44 PM
    • Arduino - RS-232 Expansion Board
      by support
      PES-2606 is an easy-to-use RS-232 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS-232.
      Especially, Arduino does NOT use UART pins to communicate with RS-232 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS-232 expansion boards (up to 14) without using Arduino UART pins.

      Library and example for the RS-232 expansion board...
      11-13-2018, 02:43 PM
    • Arduino - Stepper Motor Controller
      by support
      PES-2605 is an easy-to-use stepper motor controller for Arduino Uno and Mega, which uses micro-stepping method to precisely control stepper motor.
      Library and example for the stepper motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the step motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 02:41 PM
    • Arduino - DC Motor Controller
      by support
      PES-2604 is an easy-to-use DC motor controller for Arduino Uno and Mega.
      Library and example for the DC motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the DC motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 02:40 PM
    • Arduino - Digital Input Board
      by support
      PES-2602 is an easy-to-use 4-port Input Expansion Board for Arduino Uno and Mega, which allows Arduino to monitor state of DC electric device. In addition, it can monitor NPN, PNP and dry contact(relay).
      Library and example for the 4-port input expansion board are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use 4-port input expansion board with an example of PhpocExpansion library for Arduino.

      ...
      11-13-2018, 02:39 PM
    Working...
    X