It looks like I have a problem with Touch / touchAttachInterrupt running on battery power.
My test application, running on the XIAO ESP32S3, started from TouchButtonV2.ino / Arduino 2.3.2 and runs fine on the USB connection and output on the Serial Monitor. Once I move it over to run on battery, I cannot get it to recognizing a button touch.
My 2 touch pins are connected to T7 and T8
First step, connect an OLED screen to give some debug output and get a right value or - int threshold = 1500; - when running on Battery. I started with touchRead(T7) to get a decent threshold value on both touch pins.
Secondly, I log an event on the OLED just after if (touch1detected) { as well after if (touch2detected) {
Again, running on the USB cable all is OK on the serial monitor as well as on the OLED. As soon as I disconnect the USB cable and run the application on battery, I don’t get events when touching the sensors.
HOWEVER! If I touch both pins at the same time, I get the log messages from touch1detected and touch2detected at the same time on the OLED.
Anybody encountered problems with touchAttachInterrupt ?
if you use the </> button in the message and post the code in that bracket it puts it into a nice code window that makes it easier for us to scroll past without even looking at it… lol
Just for practice, go back and edit your old post and move the code into the bracket…
Ok, in the meantime I installed PlatformIO compiled the code and it woks now as meant to
So building on Arduino the touchAttachInterrupt seems not to work. From now on, moving away from Arduino
Hope this issue might help others. Thanx you for your help
Sorry comming back to this issue.
I recompiled and uploaded again but no joy
I checked all but my problem stays.
Removed the OLED screen and code, just to be sure
Instead of the OLED I introduced the LED_BUILDIN blinking. Blink once on T7 Blink twice on T8.
Code compiles and runs and does the blinking as expected.
HOWEVER: it runs fine as I started this post with. It runs on the USB cable attached to my computer.
Running on battery (>4.00v) I only get T7 or T8 events when pressing the 2 sensors simultaneously
Any suggestion for me to investigate? @PJ_Glasso , did you test the above code on running battery as well?
PS, my remark abot the working on PlatformIO was a mistake. Same issue
Hi there,
Ok so I don’t have the LIB’s “SSD1306Ascii.h” or the wire one?
Are they custom?
You would need to use an Interrupt or IO “Bit MASK” ie. “11000000” for the touch inputs “attach interrupt” you want to generate the interrupt, check the technical ref guide S6 and you get it going as you want.
HTH
GL PJ
Is the charge LED ON , when you plug in the USB with the Battery connected? for how long or always?
Wire.h is a lib for I2C communications and SSD1306Ascii is an unbuffered character only library for small OLED displays. So no worries. I took the OLED out and replaced it with the blinking the onboard LED. Results are the same.
The charge battery LED is not ON. This because I connected the battery to the side strip, not the bottom connectors. I could see and change that
Hi there,
Yea, I know what Wire.h is and Show a picture of this device with the battery connected HOW?
What pins and what side strip? You will still need the interrupt bit mask to get the functionality you described.
I’ll locate the libs if they are standard i.e nothing funny in there.
Have you loaded the factory firmware and example program the device comes with?
also on the WiKi.
GL PJ