analogRead and Delay trouble

Hello, me and some classmates were working over a simple sketch to read an resistance soil moisture sensor. The problem itself come over when we tried to set off the sensor for an x time and power it only when we were asking for the value. When we read the sensor the analog output, which should be between 0 and 1023, only retrieves 0 - 5 numbers. We figure out that the delay after shutting off the sensor was the main problem and also found that giving a 500 ms delay between power up and analogRead() could solve a bit the problem, but the readings were still different from the always-powered-sensor sketch. Next I will attach the code we are using. I would like to know the electronics principles behind the problem. (For now I know that the cumulative ADC analog port need at least 100ms to retrieve a good read, but still doesn't mean any sense to the problem itself)

void loop() {
digitalWrite(7,HIGH); //powers up the sensor
delay(100); //this delay solves the problem accurately only over 500ms
val=analogRead(analogPin); //fills the variable for sensor value
Serial.println("Value string " + String(val)); //printsout value
digitalWrite(7,LOW); //shuts down the sensor
delay(1000); //this delay is the one making the problem, 
//if you get rid of it you dont even need the first delay to give time for analogRead
}

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.

Nice tutorial from SparkFun. Here...

The reason for the last delay is to minimize corrosion on the sensor contacts from the current flow. And the soil moisture content actually changes pretty slow.

Source voltage supplied from a HIGH data pin will most likely also provide a different analog reading from voltage supplied from a 5v or 3.3v source directly.