Add Precise Capacitive Touch To Your Raspberry Pi With Bare Conductive's Pi Cap HAT


Bare Conductive’s Pi Cap is an Raspberry Pi add-on board that lets you connect anything to one of the 12 electrodes to control sound, video and more. Pi Cap is perfect for designers, engineers, artists, students or educators who are looking for ways to connect the physical world to the digital world.

It is compatible with Raspberry Pi A+, B+, Zero and later models (any of the 40-pin Raspberry Pi's) and comes with extensive programming libraries and examples written in Python, C++ and Node.js.



Technical Details

• High quality audio output function
• Rich and easy tutorial, and startup
• Python, C ++, Node.js library
• Programmable RGB LED, multi function button
• Prototyping area with GPIO breakout
• A +, B + models with GPIO connector of 40 pins available, and available in Zero

Since the software of this product is in the official Raspbian OS repository, installation is easy. At the same time, updating can also be done with apt-get, just like you do with the core Raspberry Pi packages.

Setting up your Pi Cap

Bare Conductive was kind enough to send me one of their Pi Caps for review and here's my experience after using it. Setting it up and configuring it was a breeze. You can follow their excellently written tutorial to get started in minutes provided you already have a Pi running with Raspbian installed. You can install the “picap” package simply by typing “sudo apt-get install picap” at the terminal. Once the installation process is complete, you need to configure the Pi Cap by typing “picap-setup” at the terminal.



Now that all of the software installed you will probably want to do something with it! Open the terminal and type “picap-intro” and hit Enter. This will take you to an interactive text based tour of the example codes and show you what the Pi Cap is capable of. This tour provides you with an opportunity in terms of interacting with the hardware working and seeing it work in real time. The example codes are well documented and and it shouldn’t take much for a beginner to unpick the code and adapt it to their own uses.

Controlling LIFX LED Using Custom Touch Pads

After going through the example codes you can easily get the flavor of the example libraries provided by Bare Conductive and easily adapt it to your requirements. I had a spare LIFX LED smart bulb lying around and decided to control it via custom touch pads designed using "Conductive Electric Paint" which is just like any other water-based paint, except that it conducts electricity!

Since there is no official API supporting local interface to control the bulbs, I used petrklus python script to control the bulb. You can find the code below which will change the on-board RGB LED on Pi Cap along with WiFi controlled  LIFX LED.

# https://github.com/petrklus/lifx-simple

from time import sleep
import signal, sys, MPR121, subprocess as sp
import RPi.GPIO as GPIO

red_led_pin = 6
green_led_pin = 5
blue_led_pin = 26

# init GPIO using BCM pinout
# look here for more info on pins: http://pinout.xyz
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# set up color pins as outputs
GPIO.setup(red_led_pin, GPIO.OUT)
GPIO.setup(green_led_pin, GPIO.OUT)
GPIO.setup(blue_led_pin, GPIO.OUT)

try:
  sensor = MPR121.begin()
except Exception as e:
  print e
  sys.exit(1)

# handle ctrl+c gracefully
def signal_handler(signal, frame):
  sys.exit(0)

def light_rgb(r, g, b):
  # we are inverting the values, because the LED is active LOW
  # LOW - on
  # HIGH - off
  GPIO.output(red_led_pin, not r)
  GPIO.output(green_led_pin, not g)
  GPIO.output(blue_led_pin, not b)

signal.signal(signal.SIGINT, signal_handler)

while True:
  if sensor.touch_status_changed():
    sensor.update_touch_data()
    if sensor.is_new_touch(11):
      print "electrode {0} was just touched".format(11)
      light_rgb(0, 0, 1) # blue
      sp.Popen(["python","set_colour.py","192.168.1.12","120","50","100","3500"])  # LIFX Bulb control
    elif sensor.is_new_release(8):
      print "electrode {0} was just touched".format(8)
      light_rgb(0, 1, 0) # green
      sp.Popen(["python","set_colour.py","192.168.1.12","220","50","100","3500"])  # LIFX Bulb control
    elif sensor.is_new_release(5):
      print "electrode {0} was just touched".format(5)
      light_rgb(1, 0, 0) # red
      sp.Popen(["python","set_colour.py","192.168.1.12","320","50","100","3500"])  # LIFX Bulb control

  sleep(0.01) 


Veridict

Overall its a nice little add-on board designed for adding capacitive sensing capability to Raspberry Pi. When used in conjunction with the "Conductive Electric Paint" it allows you to express your creativity in every way that you can. By connecting anything conductive to one of the 12 capacitive touch pads, you can easily turn your Pi into a audio effects board via 3.5mm audio jack, or control other applications. Also the extensive tutorials and powerful Python / C++ libraries lets you get started in no time!

The only thing odd with this HAT is how its attached with the Pi. In most of the cases you have the Pi sitting in your desk and then you plug the HAT on top of it. But this is actually the one where you attach it upside down. This is done purposefully so that the Pi Cap can lie flat against the table or a piece of paper so that you can use the conductive ink to draw your circuits!

To learn more about the Pi Cap and its potential applications, do visit their product page here. You can also buy the Pi Cap from Bare Conductive for around $34.50 ex VAT.

0 comments