background preloader

GPIO I2C

Facebook Twitter

Setting up IO Python Library on BeagleBone Black. The majority of this library will need to be run as sudo in Debian and Ubuntu.

Setting up IO Python Library on BeagleBone Black

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, PWM and ADC are accessed. Connecting to your BeagleBone Black (SSH) Let's ssh into the system so we can execute commands. Ssh ubuntu@your.bbb.ip.address ssh ubuntu@your.bbb.ip.address Enter the the password (default is 'temppwd' most likely). Commands to setup and install 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. Linux Examples. These examples are designed to demonstrate how to use a range of our modules on a Raspberry PI.

Linux Examples

You will need an SD card with the latest official Raspbian Linux distribution running on it. I2C Modules The Raspberry PI I2C port is not enabled by default there is a rpi_i2c_setup.doc documenting the process I used to get i2c running on the Raspberry PI. We have provided the source code for download ready to be compiled and used on your system. There is also a diagram below showing which pins on the Raspberry pi's GPIO header to use for the i2c port.

MD49 The RPi serial port is used to communicate with the MD49 and drive the motors. i2cset(8): set I2C registers. Name i2cset - set I2C registers Synopsis i2cset [-f] [-y] [-m mask] [-r] i2cbus chip-address data-address [value] ...

i2cset(8): set I2C registers

[mode] i2cset -V Description i2cset is a small helper program to set registers visible through the I2C bus. Options. Wiki:linux:python:smbus:doc [wiki.erazor-zone.de] Adafruit's Raspberry Pi Lesson 4. GPIO Setup. The GPIO pins can be used as both digital outputs and digital inputs.

Adafruit's Raspberry Pi Lesson 4. GPIO Setup

As digital outputs, you can write programs that turn a particular pin HIGH or LOW. Setting it HIGH sets it to 3.3V setting it LOW sets it to 0V. To drive an LED from one of these pins, you need a 1kΩ resistor in series with the LED as the GPIO pins can only manage a small amount of power. If you use a pin as a digital input, then you can connect switches and simple sensors to a pin and then be able to check whether it is open or closed (that is, activated or not) Some Adafruit projects that use just GPIO. To program the GPIO ports in Python, we need to install a very useful Python 2 library called Rpi.GPIO. The installation process for this is the same whether you are using Raspbian or Occidentalis. Sudo apt-get update. I2C Python Library - 3-Axis Digital Accelerometer (ADXL345) with the Raspberry Pi » Think Bowl. The ADXL345 is a 3 axis accelerometer that can communicated to the Raspberry Pi with I2C.

I2C Python Library - 3-Axis Digital Accelerometer (ADXL345) with the Raspberry Pi » Think Bowl

It offers several advanced features that can be easily incorporated into your project via this library. In general an accelerometer returns the gravitational affects on 3 sensors; for example, if the z axis is perpendicular to the earth, it should have a reading of approximately 1. Some features of this library: Instance initializes with default values for common uses simplifying initial setupSettings can be tweaked for individual applicationsEasy setup for single tap, double tap, or free fall sensingConfigure interrupts to trigger based on activity, taps or free fall Usage Basic Example I2C ADXL345 Basic Example from i2clibraries import i2c_adxl345 from time import * adxl345 = i2c_adxl345.i2c_adxl345(0) while True: print(adxl345) sleep(1) Tap Example Free Fall Example. Adafruit's Raspberry Pi Lesson 4. GPIO Setup. The I2C bus allows multiple devices to be connected to your Raspberry Pi, each with a unique address, that can often be set by changing jumper settings on the module.

Adafruit's Raspberry Pi Lesson 4. GPIO Setup

It is very useful to be able to see which devices are connected to your Pi as a way of making sure everything is working. To do this, it is worth running the following commands in the Terminal to install the i2c-tools utility. sudo apt-get install python-smbus sudo apt-get install i2c-tools sudo apt-get install python-smbussudo apt-get install i2c-tools Run sudo raspi-config and follow the prompts to install i2c support for the ARM core and linux kernel Then reboot! We also recommend going through the steps below to manually check everything was added by raspi-config!

If you are using Occidentalis, then your Pi is ready to go with I2C as far as enabling the hardware goes. Sudo nano /etc/modules sudo nano /etc/modules and add these two lines to the end of the file: