user51912: I've connected four YL-69 sensors to my arduino at-mega2560 on analogs pins 0-3. This is combined with four DHT11 sensors that are in digital pins.
The DHT work fine, and I can work one YL-69 moisture sensor that gives correct readings. 
But when I connected the others, the readings are just 100% for all. I'm sure I must have made a mistake in my code somewhere, just can't spot it. 
I've posted the sketch I use below, and the results from serial monitor.
(BTW i added a short delay of 10ms between each reading thinking that may be the issue, but it had no effect).
Serial Monitor:

Sketch:
#include "DHT.h"
#include <SPI.h>        // Include SPI library (needed for the SD card)
#include <SD.h>         // Include SD library

File dataFile;

#define DHTPIN0 10     // what pin we're connected to
#define DHTPIN1 11     // what pin we're connected to
#define DHTPIN2 12     // what pin we're connected to
#define DHTPIN3 13     // what pin we're connected to


// Uncomment whatever type you're using!

#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// How to connect sensors
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht0(DHTPIN0, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);

int output_value ;
int output_value1 ;
int output_value2 ;
int output_value3 ;
int output_value4 ;

unsigned long time;

void setup() {
 Serial.begin(9600); 
 while (!Serial)
    ; // wait for serial port to connect. Needed for native USB port only
  Serial.print("Initializing SD card...");
  if (!SD.begin()) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
 Serial.println("DHTxx test!");
 dht0.begin();
 dht1.begin();
 dht2.begin();
 dht3.begin();
 delay(2000);
}

uint16_t line = 1;

void loop() {
 // Reading temperature or humidity takes about 250 milliseconds!
 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
 float h0 = dht0.readHumidity();
 float h1 = dht1.readHumidity();
 float h2 = dht2.readHumidity();
 float h3 = dht3.readHumidity();
 float t0 = dht0.readTemperature();
 float t1 = dht1.readTemperature();
 float t2 = dht2.readTemperature();
 float t3 = dht3.readTemperature();

 dataFile = SD.open("DHT11Log.csv", FILE_WRITE);
 //  if any result below is NaN (not a number) then something went wrong!
 if (dataFile) {
   output_value= analogRead(A0);
   delay(10);
   output_value1= analogRead(A1);
   delay(10);
   output_value2= analogRead(A2);
   delay(10);
   output_value3= analogRead(A3);
   delay(10);
   output_value4= analogRead(A4);
   output_value = map(output_value,1024,0,0,100);
   output_value1 = map(output_value,1024,0,0,100);
   output_value2 = map(output_value,1024,0,0,100);
   output_value3 = map(output_value,1024,0,0,100);
   output_value4 = map(output_value,1024,0,0,100);
   Serial.print("Moisture : ");
   Serial.print(output_value);
   Serial.println("%");
   Serial.print(output_value1);
   Serial.println("%");
   Serial.print(output_value2);
   Serial.println("%");
   Serial.print(output_value3);
   Serial.println("%");
   Serial.print(output_value4);
   Serial.println("%");
   Serial.print("Humidity  : sensor 0, "); 
   Serial.println(h0);
   Serial.print("  sensor 1, "); 
   Serial.println(h1);
   Serial.print("  sensor 2, "); 
   Serial.println(h2);
   Serial.print("  sensor 3, "); 
   Serial.println(h3);
   Serial.println(" %\t");
   Serial.print("temperature  : sensor 0, "); 
   Serial.println(t0);
   Serial.print("  sensor 1, "); 
   Serial.println(t1);
   Serial.print("  sensor 2, "); 
   Serial.println(t2);
   Serial.print("  sensor 3, "); 
   Serial.println(t3);
   Serial.println(" %\t");
   dataFile.print(line++);
   dataFile.print(":    Temperature = ");
   dataFile.print(",");
   dataFile.print(t0);
   dataFile.print(",");
   dataFile.print(t1);
   dataFile.print(",");
   dataFile.print(t2);
   dataFile.print(",");
   dataFile.print(t3);
   dataFile.print(",");
   dataFile.print("°C,    Humidity = ");
   dataFile.print(",");
   dataFile.print(h0);
   dataFile.print(",");
   dataFile.print(h1);
   dataFile.print(",");
   dataFile.print(h2);
   dataFile.print(",");
   dataFile.print(h3);
   dataFile.print(",");
   dataFile.println("%");
   dataFile.print(",");
   dataFile.print("Moisture : ");
   dataFile.print(",");
   dataFile.print(output_value);
   dataFile.print(",");
   dataFile.print(output_value1);
   dataFile.print(",");
   dataFile.print(output_value2);
   dataFile.print(",");
   dataFile.print(output_value3);
   dataFile.print(",");
   dataFile.print(output_value4);
   dataFile.close();

  }
  // if the file didn't open, print an error:
  else
    Serial.println("error opening DHT11Log.txt");
    delay(10000);
}


user52137: I think that the problem is here: 
output_value = map(output_value,1024,0,0,100);
output_value1 = map(output_value,1024,0,0,100);
output_value2 = map(output_value,1024,0,0,100);
output_value3 = map(output_value,1024,0,0,100);
output_value4 = map(output_value,1024,0,0,100);

replace them with:
output_value = map(output_value,1024,0,0,100);
output_value1 = map(output_value1,1024,0,0,100);
output_value2 = map(output_value2,1024,0,0,100);
output_value3 = map(output_value3,1024,0,0,100);
output_value4 = map(output_value4,1024,0,0,100);


51912: <p>I've connected four YL-69 sensors to my arduino at-mega2560 on analogs pins 0-3. This is combined with four DHT11 sensors that are in digital pins.</p>

