Rather than using an out-of-the-box capacitive touch solution for my projects, I thought I'd attempt making my own little breakout board. The idea is to use a sensor capable of triggering normal digital input pins using touch.
This post covers the selected touch sensor IC, the circuit used, getting a custom PCB made and how to use it in a project. At the end of this post, you'll find a video covering the soldering and a brief demo of the custom board.
Touch Sensor IC
While searching for capacitive touch solutions, I quickly came across two different ICs: the Freescale MPR121 (as used in the Touch Board) and the Atmel AT42QT10XX. The MPR121 comes in a QFN package, immediately making it more difficult to use. It has up to 12 inputs and an I2C interface. It can operate from 1.7 to 3.6V making it slightly more difficult to work with when using a 5V host.
Comparing the specs of the MPR121 with the AT42QT10XX IC, I decided to pick the latter.
Atmel AT42QT1070
Some of the features worth mentioning are:
- SOIC14 package
- up to seven inputs
- fully debounced outputs
- suppresses effects of external noise
- touch sensing using single pin
- different operation modes (see next paragraph)
According to the datasheet, the keys can also be operated behing panels of glass (up to 10mm thick) or plastic (5mm).
And finally, because it can operate at voltages from 1.8V to 5.5V, it can be used in combination with a wide variety of boards, such as Arduino (5V logic level) or Raspberry Pi (3.3V logic).
Operating modes
There are two modes the touch sensor IC can operate in:
- comms mode
- standalone mode
In comms mode, the sensor can have up to seven input keys and interfaces with a master microcontroller or SBC via I2C. The I2C interface can for example also be used to configure sensitivity of the different input keys. A typical connection diagram for comms mode is the following (as provided in the datasheet):
The other mode, standalone mode, does not make use of the I2C interface but rather converts up to five capacitive touch inputs into digital outputs. This is useful to convert digital inputs on a microcontroller board or SBC into capacitive touch inputs. Because the I2C interface is not used, sensitivity of the touch inputs cannot be configured and is static. The connection diagram for standalone mode is the following:
Different versions
Depending on the application's required number of inputs, different ICs of the same family can be used.
Just to name a few:
- AT42QT1010: single channel
- AT42QT1040: four channels
- AT42QT1111: eleven channels
A full list can be found here: Dedicated Touch Devices
Schematic and Board
I chose to make a breakout board for the standalone mode. The circuit is simple as it only involves the touch IC, a couple of resistors and a capacitor. It was a bit trickier to fit everything in the smallest form factor possible, but that worked out well as you can see below.
The schematic and board were created using Eagle and the AT42QT1070 component was downloaded from the Farnell page of the part (AT42QT1070-SSU - ATMEL - SENSOR, QTOUCH, 7-KEY, 14SOIC | Farnell element14).
This is only a first version. I'll be releasing the files after some possible improvements, such as:
- including pull-up resistors for the input pins rather than relying on the attached microcontroller board/SBC using internal pull-ups
- LED indicators to show which input is active, as this may be useful for easy troubleshooting
PCB
To get the PCB done, I used SeeedStudio. The service is cheap, at about $12 for 10 boards, including shipping. The only downside is perhaps the fact that it takes two weeks between ordering and receiving the boards. While waiting for the PCB to arrive, I ordered the parts so I could populate the board once it got here. I purchased the AT42QT1070AT42QT1070 from Farnell, the other bits I had available.
Once all the pieces were available, I took out the soldering paste, heated the pre-heater and hot air rework station, laid out the components on the board and reflowed the solder. The result can be witnessed in the pictures below. To see the whole process, be sure to watch the video at the end of this post.
Before hooking up the board to something else, I used my multimeter to check all the connections were correct and no shorts were introduced while soldering.
Code
For testing, I decided to used the breakout board in combination with a Raspberry Pi. The board was powered using the Raspberry Pi's 3.3V and GND pins. The touch sensor's first output was connected to the Pi's GPIO17 and the sensor's first input to a jumper wire.
Using the code below, GPIO17 is configured with internal pull-up resistor and is pulled low when the sensor's first input is touched.
import time import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17,GPIO.IN,pull_up_down=GPIO.PUD_UP) #initialise a previous input variable to 1 (assume button not pressed last) prev_input = 1 while True: #take a reading input = GPIO.input(17) #if the last reading was high and this one low, print if ((not input) and prev_input): print("Button pressed") #update previous input prev_input = input #slight pause to debounce time.sleep(0.05)
The code can easily be extended to support all five inputs, as long as the GPIO pins are configured with internal pull-up.
Video
In the video below, you can see me populating and soldering the custom PCB, followed by a little demo of the board used with a Raspberry Pi.
Top Comments