@antonholmstedt a pro mini fits if you cut the corners, check out https://forum.mysensors.org/topic/6612/door-sensor-remix-of-some-mys-community-efforts
@lis610 I have found with a 499K resistor the range is reduced to about 1.2m in a ABS box.
With a 1Mohm it was about 3m, I do not have many high value SMD resistors to experiment with but the lower the value the lower the range.
Just tried with a 333K and it operates about 0.8m in free air.
@fdlou147 According to my personal experience, I'd recommend to split up Gateway and Node funktionality and use two seperate mcu's.
Wrt. to the code itself: you only set up a debouncer on one of the pins (finally: Pin 5), as you always redefine the same "flags" over and over again. Perhaps have a look at this imo excellent multi relay/button sketch by korttoma here. This one should be not to hard to adopt to your needs (still, I'd recommend two mcu's).