How to implement an automatic alarm function for a flow meter?