touch sensor TTP223 and ESP32

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

touch sensor TTP223 and ESP32

#1 Post by megamarco83 » 02 Sep 2021, 12:58

hi, i would like to use a TTP223 touch sensor on GPIO21 of my ESP32 nodemcu.

i would like to use TTP223 as default ( active high)
ttp223.png
ttp223.png (59.49 KiB) Viewed 9721 times
As far as i know GPIOs of ESP will work with active low...correct?

if i will have the TTP223 far from ESP32 and i want to improve stability and avoid antennas or false triggering is a good idea use a connection like this that will be placed close to ESP32?
acrive high.png
acrive high.png (16.49 KiB) Viewed 9721 times
active low.png
active low.png (6.62 KiB) Viewed 9721 times
thanks!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: touch sensor TTP223 and ESP32

#2 Post by TD-er » 02 Sep 2021, 13:18

Just curious, why don't you use the ESP32 touch plugin for this?
ESP32 does support touch pins directly on some GPIO pins.
You can extend those to a metal pad and tune the sensitivity in the plugin.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: touch sensor TTP223 and ESP32

#3 Post by megamarco83 » 02 Sep 2021, 14:58

yes correct, but i need also to use GPIO21 :-)
so that's correct what i thought to use TTP223 ?
it has been needed the pull-up / pull down with ttp223 ?
thanks

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: touch sensor TTP223 and ESP32

#4 Post by TD-er » 02 Sep 2021, 15:12

I just looked at the datasheet and apparently you can configure it somewhat.
https://datasheet.lcsc.com/szlcsc/TTP223-BA6_C80757.pdf

You can set the module in "toggle mode", meaning you have to tap it to switch state.
And you can invert the logical output.

It seems the module can source current and sink current on the output port. This looks to me like it doesn't need a pull-up or pull-down resistor.

The chip also has some timer counter inside, so I don't think you need anything else to connect it to an ESP.
No need for filtering (except when running long wires maybe)

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: touch sensor TTP223 and ESP32

#5 Post by megamarco83 » 02 Sep 2021, 17:15

thanks for support.
but let me ask a stupid question: the "dafault mode" of TTP223 is active high. so it means that when i touch it, it will send 3v3 to GPIO21 of ESP32.
as far as i know ESP32 (or ESP8266) will use active low (so if i use a mechanical push button, when i press it the GPIO21 will go from 3v3 to 0v)
so...how i can manage the TTP223 that will set GPIO21 at 0v and when i touch it, while i touch it will put GPIO21 at 3v3 and when i release it, it willl set again GPIO21 at 0v ?
it's not a problem for ESP32 / ESP8266 ?

of course the aim is that when i press TTP221 -> GPIO21 change it's status and GPIO19 trigger the relay connected to it.

how i can manage?
there are any problems doing like that using "active high" of TTP223 ?
thanks

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: touch sensor TTP223 and ESP32

#6 Post by TD-er » 02 Sep 2021, 17:38

The switch plugin can be set to invert the logic.
Also you can enable monitoring on a specific pin, which will then generate an event when the state changes and you can handle it in the rules.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: touch sensor TTP223 and ESP32

#7 Post by megamarco83 » 02 Sep 2021, 19:42

ok thanks i think that i understand all....now i'll get a try :)
just last question for TTP223....if i had a power source of 12V DC can i use a ASM1117 to regulate 12v to 5v ?
thanks

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: touch sensor TTP223 and ESP32

#8 Post by TD-er » 02 Sep 2021, 23:26

Typical current drawn by such a sensor is quite low, so the power dissipated in a linear voltage regulator like the AMS1117 is low.
Let's say you have a voltage drop of 7V (12V in, 5V out) at 1 mA.
Then the linear voltage regulator has to dissipate 7V * 1mA = 7 mWatt.
That's not much and well within the capabilities of that regulator.

Next thing to look out for on the datasheet is the max input voltage of the regulator.
The AMS1117 does seem to have an absolute max. of 15V.
So if it is "12V from a battery" I guess it is fine.
If it is "12V from a running car" then nope!
The charging voltage from an alternator in a car is limited to 14.2V, but there will be over voltage spikes, so you will see higher voltages inside a car with running engine.

You can also have a look at those good old 7805 or maybe 78L05
The 7805 can handle 35V input voltage.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: touch sensor TTP223 and ESP32

#9 Post by megamarco83 » 03 Sep 2021, 00:12

No it is a stabilized power supply 12v dc, so i guesst that a1117 could be used :)
I prefer asm1117 because i find small board than 7805 :)

But talking about power sources.... my father's house has an old domotic system (comelit simple bus) that works with 24v dc... So inside wall switches i have this kind of power supply and i want to add an esp8266...
What could be the best and smallest solution for a stepdown to fit: esp + ttp223 + step regulating 24-5v?
Of course i must stay with 24v dc as power source because esp will be working in parallel of actual domotic system and not in place of it, but just adding some features thanks to espeasy :)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: touch sensor TTP223 and ESP32

#10 Post by TD-er » 03 Sep 2021, 23:11

For such a high drop in voltages and also powering an ESP, you should look into DC/DC switching power supply modules.
For example ones using an LM2596, which can be found a lot on AliExpress et.al.

The advice to use a linear voltage regulator to go from 12V to 5V is only based on the low currect used by the TTP223.
If you also try to power an ESP, the poor linear regulator will dissipate way too much heat.
From 12V to 5V using a linear regulator will reduce the efficiency to less that 50%. Going from 24V to 5V (or even 3.3V) will make it even worse.
So then you really must look for switching regulators.
I would go for a DC/DC switching one to make 5V and from 5V to 3V3 you can use a linear regulator.
This will make the cleanest voltage for the ESP and still make it relatively efficient.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 19 guests