error in flow measurement sketch

Reply #2 explains at least ONE problem quite clearly. There are many others with that code.

You unnecessarily detach the sensor from the system, execute a totally unnecessary, do-nothing, delay for 2 seconds, then attach the sensor again.

Sensor counts are ignored when it is detached from the system.

This should not be difficult to understand.

My approach would be to have the transmitter sketch simply accumulate sensor counts for (say) 1 minute, and every minute transmit that count, along with a sequence number to detect possibly missing transmissions, to the base station for processing. Very simple and easy to code.