Water level monitoring system using Xbee

In your code, the moment the reading drops below 1000 (or you have no reading at all that round), your relay is set to HIGH again. So make sure you run that snippet only when you have received a valid reading.