Skip to main content

Grove - Touch Sensor

Grove - Touch Sensor enables you to replace press with touch. It can detect the change in capacitance when a finger is near by. That means no matter your finger directly touches the pad or just stays close to the pad, Grove - Touch Sensor would outputs HIGH also.

Specifications

  • Operating Voltage: 2.0 - 5.5V
  • Operating Current(Vcc=3V):1.5 - 3.0μA
  • Operating Current(VDD=3V):3.5 - 7.0μA
  • Output Response Time: 60 - 220mS
  • Used Chipset: TTP223-BA6
tip

More details about Grove modules please refer to Grove System

Platforms Supported

ArduinoRaspberry Pi
caution

The platforms mentioned above as supported is/are an indication of the module's software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Option features

AHLBTOGLPMBMOTBSLRFTBRSTQOPDO
Output Active High / LowToggle modePower ModeMax. On TimeSampling lengthRESET PINCMOS OutputOpen Drain Mode
VV011XVX
Active HighDisabledLOWInfinite1.6 msecN/APresentN/A

Getting started

Play with Arduino

This demo is going to show you how to turn on/off an LED.

Hardware

  • Step 1. Prepare the below stuffs:
Seeeduino V4.2Base ShieldGrove-Touch_SensorGrove-LED
enter image description hereenter image description hereenter image description hereenter image description
Get One NowGet One NowGet One NowGet One Now
  • Step 2. Connect Grove-Touch_Sensor to port D2 of Grove-Base Shield.
  • Step 3. Connect Grove-LED to port D3 of Grove-Base Shield.
  • Step 4. Plug Grove - Base Shield into Seeeduino.
  • Step 5. Connect Seeeduino to PC via a USB cable.

with_ardu

Software

  • Step 1. Please copy and paste code below to a new Arduino sketch.
const int TouchPin=2;
const int ledPin=3;

void setup() {
pinMode(TouchPin, INPUT);
pinMode(ledPin,OUTPUT);
}

void loop() {
int sensorValue = digitalRead(TouchPin);
if(sensorValue==1)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}

Step 2. Monitor the led on and off.

Play with Codecraft

Hardware

Step 1. Connect a Grove - Touch Sensor to port D2, and connect a Grove - Red LED to port D3 of a Base Shield.

Step 2. Plug the Base Shield to your Seeeduino/Arduino.

Step 3. Link Seeeduino/Arduino to your PC via an USB cable.

Software

Step 1. Open Codecraft, add Arduino support, and drag a main procedure to working area.

note

If this is your first time using Codecraft, see also Guide for Codecraft using Arduino.

Step 2. Drag blocks as picture below or open the cdc file which can be downloaded at the end of this page.

cc

Upload the program to your Arduino/Seeeduino.

success

When the code finishes uploaded, the LED will goes on when you touch the Touch Sensor.

Play With Raspberry Pi (With Grove Base Hat for Raspberry Pi)

Hardware

  • Step 1. Things used in this project:
Raspberry piGrove Base Hat for RasPiGrove - Touch Sensor
enter image description hereenter image description hereenter image description here
Get ONE NowGet ONE NowGet ONE Now
  • Step 2. Plug the Grove Base Hat into Raspberry.
  • Step 3. Connect the touch sensor to port 12 of the Base Hat.
  • Step 4. Connect the Raspberry Pi to PC through USB cable.

note

For step 3 you are able to connect the touch sensor to any GPIO Port but make sure you change the command with the corresponding port number.

Software

attention

If you are using Raspberry Pi with Raspberrypi OS >= Bullseye, you have to use this command line only with Python3.

  • Step 1. Follow Setting Software to configure the development environment.
  • Step 2. Download the source file by cloning the grove.py library.
cd ~
git clone https://github.com/Seeed-Studio/grove.py

  • Step 3. Excute below commands to run the code.
cd grove.py/grove
python3 grove_touch_sensor.py 12

Following is the grove_touch_sensor.py code.


import time
from grove.gpio import GPIO


class GroveTouchSensor(GPIO):
def __init__(self, pin):
super(GroveTouchSensor, self).__init__(pin, GPIO.IN)
self._last_time = time.time()

self._on_press = None
self._on_release = None

@property
def on_press(self):
return self._on_press

@on_press.setter
def on_press(self, callback):
if not callable(callback):
return

if self.on_event is None:
self.on_event = self._handle_event

self._on_press = callback

@property
def on_release(self):
return self._on_release

@on_release.setter
def on_release(self, callback):
if not callable(callback):
return

if self.on_event is None:
self.on_event = self._handle_event

self._on_release = callback

def _handle_event(self, pin, value):
t = time.time()
dt, self._last_time = t - self._last_time, t

if value:
if callable(self._on_press):
self._on_press(dt)
else:
if callable(self._on_release):
self._on_release(dt)

Grove = GroveTouchSensor


def main():
import sys

if len(sys.argv) < 2:
print('Usage: {} pin'.format(sys.argv[0]))
sys.exit(1)

touch = GroveTouchSensor(int(sys.argv[1]))

def on_press(t):
print('Pressed')
def on_release(t):
print("Released.")

touch.on_press = on_press
touch.on_release = on_release

while True:
time.sleep(1)


if __name__ == '__main__':
main()


success
If everything goes well, you will be able to see the following result

pi@raspberrypi:~/grove.py/grove $ python3 grove_touch_sensor.py 12
Pressed
Released.
Pressed
Released.
Pressed
Released.
Pressed
Released.
^CTraceback (most recent call last):
File "grove_touch_sensor.py", line 110, in <module>
main()
File "grove_touch_sensor.py", line 106, in main
time.sleep(1)
KeyboardInterrupt

You can quit this program by simply press ctrl+c.

Play With Raspberry Pi (with GrovePi_Plus)

Hardware

  • Step 1. Prepare the below stuffs:
Raspberry piGrovePi_PlusGrove-Touch_Sensor
enter image description hereenter image description hereenter image description here
Get One NowGet One NowGet One Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.
  • Step 3. Connect Grove-Touch_Sensor to D2 port of GrovePi_Plus.
  • Step 4. Connect the Raspberry to PC through USB cable.

with_rpi

Software

caution

If you are using Raspberry Pi with Raspberrypi OS >= Bullseye, you have to use this command line only with Python3.

  • Step 1. Follow Setting Software to configure the development environment.
  • Step 2. Git clone the Github repository.
cd ~
git clone https://github.com/DexterInd/GrovePi.git

  • Step 3. Excute below commands to use this sensor, please change the port to from D4 to D2.
python3 grove_touch_sensor.py
#!/usr/bin/env python
#
# GrovePi Example for using the Grove Touch Sensor (https://www.seeedstudio.com/wiki/Grove_-_Touch_Sensor)
#
# The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi
#
# Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi
#
'''
## License
The MIT License (MIT)
GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
Copyright (C) 2017 Dexter Industries
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''
import time
import grovepi

# Connect the Grove Touch Sensor to digital port D2
# SIG,NC,VCC,GND
touch_sensor = 2

grovepi.pinMode(touch_sensor,"INPUT")

while True:
try:
print(grovepi.digitalRead(touch_sensor))
time.sleep(.5)

except IOError:
print ("Error")

Here is result:

Schematic Online Viewer

Resources

Projects

Using Grove Touch Sensor To Control Grove LED: How to connect and use Grove Touch Sensor to control Grove LED socket kit.

Touch sensor Grove module:

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...