A thermal flow sensor is equipped with a self-test unit that monitors the device and generates a fault signal in the presence of a malfunction. The self-test unit can e.g. monitor the integrity of a membrane carrying the heater and temperature sensors, or it can monitor various operational parameters of the device, thereby increasing the safety of the device.