Tuesday, 28 January 2014

Adafruit-BeagleBone-IO-Python installation - written by Justin Cooper

Installation on Angstrom - Created by Justin Cooper

http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/installation

Installing the Adafruit-BeagleBone-IO-Python (phew!) library is fairly simple. Let's make sure we have a good foundation setup first.

The most important part here is that you are using a Linux distribution with the 3.8 kernel. This kernel version made some fairly significant changes with how GPIO and PWM is accessed. The good news is that your BeagleBone Black came pre-installed with the proper kernel. It just may not be the latest and greatest. If you have some extra time, it may not be a bad idea to follow our installation guide for Angstrom, and flash your BeagleBone Black with the latest version.

Connecting to your BeagleBone Black (SSH)

Once you have the latest version of Angstrom on your BBB, let's ssh into the system so we can execute commands. The easiest way to gain access to the system is by using GateOne SSH. You can easily access GateOne by typing in the following into your browser window:

Copy Code

http://beaglebone.local

Once the page loads successully (you should see a green box that says "Your board is connected!"), you can click on the "GateOne SSH link to the upper left, in the sidebar. Then, click the "GateOne SSH client" link to get started. Some browsers may complain about invalid certificates, but you can proceed anyways.

 GateOne.jpeg

To sign into the beaglebone, type the following at the prompts (assuming root user on a fresh Angstrom installation):

Copy Code

Host/IP or SSH URL [localhost]:  beaglebone.local
Port [22]:  (just hit enter)
User: root

Connecting to ssh://root@beaglebone.local:22

 GateOneFilled.jpeg

Commands to setup and install Adafruit_BBIO

Now that you're connected to the BBB, you'll want to start with setting the date and time so that it's accurate. Copy and paste the following into your terminal (you may want to make it execute this on startup in the future):

Copy Code

/usr/bin/ntpdate -b -s -u pool.ntp.org

These commands will require internet access. If you get errors, please view the FAQ page for resolutions.
Next, execute each of the following lines. Copy and paste the following one-by-one into the terminal, and hit enter:

Copy Code

opkg update && opkg install python-pip python-setuptools python-smbus
pip install Adafruit_BBIO

Test your Installation (optional)

You can optionally test if your installation was successful by simply trying to load one of the modules. Execute the following command from the console (not from within the python interpretor), it shouldn't throw any errors, but return one line:

Copy Code

python -c "import Adafruit_BBIO.GPIO as GPIO; print GPIO"

#you should see this or similar:

<module 'Adafruit_BBIO.GPIO' from '/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO/GPIO.so'>

You can also validate by executing the 'python' command to enable the interpreter, and run the following code (you can tell you're in the right place when you see the ">>>" in your terminal):

Copy Code

import Adafruit_BBIO.GPIO as GPIO; print GPIO

#you should see this or similar:

<module 'Adafruit_BBIO.GPIO' from '/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO/GPIO.so'>

Manual Installation (optional)

You can also install Adafruit_BBIO by cloning the git repository. The following commands should get it installed as well:

Copy Code

git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git

#set the date and time

/usr/bin/ntpdate -b -s -u pool.ntp.org

#install dependency

opkg update && opkg install python-distutils python-smbus

cd adafruit-beaglebone-io-python

python setup.py install

.END

No comments:

Post a Comment