# Stemma qt / qwiic direct to GPIO pins for capacitive touch sensor

**URL:** <https://forum.core-electronics.com.au/t/stemma-qt-qwiic-direct-to-gpio-pins-for-capacitive-touch-sensor/12174>\
**Category:** Support\
**Created:** [20 November 2021 07:57 UTC](https://forum.core-electronics.com.au/t/stemma-qt-qwiic-direct-to-gpio-pins-for-capacitive-touch-sensor/12174 "2021-11-20T07:57:51Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Oliver33](https://avatars.discourse-cdn.com/v4/letter/o/a9adbd/32.png) [@Oliver33](https://forum.core-electronics.com.au/u/Oliver33)\
**Post date:** [20 November 2021 10:54 UTC](https://forum.core-electronics.com.au/t/stemma-qt-qwiic-direct-to-gpio-pins-for-capacitive-touch-sensor/12174/6 "2021-11-20T10:54:55Z")

</div>

Hmm, seems like you need to set the pins as well as the bus, like this guy does (though this example is in C++ instead of Python)

[![](https://img.youtube.com/vi/092xFEmAS98/maxresdefault.jpg "Beginners Guide to I2C on the Raspberry Pi Pico (BNO055 IMU Example)") ](https://www.youtube.com/watch?v=092xFEmAS98)

Having a quick look through the [python code](https://github.com/CoreElectronics/CE-PiicoDev-Unified/blob/main/PiicoDev_Unified.py), it appears it’s not enough to just set the pins, you also need to set the frequency or it’ll ignore your pin request inputs.

You’ll also need to `import from machine I2C, Pin`, or alternatively, just `import machine` if you’ve got the space. Then you can set your sda and scl pins, and create your object using:  
`touchSensor = PiicoDev_CAP1203(touchmode='single', freq=400000, sda=Pin(0), scl=Pin(1))`

Here are some examples from the documentation:

```auto
from machine import Pin

p0 = Pin(0, Pin.OUT) # create output pin on GPIO0
p0.on() # set pin to "on" (high) level
p0.off() # set pin to "off" (low) level
p0.value(1) # set pin to on/high

p2 = Pin(2, Pin.IN) # create input pin on GPIO2
print(p2.value()) # get value, 0 or 1

p4 = Pin(4, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
p5 = Pin(5, Pin.OUT, value=1) # set pin high on creation

```

```auto
from machine import Pin, I2C

i2c = I2C(0) # default assignment: scl=Pin(9), sda=Pin(8)
i2c = I2C(1, scl=Pin(3), sda=Pin(2), freq=400_000)

```

PS, here are the default I2C values if you don’t specify them:  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/d/de0bc743664a87c3e3341cb9e64e72dac7ee32a1.png)

See:  
[https://docs.micropython.org/en/latest/library/machine.Pin.html](https://docs.micropython.org/en/latest/library/machine.Pin.html)  
[https://docs.micropython.org/en/latest/library/machine.I2C.html](https://docs.micropython.org/en/latest/library/machine.I2C.html)

> **[raspberry-pi-pico-python-sdk.pdf](https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf)**
>
> 2.20 MB

> **[Raspberry Pi Documentation - MicroPython](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html#documentation)**
>
> The official documentation for Raspberry Pi computers and microcontrollers

[https://docs.micropython.org/en/latest/rp2/quickref.html#general-board-control](https://docs.micropython.org/en/latest/rp2/quickref.html#general-board-control)

---

_[View the full topic](https://forum.core-electronics.com.au/t/stemma-qt-qwiic-direct-to-gpio-pins-for-capacitive-touch-sensor/12174)._
