2014年2月19日水曜日

Web GPIO controller with PHP

INDEX
Set up Raspberry Pi Noobs
Install wiringPi
GPIO setting for Python.
(Python is the simplest sample code,.You don't need to check the number of GPIO. )
Web controller with PHP for MCU Gear
                                      

You can make GUI application easily.



                                      

Step 1: Install Apache and PHP

$sudo apt-get update
$sudo apt-get upgradesudo apt-get install apache2 php5
$sudo chown pi -R /var/www
$sudo updata-rc.d apache2 defaults

You can use HTML on /var/www/ folder.
                                      
Step 2 : Edit sudoers file

$sudo nano /etc/sudoers

Write "www-data ALL=(root) NOPASSWD: ALL" to the end of file.



Then you can use sudo command on PHP.

                                      

Step 3 : Download Sample program

$wget http://mcugear.org/RPitest/MUGear.tar
$tar xvf MCUGear.tar
$sudo mv -f MCUGear /usr/lib/cgi-bin

Then reboot RPi.
$sudo reboot

                                      

Step 4 : Test from you PC or Tablet.
Open browser and connect to 
http://raspberrypi.local/cgi-bin/MCUGear/index.php
or
http://[IP Address]/cgi-bin/MCUGear/index.php

You can see this page.



                                      

Step 5 :  How use it?

Push "Init Baseboard" botton that initialize baseboard and enable.

Read Input Pins : Read Input signal from Universal Module.
Write Output Pins : Write DA data to DA Module.
Read AD 2ch : Read AD data from 12bit AD 2ch module.
Read AD 8ch : Read AD data from 12bit AD 8ch module.
Write DA : Write DA data to DA Module.
Move RC Servo : Multifunction module 3ch PWM mode.

"Shutdown" is sudo halt command.
You do not need remote login for shutdown RPi.

PHP use System command format is
sudo python ***.py [module address] [data0] [data1] [data2] ...



0 件のコメント:

コメントを投稿