@Cliff-Karlsson
I see why. But once again, i think i made your sketch work.
As i see it. This is the current desired logic.
once per second, you want to check the following things:
- is there motion?
- has there been a change in pressure (HIGH to LOW or LOW to HIGH)?
But actually you want to check both ALWAYS. The thing you are obviously looking for, are interrupts. I do not know how these work if you do not want to sleep. Maybe there is a wait(interrupt_pin_1_functor, interrupt_pin_2_functor, waittime=forever) function (I know the sleep() version exists).
Maybe you already know what interrupts are but, in short: When a given interrupt pin notices a difference in value (HIGH to LOW, for example) it gives a signal. The current code is being stopped and the function that is bound to the pin is executed. This function could be sending the new value to the gateway.
Can someone confirm this?