Need to connect flow sensor with in-line heater

Hello! I have built an in-line heater with two DS18B20 temperature sensors and a relay that turns the heater on and off when the temperature gets above or below a certain temperature. I need to connect a GREDIA 1/4 inch water flow meter that causes the relay to turn the heater on when it senses flow, and off when there’s no flow. I’m not sure how to incorporate that code into my current code. I would really appreciate all the help i can get. I have attached my current code.

Temp_Sensor_Final.ino (1.17 KB)

Put together the code for a free-running timer. A free-running timer does not have a condition to control its operation. Monitor the timer with a compare to know when the timer accumulates a value greater than some preset value. This condition will control the relay.

Condition the flowmeter pulses (pulses assumed) with state change detection code, found at IDE -> file/examples/digital. Whenever the flowmeter transitions from low-to-high or vice versa, your choice, reset the timer - set its accumulated value equal to millis().

As long as pulses come in often enough to keep the timer from timing out you know to turn on the relay. If pulses stop, timer times out and shuts off relay.