I connected an Arduino Nano via USB to my Raspberry PI3. The Arduino is programmed to send (via serial) 16 bytes of information every 500 milliseconds. In this RPi3 I have Python, Apache2 and PHP5 installed on my Raspbian Jesse, so I wrote the following code and save in var/www/html/ler.py :
import serial comunica = serial.Serial('dev/ttyUSB0', 9600) print comunica.read(16)
And then when I type in the command line:
I have the perfect response from the script: it shows me 2.502.502.505.00 that is the analogRead from four potentiometers in the Arduino.
The trouble starts when I try to do the same thing via browser. I did create a page named index.php and add the following code in it:
<?php system('ls -l'); system('python ler.py'); ?>
When I access the page, it return the content of the directory (ls -l) but doesn't return the values from the command "python ler.py"
In the command line works fine, but not in PHP.
I think there is something to do with the permissions, Apache runs over the www-data user and this scripts needs to access the dev ttyUSB0.
Does someone experience a similar situation?