PHP Classes

Arduino PHP Serial Linux: Communicate with a Arduino board via serial port

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 355 All time: 6,934 This week: 314Up
Version License PHP version Categories
arduinolinuxserial 1.0GNU Lesser Genera...5PHP 5, Unix, Hardware
Description 

Author

This class can communicate with a Arduino board via serial port.

It can open a connection with a USB serial port of a given name on Linux.

The class can send and receive messages from the board.

Innovation Award
PHP Programming Innovation award winner
January 2018
Winner


Prize: One big elePHPant Plush Mascott
This class can communicate with a Arduino board via serial port.

It can open a connection with a USB serial port of a given name on Linux.

The class can send and receive messages from the board.

Manuel Lemos
Picture of Marco Sillano
  Performance   Level  
Name: Marco Sillano <contact>
Classes: 4 packages by
Country: Italy Italy
Age: ???
All time rank: 202679 in Italy Italy
Week rank: 569 Up24 in Italy Italy Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Example

<html>
<head>

<?php
$d
= dirname(__FILE__);
include(
"$d/ArduinoLinuxSerial.php");

// new object
$ArduinoSerial = new ArduinoLinuxSerial('/dev/ttyACM0'); // Linux device

$led = 'LED ??';

if (isset(
$_GET['LED'])){
   if (
$_GET['LED'] == 'ON'){
  
$led = $ArduinoSerial->sendMessage('1 test'); // command 1: led 13 ON, ' test' is dummy
  
if (isset($_GET['AUTO'])) // blinking 3 sec.
       
header('refresh: 3; url=index.php?AUTO=BLINK&LED=OFF');
   }
   if (
$_GET['LED'] == 'OFF'){
  
$led = $ArduinoSerial->sendMessage('2 test'); // command 2: led 13 OFF, ' test' is dummy
  
if (isset($_GET['AUTO'])) // blinking 3 sec.
       
header('refresh: 3; url=index.php?AUTO=BLINK&LED=ON');
   }
}
?>

</head>
<body
 style="font-family: -moz-fixed; white-space: -moz-pre-wrap; width: 72ch;">
<pre></pre>
<h1> TEST ARDUINO Linux Serial</h1>
&nbsp;&nbsp;&nbsp;&nbsp;<b><i><?php echo $led; ?></i></b><br><br>
<form action='index.php' method='GET'>
<select id='led' name='LED'>
<option id='0'>OFF</option>
<option id='1'>ON</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;
<input type='submit' value='SET'>&nbsp;&nbsp;&nbsp;&nbsp;
<input type='submit' name='AUTO' value='BLINK'>
</form>

<br>
</body>
</html>



  Files folder image Files  
File Role Description
Files folder imagearduino (1 file)
Files folder imagetest (1 file)
Plain text file ArduinoLinuxSerial.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file serialArduino.sh Data Auxiliary data

  Files folder image Files  /  arduino  
File Role Description
  Accessible without login Plain text file testSerial.ino Data Auxiliary data

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file testSerial.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:355
This week:0
All time:6,934
This week:314Up
User Comments (1)
Thats a amazing class ;-)
5 years ago (José Filipe Lopes Santos)
80%StarStarStarStarStar