<p>The DHT work fine, and I can work one YL-69 moisture sensor that gives correct readings. 
But when I connected the others, the readings are just 100% for all. I'm sure I must have made a mistake in my code somewhere, just can't spot it. </p>

<p>I've posted the sketch I use below, and the results from serial monitor.
(BTW i added a short delay of 10ms between each reading thinking that may be the issue, but it had no effect).</p>

<p><strong>Serial Monitor:</strong></p>

<p><a href="https://i.stack.imgur.com/1xM3l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1xM3l.png" alt="Serial Monitor"></a></p>

<p><strong>Sketch:</strong></p>

<pre><code>#include "DHT.h"
#include &lt;SPI.h&gt;        // Include SPI library (needed for the SD card)
#include &lt;SD.h&gt;         // Include SD library

File dataFile;

#define DHTPIN0 10     // what pin we're connected to
#define DHTPIN1 11     // what pin we're connected to
#define DHTPIN2 12     // what pin we're connected to
#define DHTPIN3 13     // what pin we're connected to


// Uncomment whatever type you're using!

#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// How to connect sensors
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht0(DHTPIN0, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);

int output_value ;
int output_value1 ;
int output_value2 ;
int output_value3 ;
int output_value4 ;

unsigned long time;

void setup() {
 Serial.begin(9600); 
 while (!Serial)
    ; // wait for serial port to connect. Needed for native USB port only
  Serial.print("Initializing SD card...");
  if (!SD.begin()) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
 Serial.println("DHTxx test!");
 dht0.begin();
 dht1.begin();
 dht2.begin();
 dht3.begin();
 delay(2000);
}

uint16_t line = 1;

void loop() {
 // Reading temperature or humidity takes about 250 milliseconds!
 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
 float h0 = dht0.readHumidity();
 float h1 = dht1.readHumidity();
 float h2 = dht2.readHumidity();
 float h3 = dht3.readHumidity();
 float t0 = dht0.readTemperature();
 float t1 = dht1.readTemperature();
 float t2 = dht2.readTemperature();
 float t3 = dht3.readTemperature();

 dataFile = SD.open("DHT11Log.csv", FILE_WRITE);
 //  if any result below is NaN (not a number) then something went wrong!
 if (dataFile) {
   output_value= analogRead(A0);
   delay(10);
   output_value1= analogRead(A1);
   delay(10);
   output_value2= analogRead(A2);
   delay(10);
   output_value3= analogRead(A3);
   delay(10);
   output_value4= analogRead(A4);
   output_value = map(output_value,1024,0,0,100);
   output_value1 = map(output_value,1024,0,0,100);
   output_value2 = map(output_value,1024,0,0,100);
   output_value3 = map(output_value,1024,0,0,100);
   output_value4 = map(output_value,1024,0,0,100);
   Serial.print("Moisture : ");
   Serial.print(output_value);
   Serial.println("%");
   Serial.print(output_value1);
   Serial.println("%");
   Serial.print(output_value2);
   Serial.println("%");
   Serial.print(output_value3);
   Serial.println("%");
   Serial.print(output_value4);
   Serial.println("%");
   Serial.print("Humidity  : sensor 0, "); 
   Serial.println(h0);
   Serial.print("  sensor 1, "); 
   Serial.println(h1);
   Serial.print("  sensor 2, "); 
   Serial.println(h2);
   Serial.print("  sensor 3, "); 
   Serial.println(h3);
   Serial.println(" %\t");
   Serial.print("temperature  : sensor 0, "); 
   Serial.println(t0);
   Serial.print("  sensor 1, "); 
   Serial.println(t1);
   Serial.print("  sensor 2, "); 
   Serial.println(t2);
   Serial.print("  sensor 3, "); 
   Serial.println(t3);
   Serial.println(" %\t");
   dataFile.print(line++);
   dataFile.print(":    Temperature = ");
   dataFile.print(",");
   dataFile.print(t0);
   dataFile.print(",");
   dataFile.print(t1);
   dataFile.print(",");
   dataFile.print(t2);
   dataFile.print(",");
   dataFile.print(t3);
   dataFile.print(",");
   dataFile.print("°C,    Humidity = ");
   dataFile.print(",");
   dataFile.print(h0);
   dataFile.print(",");
   dataFile.print(h1);
   dataFile.print(",");
   dataFile.print(h2);
   dataFile.print(",");
   dataFile.print(h3);
   dataFile.print(",");
   dataFile.println("%");
   dataFile.print(",");
   dataFile.print("Moisture : ");
   dataFile.print(",");
   dataFile.print(output_value);
   dataFile.print(",");
   dataFile.print(output_value1);
   dataFile.print(",");
   dataFile.print(output_value2);
   dataFile.print(",");
   dataFile.print(output_value3);
   dataFile.print(",");
   dataFile.print(output_value4);
   dataFile.close();

  }
  // if the file didn't open, print an error:
  else
    Serial.println("error opening DHT11Log.txt");
    delay(10000);
}
</code></pre>
 52137: <p>I think that the problem is here: </p>

<pre><code>output_value = map(output_value,1024,0,0,100);
output_value1 = map(output_value,1024,0,0,100);
output_value2 = map(output_value,1024,0,0,100);
output_value3 = map(output_value,1024,0,0,100);
output_value4 = map(output_value,1024,0,0,100);
</code></pre>

<p>replace them with:</p>

<pre><code>output_value = map(output_value,1024,0,0,100);
output_value1 = map(output_value1,1024,0,0,100);
output_value2 = map(output_value2,1024,0,0,100);
output_value3 = map(output_value3,1024,0,0,100);
output_value4 = map(output_value4,1024,0,0,100);
</code></pre>
