Raspberry Pi Interface with TTP229 Capacitive Keypad

Demonstration
TTP229 Raspberry Pi test

Physical connections

keypad connections

Notes

  1. The jumper shown on the board needs to be in place for all 16 keys to be read. Otherwise only 8 keys will be read.
  2. VCC can be 3.3V, so no level shifting is needed for the Raspberry Pi.
  3. There can be some confusion, since a different version of the TTP229 chip uses I2C. This is not an I2C device.
  4. Any GPIO pins can be used. I used GPIO17 for SCL and GPIO4 for SDO.

Python code

import RPi.GPIO as GPIO
import time


GPIO.setmode(GPIO.BCM)
SCLPin=17
SDOPin=4

HALF_BIT_TIME=.001
CHARACTER_DELAY=5*HALF_BIT_TIME

NUM_BITS=16

GPIO.setup(SCLPin,GPIO.OUT)
GPIO.setup(SDOPin,GPIO.IN)

GPIO.output(SCLPin,GPIO.HIGH)
time.sleep(HALF_BIT_TIME)
oldKey=18

try:
	while True:
		button=1
		time.sleep(CHARACTER_DELAY)


		while button < 17:
			print_button=button
			if (print_button==17):
				print_button=1

			GPIO.output(SCLPin,GPIO.LOW)
			time.sleep(HALF_BIT_TIME)
			keyval=GPIO.input(SDOPin)
			if not keyval and not pressed:
				pressed=True
				if(oldKey!=button) :
					print(print_button)
					oldKey=button
			GPIO.output(SCLPin,GPIO.HIGH)
			time.sleep(HALF_BIT_TIME)

			button+=1

		pressed=False
except KeyboardInterrupt:
	pass
	GPIO.cleanup()
    

Notes

  1. The timing can be finicky. Specifically, the CHARACTER_DELAY.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University