I am planning to set up an HTML-PHP website gui which opens up in Chromium Kiosk mode.

I want the gui to count the number of falling edge interrupts and show the count on the GUI.

I have achieved this functionality quite easily using a C-program, but I don't know how to update the count php-variable on the GUI website.

The wiringPi GPIO utility does provide some functionality regarding GPIO pins, but not related to interrupts. This is the tutorial regarding wiringPi/PHP.

Any suggestions on how to tackle this problem?


Since you're going to be using Python, why use WiringPi? You can read the GPIO pins directly from Python in many cases. http://raspberry.io/projects/view/reading-and-writing-from-gpio-ports-from-python/

  • I am not using Python at all. But can switch to Python as well. But, the problem still stands, how can I update the HTML webpage GUI through python application running at the back? Sep 25 '17 at 17:28
  • For somethings (thermocouples, for sure) the values are written to a file. Sep 25 '17 at 18:05

I'd recommend taking a look at phpi-websocket, it has everything you need to implement what you're after, so it'd just be a matter of looking at the examples and trimming out what you don't need.

It uses a native PHP library to interact with the edge detection registers and does an event-based push to an HTML page via websockets.

As mentioned before, there's more than you need in the example - you're mainly interested in this part on the server:

$pin->on(\Calcinai\PHPi\Pin::EVENT_LEVEL_CHANGE, function() use($pin, $controller){
    $controller->broadcast('pin.level', ['pin' => $pin->getPinNumber(), 'level' => $pin->getLevel()]);

which handles the pin change event and broadcasts it. Then on the client

.bind('pin.level', function(data){
    $('.pin[data-bcm="'+data.pin+'"]').data('level', data.level);

which binds that javascript event to the UI. You can easily make it do something like increment a variable instead.

disclaimer: I'm the author and maintainer of the above library

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.