- //touch pad defs
- #define TOUCHPIN T8
- #define REPEAT 32
- #define DELAYTOUCHREPEAT 5
- void calibrateTouch(){
- int touch = 0,totalValue = 0;
- //calculate the avarage value
- for(int counter = 0;counter < REPEAT ;counter++){
- //noise delay
- delay(DELAYTOUCHREPEAT);
- touch = touchRead(T8);
- totalValue += touch;
- //debugging purposes
- Serial.println(touch);
- }
- touchTehreshold = totalValue/REPEAT;
- Serial.println(touchTehreshold);
- }
Simple ESP32 touch calibration for changing environment
Simple ESP32 touch calibration for changing environment
We can calculate the threshold value and different capacitance value due to changing environment. For example if you place 3 mm plastic plate onto the touch pad and restart the calibrate code esp32 recalculate the environment capacitance value.
Who is online
Users browsing this forum: No registered users and 96 guests