touch sensor/How a touch becomes HIGH/04. The first half second
How a touch becomes HIGH · 04 of 9

The first half second

For about half a second after power-up the chip measures the pad and calls whatever it finds nothing. Touch it then and your finger becomes the baseline. After that it keeps relearning slowly, and this version of the chip never gives up on a touch: something left on the pad holds SIGNAL HIGH for as long as it stays.

Nothing is a number it has to learn

A touch is a rise in capacitance, but a rise from what? The pad, its track, C5 and whatever is around the board add up to some value the chip cannot know in advance. So it learns it. For about 0.5 s after power-up it measures the pad, treats that as nothing, and ignores the pad meanwhile. The datasheet puts it plainly: during that time, do not touch the key pad.

The first half second
At power-up
Time
0.0 s
On the pad
nothing
SIGNAL
LOW
Power is on. For about 0.5 s the chip measures the pad with whatever is on it and calls that nothing. It ignores the pad meanwhile.

Play each case. With hands clear, the chip learns the bare pad and every touch after that is a rise it can see. With a finger on the pad at power-up, the finger is part of nothing. Lifting it is a fall, which is not a touch, and the next touch only brings the pad back to what the chip thinks is normal. It may be missed.

It keeps relearning

The chip does not learn once and stop. Tontek says it calibrates for life: about every 4 s while the pad is untouched, and again about 16 s after a touch ends. That is how it follows slow change, a warm room, a damp day, a case screwed on after power-up. It is also why a board that started confused often comes right by itself after a few seconds with nothing on the pad. A power-cycle with your hand clear is the quick way.

A touch that never ends

Some TTP223 variants release a touch that lasts too long: after about 100 s the chip treats the thing on the pad as part of the scenery and goes back to LOW. The six-pin package on this board has that limit switched off inside the chip. A finger, a coin or a cable resting on the pad holds SIGNAL HIGH for as long as it rests there.

For a button, that is what you want: a touch held for two minutes is still a touch. For a sensor in a case, it means anything that settles against the pad looks like a finger forever. Keep wires and loose parts off it, and give the pad a clear area in front of the panel.

When it does not work

It ignores the first touch after I plug it in.

Something was on or near the pad in the first half second: a finger holding the board, the cable, the edge of a case. The chip learnt that as nothing. Unplug, keep clear of the pad, plug in again. Waiting a few seconds with nothing on it usually fixes it too, as the chip relearns.

SIGNAL stays HIGH and will not go LOW.

Something is still on the pad, or near enough to count: a wire lying across it, a hand resting on the enclosure, a metal part. The chip in this package never times a touch out, so it will stay HIGH until the thing moves. Clear it, then power-cycle if it still holds.

My sketch sees a touch at power-up.

It should not from the block: the datasheet says the chip keeps the key disabled for its first half second. More often the sketch read the pin before it was set up, or the host's pin has a pull-up during boot. Read SIGNAL after pinMode, and ignore anything in the first half second.

Does it drift over hours?

It adjusts to slow change on its own: Tontek says it recalibrates for life, about every 4 s while nothing touches it. Slow drifts in temperature and humidity are what that is for. Fast ones, like a supply that jumps, are not, and can look like touches.

Where this goes next

Why the first touch after a rest is slower than the next.

Asleep and awake →

Edit this page — content/books/tp223-touch-sensor/the-first-half-second.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →