Capacitive medium range sensor with STM8
The 1 megaohm source resistor and comparable input impedance of your scope with a 1x probe form a voltage divider preventing the test signal from reaching more than about half value.
Remove the scope probe - this circuit is too sensitive.  If you must try to probe use a 10x probe, but it would be better that you have nothing extraneous connected to the test node at all.