touch exception
# help
o
I'm trying out the example code from the
Touch
class, but I'm getting an error when trying to run it:
Copy code
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.53>
******************************************************************************
EXCEPTION error. 
UNKNOWN ERROR 0xffffffff(-1)
  0: touch_read_               <sdk>/gpio/touch.toit:113:3
  1: Touch.read                <sdk>/gpio/touch.toit:58:12
  2: main                      touch-test.toit:21:18
******************************************************************************
The code I'm using is
Copy code
while true:
    touch := Touch (gpio.Pin 0) --threshold=500
    print (touch.read --raw)
    touch.close
    sleep --ms=1000
(plus the relevant imports). I'm using a TTGO T-BEAM, and pins 0 or 32 bothe didn't work... Any ideas?
f
I can reproduce. Will have a look at it.
Found it. I broke touch, when I refactored some of its code for other variants of the ESP32. 😦 Working on a fix now.
o
Thank you! πŸ‘πŸ»
f
fyi: the last version where touch still worked was with Jaguar v1.7.6 (Toit v2.0.0-alpha.38).
Fix for the touch is uploaded and should make it into the next release. I expect us to do one early next week, but it could slip more towards the end of the week.
big thanks for reporting the issue.
k
Fix is included in Jaguar v1.9.3.
o
I'm now getting a different error 😦
Copy code
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.55>
******************************************************************************
EXCEPTION error. 
UNKNOWN ERROR 0x103(259)
  0: touch_read_               <sdk>/gpio/touch.toit:113:3
  1: Touch.read                <sdk>/gpio/touch.toit:58:12
  2: main                      touch-test.toit:21:18
******************************************************************************
f
Is there something in there lines before?
o
This is the complete program:
Copy code
import gpio
import gpio.touch show Touch

main:
  while true:
    touch := Touch (gpio.Pin 32)// --threshold=500
    print (touch.read --raw)
    touch.close
    sleep --ms=1000
(I've attached a cable to pin 32)
f
I was actually able to reproduce. I think by pure coincidence...
When the touch-pin is grounded, then I get this error.
If it's floating (as it should), then the error goes away and the touch functionality works.
o
I have a cable plugged into the pin with a bare end, which would be the bit to touch; but I get the error immediately, before I even touch it.
f
Weird. I do the same. If the bare end touches ground, I get that exact same error. If it doesn't then things work for me.
So the touch sensor got a 0 read.
o
I tried touching the cable while running the program, but same result: error regardless of whether the cable is touched or not.
f
It could be that we are initializing the touch sensor in a bad way, but I just checked again, and can't see anything that sticks out.
Do you maybe have an easy way of testing with Arduino, to see if the setup works there?
o
No, I've only got an ESP32; I can try another one to make sure that that particular one isn't a dud.
f
You can run Arduino on the ESP32.
But if you haven't set it up yet, it's not worth it.
Using the esp-idf would also be an option.
But again: if you haven't set it up...
o
Ah, you mean with the Arduino IDE! I used to do that, but have abandoned it because I prefer toit πŸ™‚
f
πŸ™‚
Just sometimes useful to figure out what we are doing wrong wrt esp-idf calls.
o
I don't know if that helps, but I've just tried with pin 2, and I'm getting a different error:
Copy code
EXCEPTION error. 
ALREADY_IN_USE
  0: gpio_use_                 <sdk>/gpio/pin.toit:389:3
  1: Pin                       <sdk>/gpio/pin.toit:131:17
  2: main                      touch-test.toit:6:21
Same program, so nothing apart from trying to init the pin and then
touch.read
it
(alpha 55)
Doh! I have the pin initialisation in the while loop, so the second time this is executed the pin is actually in use.
It works now with pin 15!
But the program seems to mess up the wifi, as I get a lot of messages about dropped wifi connections from the jag monitor.
Pin 0 still gives the error above. (The Unknown Error 0x103)
f
Might be that pin 0 is pulled low by your board (i wouldn't be surprised if it was a strapping pin). Pin 32 is more surprising to me.
o
It’s a TTGO T-BEAM. As long as any pin works, that’s enough for me πŸ™‚ Quite pleased that it even works through a few mm of plastic – I need it for a waterproof box, and that saves me putting a hole in the case for a physical button.
f
Looked it up, and indeed, gpio 0 is a strapping pin: "GPIO 0 (must be LOW to enter boot mode)" There is likely a pull down resistor on pin 0. I then continued looking, and I think pin 32 is explained here: https://github.com/LilyGO/TTGO-T-Beam/issues/30
o
Ah, so I was just extremely unlucky in my choice of pins 0 and 32 😳
f
I think so.
p
Is it possible somehow to pull GPIO 36 to low?
a
Sorry, I don't talk to strangers.
f
argh. I think I need to change the ai-bot.
a
Sorry, I don't talk to strangers.
f
Bot is kicked.
Is this related to the touch exception?
p
No, my electronic engineer attached a charging circuit to pin 36 and I need to somehow pull it low to start the charging circuit
f
ok. Let's open a different help topic then.
p
Okay πŸ™‚
4 Views