GithubHelp home page GithubHelp logo

Comments (5)

mcauser avatar mcauser commented on July 24, 2024

The TTP223 module as pictured has two solder-bridge pads on the back labelled A and B.
These determine whether a touch drives the OUT pin HIGH or LOW, and whether it's momentary or latching (stays on until pressed again).
https://github.com/mcauser/micropython-ttp223#trigger-mode

On my TTP223 both A and B are no bridged, which means: Momentary, output HIGH (when pressed).

The PCF8575's interrupt should fire on any rising or falling edge when the pin is in input mode.

Here's a working example on my TinyPICO.

TinyPICO PCF8575 TTP223
3V3 VCC VCC
GND GND GND
22 SCL
21 SDA
5 INT
P0 OUT
import pcf8575
from machine import Pin, I2C
i2c = I2C(scl=Pin(22), sda=Pin(21))
pcf = pcf8575.PCF8575(i2c, 0x20)

# set all pins as inputs (HIGH)
pcf.port = 0xffff

# make sure the pin is being pulled up as the PCF int will pull it LOW when it fires
p5 = Pin(5, Pin.IN, Pin.PULL_UP)

print(p5.value())
# shows 1 (high)

print(pcf.port)
# shows 65534 or 0xFFFE
# meaning all pins are HIGH except for P0 which is being pulled LOW by the TTP223

# simple interrupt handler that prints the INT pin value and the PCF pin values
def handler(p):
	print(f'Pin5: {p5.value()}, Port: {pcf.port}')

# trigger on rising and falling edges
p5.irq(trigger=Pin.IRQ_RISING|Pin.IRQ_FALLING, handler=handler)

# press and hold and the TTP223 button prints
Pin5: 0, Port: 65535
Pin5: 1, Port: 65535

# release and the TTP223 button prints
Pin5: 0, Port: 65534
Pin5: 1, Port: 65534

# switch int off
p5.irq(None)

# trigger on falling edge only
p5.irq(trigger=Pin.IRQ_FALLING, handler=handler)

# pressing the TTP223 button prints
# Pin5: 0, Port: 65535

# releasing the TTP223 button prints
# Pin5: 0, Port: 65534

from micropython-pcf8575.

mcauser avatar mcauser commented on July 24, 2024

Make sure you pull Pin 15 HIGH for it to detect when the PCF pulls it LOW on INT.

On the ESP8266, GPIO15 is usually pulled to GND as BOOT fails if it's pulled HIGH.
(Your script can set it HIGH after booting, but you shouldn't use a hardware pull up (resistor) to be safe)
https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

Maybe it's better if you use a different GPIO for the INT. GPIO0 and GPIO2 are normally pulled HIGH and driven LOW.

from micropython-pcf8575.

Vacant0mens avatar Vacant0mens commented on July 24, 2024

If I'm not using SPI, I could use pin 14 for my interrupts, right?

from micropython-pcf8575.

mcauser avatar mcauser commented on July 24, 2024

Sure can. If not using SPI, it's just a regular GPIO pin.

from micropython-pcf8575.

Vacant0mens avatar Vacant0mens commented on July 24, 2024

That worked! thank you!
Seems like using the wrong pin is the bane of my existence.

from micropython-pcf8575.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.