I saved the g-code in the 'makros's and I did try to call it from several positions within config.g, none of them worked.
I can see the makro is being processed (the machine has LED light and entering a call of the makro to switch it off worked, so there is probably just no information from the sensor at that point of time forcing the makro to simply 'do nothing'?
When it comes to the configuration of the port I will switch to linear-analog as suggested and see how it performs.
Anyway, I appreciate your quick response. I dont have the time to look after it right now but I will continue working on the problem at the beginning of next week, so I will keep you updated.
Best regards
Sascha