BoneKit is a physical interface toolkit for the BeagleBone.

BoneKit is a ruby library that facilitates the creation of physical interaction experiments using the BeagleBone. It gives access to low-level hardware features (PWM, SPI, I2C, ADC) and includes support for some ICs (TLC5940, ADLX335, HMC5883L).

Getting Started

require 'bonekit'
compass =
heading = compass.heading

Use RubyGems to install:

gem install bonekit

or build and install:

gem install --local pkg/bonekit-0.0.4.gem


This example turns the LED on when a push button is pressed. The pin P9-11 has a 10K pull-up resistor connected to GND.

require 'bonekit'

switchPin = P9_11
ledPin = P9_13, Output

loop do
  ledPin.value = switchPin.value 
  sleep 0.01


Digital Input/Output

pin = P9_11 # Input mode pin by default
digital_value = pin.value # Read digital value (Low or High)

pin.mode = Output # Set mode to Output
pin.value = High # Write digital value (low or High)

Analog Input/Output

pin = P9_39 # Analog pin
analog_value = pin.analog_value # Read analog value (0.0 to 1.0)
pin = P9_42 # Pulse-Width Modulation pin
pin.analog_value = 0.3 # Write analog value (0.0 to 1.0)


device = address # read 1 byte
device.write([0x03,0x00]) # write 2 bytes

Devices (ICs)

compass =
heading = compass.heading # degrees


  • Digital Input/Output (implemented)
  • Analog Input (implemented)
  • Analog Output (implemented)
  • I2C (implemented)
  • SPI (planned)
  • Interrupts (planned)
  • Serial Communication (planned)
  • Devices:
    • HMC5883L (implemented, with issues)
    • ADXL345 (planned)
    • ITG-3200 (planned)
    • TLC5940 (planned)
    • TMP102 (planned)
  • Other:
    • Capacitive Sensor (planned)
    • Resistive Pressure Sensor (planned)