Your measurement routine disables interrupts after it is done and leaves them disabled - not good.
You need to turn them off to reset your pulse counter, turn them on to get your measurements, turn the off again to copy the results and then turn them back on
int ObtenerFrecuecia() //Function for obtaining the frequency of the flow sensor
{
int frecuencia;
noInterrupts();
NumPulsos = 0; //Pulse numer is reset
interrupts(); //Enable interrupts
delay(500); //Sensor is polled for half a second
noInterrupts(); //Interrupts are disabled
frecuencia = NumPulsos; // We get the half frequency
interrupts();
return frecuencia;
}
and depending on how many pulses you get, you should change NumPulsos from 'int' to 'unsigned int' or 'unsigned long' since there really is no concept of a negative pulse count.
Also, your time variables should be unsigned long as well since that is what millis() returns.