Tag Archives: cypress capsense express

Python I2C Cypress Capsense Library on BeagleBone Black

Over the weekend, I spent some time getting my old Cypress CapSense Express capacitive touch boards to talk to my new BeagleBone Black.

On the BBB, I2C is relatively trivial. It includes internal pull-ups, like the Arduino, so you don’t have to muck around with external resistors. My boards have a spot for pull-ups, but I never populated them, since I expected that I would rarely have a single board running on a bus. The boards also run on 3v3, so that was easy on the BBB.

My language of choice is Python where possible, so I hunted around for libraries to perform I2C over python. SMBus to the rescue! Also, Adafruit has some nice BBB libraries for I2C, which I cribbed as a starting example.

I’ve posted the result to GitHub, alongside my older Arduino/Chipkit Cypress Capsense library, and posted the python module to PyPI, so you can do fetch it with pip or easy_install.

To invoke:

import CypressCapsense_I2C

####### INITIAL SETUP - Only Do Once Per Device
# sensorInit = CypressCapsense_I2C.CypressCapsense_I2C(0x00, debug=True)
# sensorInit.setupDevice()
# sensorInit.changeDeviceAddress(0x5D) # or whatever address you want
########################################################################


## this device has already been set up to use 0x5D as its address
sensor = CypressCapsense_I2C.CypressCapsense_I2C(0x5D, debug=False)

while(True):
    print "0x%02X" % sensor.fetchTouchStatus()