Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Amenhotep
#42742 Hello everybody!

I was wondering, is there any indication that lethe's method (the one proposed in the first answer, using one GPIO) is unreliable? Has anyone tested it and found that it doesn't always work, or that it works faulty?

I think lethe's method is clear, plausible, theoretically sound and proven in practice, but I have a friend claiming that it is unreliable. He told me that some posts in this thread say so. I couldn't find those posts, so I ask you: has anyone experienced any problems with lethe's one pin method of making ESP8266 sense touch?

Shoelessone, have you managed to implement it? Did it work?

Thank you
User avatar
By willfly
#43365 If anyone is interested, here is Arduino C code. Threshold value would depend upon length/thickness of touch wire:

Code: Select allvoid testTouch() {
   DBG_PRINTLN("Testing touch switch...");
   int threshold = 3;
   
   while(true)   {
      int riseTime = 0;
      pinMode(TOUCH_PIN, OUTPUT);
      digitalWrite(TOUCH_PIN, 0);
      delay(1);
      pinMode(TOUCH_PIN, INPUT_PULLUP);
      while(digitalRead(TOUCH_PIN) == LOW)
         riseTime++;
      
      if(riseTime)
         DBG_PRINTLN(riseTime);
      
      if(riseTime > threshold)   {
         DBG_PRINTLN("touch");
      }
      delay(500);
   }
}