Tutorial #5: Capacitance and Conductive Materials

Tutorial and Research by Tommy Dylan

Capacitance and Conductive Materials

Capacitance is a really useful way of embedding interactions onto and into physical materials like paper and also glass. Capacitance sensing is central to multi-touch screens and is surprisingly simple to recreate with an Arduino or Raspberry Pi (other controllers apply).

For more in depth information on capacitive sensing, click here.

We are not going to worry too much about the science but take a hands on look at how we can make use of these principles.

Some examples of previous interaction experiments can be found here.

Conductive Materials

Solids
Paperclips in Glass

Copperwire in Glass

Paper clips on the left and copper wire on the right

Any solid conductive material (images above) can be used to create a capacitance sensor. This means copper wire/tape, paper clips, or nails. So long as you can connect a wire to it. Many of these materials can also be fused into glass.

Powders
Carbon Powder Touch Sensor

Putting Carbon Powder in Glass

Carbon powder touch sensor

Some powders can also be fused and work fairly well, carbon powder works (images above), but not copper powder. The copper powder becomes heavily oxidised and no longer forms one solid conductor. The challenge with powders is getting enough in and making a clean connection with a copper wire to connect it to a circuit.

Inks

Bare Conductive ink works nicely, this can only be used cold. This ink is an acrylic based paint with a high carbon powder content. It works really well with capacitance and has a degree of resistance alo depending on the pattern created, this means it can also detect distance from the printed image.

Bare conductive ink

Filling sand-blasted grooves with bare conductive ink

Previous glass examples involved creating grooves in the glass to fill with bare conductive paint (image above) and adding a wire to the paint, or using a crocodile clip (bulldog clip or paper clip) on one end to make contact. These grooves can be patterned of course and or you can put it on the back and it will be sensed from the other side. By increasing the sensitivity, bare ink will work through materials like glass as I will demonstrate in the examples below.

Working with Capacitance

MPR121 and conductive paint on paper
Conductive paint on paper

Conductive Paint on Paper

Bare Ink on Paper Connected with Paper Clips

In the first examples we are going to use conductive paint and paper. First thing, we need to set up the MPR121 board in order to detect touch. This is a breakout board module for the Arduino that we can use to detect touch or release. MPR121 allows us to change the sensitivity so we can detect proximity and it can work through some materials up to around 5mm (important to test this first). For greater sensitivity, or as an alternative, we can also use a combination of resistors and a special library for the Arduino. For now we will stick with the MPR121 as it is more reliable.

Designing Shapes and Patterns

Some useful parameters for designing conductive patterns can be found here.

In simple terms, large shapes work better for proximity and small work best as touch points. If you are making a large shape then hatching results in a better proximity reading than a solid shape.

Wiring the board
MPR121 Circuit

Wiring the MPR121

Installing the Library

ZIP library download

Arduino IDE: Sketch > Include Library > Add .ZIP Library > Browse to zip file

Example Code

Libraries come with useful examples that can act as simple starting points for working with sensors.

We will start with a built in example: File > Examples > MPR121 > Simple Touch

Note: You must change the following line:

   if(!MPR121.begin(0x5C)){ 
to

   if(!MPR121.begin(0x5A)){ 


Sensitivity

The sensitivity can be altered by changing the following two lines:

   MPR121.setTouchThreshold(40);
   MPR121.setReleaseThreshold(20);

The provided values above work well for highly conductive materials.


For bare conductive ink, depending on the pattern, the following should work for touch:

   MPR121.setTouchThreshold(5);
   MPR121.setReleaseThreshold(2);


And for proximity sensing at a distance:

   MPR121.setTouchThreshold(1);
   MPR121.setReleaseThreshold(0.5);


If you are experimenting note that the setTouchThreshold is always higher than the release otherwise it will not work at all.


Sensing Distance

MPR121 with bare conductive ink can also let us detect distance values that can be used to control outputs in an analog way, so you can control brightness for example based on how far your hand is from the piece of paper. The setup is the same, we just need the following example code to do this.

https://pastebin.com/rTecj7i4

This is usefully demonstrated by going to the Serial Plotter and showing the change in values visually. Larger areas of Bare Conductive Ink work best for sensing distance.

Tools > Serial Plotter

Capacitance Sensing with Big Resistors

Another way of detecting touch is with large resistors and a capacitance touch library for the Arduino. This tends to be much more sensitive and you can easily get form values from the sensors allowing some basic and sometimes unreliable distance sensing.

Capacitance with Resistors Circuit

Capacitance with resistors

The library can be found here.

Example code and further information can be found here.

If your capacitance touch pins to the resistors are not wired up, or wired incorrectly, then the code will run extremely slowly. If you have this problem check your wiring.