Esp32 wakeup by touch pin

hello,
I write sketch to use esp32 that will auto go into sleep mode if the ADC not have any new change value
and use a build_in function from esp package to call it wake_up again: touchSleepWakeUpEnable(T0, to4val - sen_th) . On Arduino, it build normal, now i try import this sketch into PIO, I got error warning while run build:
error: ‘touchSleepWakeUpEnable’ was not declared in this scope: touchSleepWakeUpEnable(T0, 10);

please show me any adjustment necessary to let it run normal, thanks you !

PlatformIO and Arduino IDE should build the same way, if the same framework version was used and .ino.cpp was converted correctly.

What’s the platformio.ini and code?

You have tried #include <esp32-hal-touch.h>?

Hi maxgerhardt

thank you for quick reply, I’ve try out your suggestion but still got same warning message, below is config file

and here is the sample sketch I get from this site : ESP32 Touch Wake Up from Deep Sleep | Random Nerd Tutorials

https://raw.githubusercontent.com/RuiSantosdotme/ESP32-Course/master/code/DeepSleep/TouchWakeUp/TouchWakeUp.ino

thanks you for your help!

The code, when prefixed with #include <Arduino.h>, compiles flawlessly, with the exact platformio.ini you have given and the latest 6.5.0 version of the espressif32 platform.

RAM:   [=         ]   7.1% (used 23236 bytes from 327680 bytes)
Flash: [==        ]  22.1% (used 289581 bytes from 1310720 bytes)
Building .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 3 ELF sections
Successfully created esp32 image.
===========[SUCCESS] Took 3.90 seconds ===========
1 Like

OMG

I have change with your suggested, it compiles successfully
thank you alot!

Best regard!