ESP8266 with CapacitiveSensor Library for proximity detection

Hi All,
I am trying to detect proximity using the CapacitiveSensor Library GitHub - PaulStoffregen/CapacitiveSensor: Detect touch or proximity by capacitve sensing
I have tried to use this lib with an Arduino UNO for proximity detection by adding a 1 Mohm resistor between the send and the receive pins.

I have tried the same with the ESP8266 WiFi module and putting the residtor between GPIO 4 and GPIO 5. However, it only detects when I touch the PIN no proximity is detected. Adding to that, on the serial monitor it outputs the timeout error -2 if it is not touched.

Please advise if there is anyway we can workarround this to detect the proximity on the ESP8266 module.

Thank you,

Also posted at:
If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.