[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

ESP32 touch sensor. RSS feed
Forum Index » tcMenu Arduinio library
Author Message
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Hi Dave!

I've been struggling to find good quality binary encoders, and have settled in on the ESP32 as my primary platform for projects. Since there's touch support in both the hardware and tcMenu, I figured I'd give it a whirl.

I'm struggling. I've been through all of the permutations in Designer. Nothing works. No errors, but no sensing. I've tried both interrupt and loop. Nothing.

On a lark, I added this to my loop():
Serial.print(touchRead(4)); Serial.print(" ");
Serial.print(touchRead(13)); Serial.print(" ");
Serial.print(touchRead(32)); Serial.print(" ");
Serial.println();

... when that code is present, I see ~200 with no touch, < 100 with touch.... I also see random touches (this seems to be an ADC issue) ... and the tcMenu cursor comes to life (and sometimes moves on its own).

I've got sensors on GPIOs 4, 13, 32 and specified 9, 4, 0 in the Designer.

I've walked through the code and would like to see if I can enable a debug mode. I see lots of info getting passed over to "serdebugF2", but it doesn't appear to be enabled.

Can you point me in the right direction?
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
You can define the threshold and also the parameters as per the esp manual for the esp touch pin plugin. It uses exactly the same values.

IO_LOGGING_DEBUG

Is the flag.

You could define it with plaformIo using a build flag.

On Arduino just uncomment the define in src/IoLogging.h
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Hi Dave.

I'm seeing this already enabled:

// When line below commented out - no logging, when un-commented - logging. You can also define this macro in your build system
#define IO_LOGGING_DEBUG

// END user adjustable section.

... but I've never seen any debug? I'm assuming it goes to serial by default? I'm doing a Serial.begin() in my code -- could that be interfering?
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
Ok, this is interesting. It seems, if I wait long enough (many minutes) ... the touchpad springs to life. Prior to that, it will sit there and say intCount = 0.... and then, wham. It comes to life and works reliably.

I've tested this on a few ESPs. They all act the same way.

in ESP32TouchKeysAbstraction::readValue, I added some debug...

22:43:50.562 -> 504129:TouchKeysAbstraction::readValue: 1546
22:43:50.562 -> 504153:TouchKeysAbstraction::readValue: 5
22:43:50.562 -> 504153:TouchKeysAbstraction::readValue: 5
22:43:50.562 -> 504153:TouchKeysAbstraction::readValue: 1362
22:43:50.562 -> 504153:TouchKeysAbstraction::readValue: 1546
22:43:50.595 -> 504177:TouchKeysAbstraction::readValue: 5
22:43:50.595 -> 504177:TouchKeysAbstraction::readValue: 5
22:43:50.595 -> 504177:TouchKeysAbstraction::readValue: 1363
22:43:50.595 -> 504177:TouchKeysAbstraction::readValue: 1557
22:43:50.633 -> 504201:TouchKeysAbstraction::readValue: 220

Any ideas why the pad would randomly spring to life?
ScubaSteve


Joined: May 14, 2021
Messages: 30
Offline
So it turns out that debug I added ... that shows the values on the pins... was extremely helpful.

Best I can tell, something randomly happens which causes all of the pins to return different values. I was hovering in the 600s with no touch, then it would bounce to 1600s with no touch. It's not an electrical issue -- I've replicated it with nothing connected. I observed the numbers briefly with a small piece of standalone test code and ran with it, unaware there was more of a range than observed.

This is my current theory. I'll play around and overthink and see if I can come up with something else..

Thank you for everything you do!

Steve


uint8_t ESP32TouchKeysAbstraction::readValue(pinid_t pin) {
if(!allOk) return 0;

ensureInterruptRegistered();

uint16_t val;
touch_pad_read_filtered((touch_pad_t)pin, &val);
+ serdebugF3("TouchKeysAbstraction::readValue: ", pin, val);
return val <= pinThreshold;
}
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
For the logging I would ensure that the library you’re editing is the one that’s in use. Calling Serial.begin is needed for it to work.

In terms of the behaviour I would read the esp guide around touch pin setup. There are some requirements, I set up a test board with small coin sized metal pieces soldered to a short wire. There may even be a photo of it somewhere here. The simhub connector example uses esp touch.

I’ll try and look through the code for that later or tomorrow and see if there’s anything else I can remember.
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.