Introduction: BeagleBoneBlack PHP-GPIO

Before you start with this tutorial download this list:

• Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
• WinSCP (http://winscp.net/eng/download.php)
• Editor (http://notepad-plus-plus.org/download/v6.5.html)
• 7-ZIP (http://www.7-zip.de/)
• Win32-DiskImager (http://sourceforge.net/projects/win32diskimager/)
• Debian Image (http://elinux.org/BeagleBoardDebian#eMMC:_BeagleBone_Black)
Required hardware:
• 4GB microSD-card

Step 1: Flash Your BeagleBoneBlack

Extract the debian_flasher.img.xz with 7-ZIP

Select the extracted .img with Win32-DiskImager and copy it to your SD-card

Flash your beaglebone:
• insert the microSD-card into the slot on the back of the BeagleBone Black
• now click the User-Button. It’s located on the same side of the BBB as the microSD card slot.
• Hold the "User Boot" button down, and then plug in the power (USB or 5V adaptor). Keep holding down the button until you see the bank of 4 LED's light up for a few seconds. You can now release the button.
• It will take some minutes to flash the image to the on-board chip. (15-50mins)
• Once it’s done, the bank of 4 LED’s will all stay lit up at the same time. You can now remove the power and the microSD-card.

Step 2: Install the Webserver

Power on your BBB and connect with putty.
If you don’t know the IP-address of your BBB connect to the Web interface of your router and you will find it under connected devices.

username:  debian
password: temppwd


Install the webserver:
• apt-get install apache2
• apt-get install php5 libapache2-mod-php5
• /etc/init.d/apache2 restart

Step 3: Add Your First Php-script

edit the etc/rc.local example for gpio 30:
• echo 30 > /sys/class/gpio/export
• chmod 666 /sys/class/gpio/gpio30/value
• chmod 666 /sys/class/gpio/gpio30/direction
• echo out > /sys/class/gpio/gpio30/direction
• exit 0


To power on a gpio30 you can use this php-command:
shell_exec("echo \"1\" > /sys/class/gpio/gpio30/value");

The default path of the webserver directory is: /var/www/

Now you can connect with winscp and the root user (user:root, pw:root) to this directory and add some of your php-scripts.

If you have any further questions, do not hesitate to contact me:
willimeter@hotmail.com

Comments

author
Computothought (author)2015-04-19

Cool.

author
cwoidyla (author)2014-11-04

This BBB web server project includes PHP source for controlling the LEDs:
http://www.element14.com/community/community/desig...

author
vagom (author)2014-07-14

Were is the source code?

author
altainta (author)2014-07-10

1) Hello kindly post source file. As you are showing the html (php) page in the browser...

2) How can we also control the 4 leds situated in

/sys/class/leds/beaglebone:green:usr3/brightness

i tried

chmod 666 /sys/class/leds/beaglebone:green:usr3/brightness

and changed the of source script but it didn;t work

3) LED SETUP

asking very basic because when i was a noob that time i know that there is not much info regarding the topic (php beaglebone black)