Soil Moisture Sensor and LM35 sensor

Hello everyone!! I am really noob and i have some questions.
If you can answer them one by one, you would make me really happy:

  1. My soil moisture sensor which i connected to A5 not A0, when i use it alone, without any other sensors, shows values from 62 to 99 when i map it like map(value,0,1023,0,100); . When it is on the air it shows 99 and when it is inside a glass full of water it show 62, not 0. Is my sensor broken? It is one this model:
    Soil Moisture Sensor Link

  2. When i use my LM35 alone, i have no problems. It is accurate, however when i try to use it together with soil moisture sensor, it goes crazy. It shows very different and inaccurate values as temperature. Why is that and what should i do?

  3. I am using my Arduino Mega 2560's 5v pin to power these: 5V 4-Channel Arduino Relay, LM35, Soil Moisture Sensor, Raindrops Module Sensor. Is using the 5V power pin for all of them wrong?

By the way i am also using external 5v battery in my breadboard(i dont connect external voltage source to my arduino, so my arduino gets its power from computer only) for servomotor and another external 5v battery in my breadboard for my fan.

If you can help me, i will appreciate it. It is about my graduation project. Thanks in advance!!

If you can help me

Since you didn't post your code, there is no chance of that happening.

I am sorry, my fault. I am not only a noob in electronics but also forum. Anyway, here are my codes:

Soil Moisture Sensor alone (In which i only get values between 62, in water, and 99, on air):

int moisture= A5;
int value;

void setup()
{
   Serial.begin(9600);
}
void loop(){
   value = analogRead(moisture);
   value = map(value,0,1023,0,100);
   Serial.print("Value :");
   Serial.println(value);
   delay(1000);
}

LM35 with Soil Moisture Sensor (This is the code my LM35 values go crazy like 10C one second and 50C the other second:

float tempC;
int moisture= A5;
int value;

void setup() {
Serial.begin(9600);    
}

void loop()
{
  
    tempC = analogRead(A0);  //Read the analog value from the Lm35 sensor 
    tempC = (5.0 * tempC * 100 )/1024.0;  //convert the analog data to temperature (Dout=vin*step size)...  and step size=vref/resolution)
   
  
   Serial.print(tempC, 1);
   Serial.print(",\t");
   value = analogRead(moisture);
   value = map(value,0,1023,0,100);
   Serial.print("Value :");
   Serial.println(value);
   delay(1000);
   
  }

If you can answer my questions with the number in front of them, i can understand easier. As i told before, i am just a noob in this. Thanks :slight_smile:

Without trying to use the data you get from analogRead() (just printing the actual value, with ID), what do you see happening? A schematic, hand-drawn is fine, would be useful.

I am sorry but i couldnt understand what do you mean. Can you please explain it? Also, when i tried those two sensors together, i only used and my arduino mega 2560. Here is a schematic, only the pins i used are different from this, i already wrote which pins i used.

Schematic

By the way, at the moment, only problem i want to solve is these two's not working together. I just want to get normal values, using both together. That's the only thing i care about.

Try this. It JUST prints the raw values

int moisturePin = A5;
int tempPin = A0;

void setup()
{
  Serial.begin(9600);   
}

void loop()
{
    int tempRawValue = analogRead(tempPin);
    Serial.print("tempRawValue: ");
    Serial.println(tempRawValue);

    int moistRawValue = analogRead(moisturePin);
    Serial.print("moistRawValue:");
    Serial.println(moistRawValue );

    delay(1000); 
}

Show us the output.

Comment out the first three statements in loop(). Compile link and run. Show us some output.

Uncomment them, and comment out the next three. Compile link and run. Show us some output.

By the way. I don't care about how you were SUPPOSED to wired the sensors. I only care about how you ACTUALLY wired them. Draw a picture, and post it.

Hello SunStorm

1/try to add a 100nF between the + and - of the LM35, very near the LM35.

2/Try to add a dummy analogRead() like :

analogRead(tempPin);
int tempRawValue = analogRead(tempPin);

Regards,
bidouilleelec

Hello to you too, bidouilleelec

I haven't tried that 100nF yet, you mean that i should add 100nf to Vcc and GND of LM35 on my breadboard?

And PaulS, here comes the values when working together:
tempRawValue: 38
moistRawValue:989
tempRawValue: 45
moistRawValue:989
tempRawValue: 30
moistRawValue:989
tempRawValue: 68
moistRawValue:988
tempRawValue: 51
moistRawValue:988
tempRawValue: 51
moistRawValue:988
tempRawValue: 34
moistRawValue:988
tempRawValue: 70
moistRawValue:988

Here comes the tempRawValues only, very accurate:
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38
tempRawValue: 38

Here comes the moistRawValues only, very accurate:
moistRawValue:971
moistRawValue:971
moistRawValue:971
moistRawValue:971
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:971
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970
moistRawValue:970

SunStorm:
Hello to you too, bidouilleelec

I haven't tried that 100nF yet, you mean that i should add 100nf to Vcc and GND of LM35 on my breadboard?

add 100nf to between Vcc and GND of LM35 on my breadboard

But try the dummy analogRead()

You are great bidouilleelec!!

At first i didn't realize that what you were telling about dummy is different from PaulS's. But now as you warned me, i checked again and understood what you were meaning about dummy, i am so dumb sorry. That dummy code just did the trick!!

Thank you very much, it means a lot.

And i was so focused on my LM35 so that i forgot my soil moisture sensor is accurate but still not getting 0-1023 values. Here are the raw values together again:

tempRawValue: 52
moistRawValue:991
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:990
tempRawValue: 52
moistRawValue:836
tempRawValue: 52
moistRawValue:692
tempRawValue: 52
moistRawValue:686
tempRawValue: 52
moistRawValue:695
tempRawValue: 52
moistRawValue:665
tempRawValue: 52
moistRawValue:663
tempRawValue: 52
moistRawValue:661
tempRawValue: 52
moistRawValue:660
tempRawValue: 52
moistRawValue:658
tempRawValue: 52
moistRawValue:655
tempRawValue: 52
moistRawValue:656
tempRawValue: 52
moistRawValue:657
tempRawValue: 52
moistRawValue:655
tempRawValue: 52
moistRawValue:655
tempRawValue: 52
moistRawValue:653
tempRawValue: 52
moistRawValue:654
tempRawValue: 52
moistRawValue:651
tempRawValue: 52
moistRawValue:653

At the start, moisture sensor was on air, then i put it in a glass full of water and it only changed to 651. My soil moisture sensor's value range is 651-991 instead of 0-1023. What can be wrong with it?

What can be wrong with it?

Why do you think that there is anything wrong with it? Have you not heard of humidity, or do you not understand what humidity is?

There is moisture in the air. Your sensor is measuring that.

Surely a range of 650 to 990 is sufficient for you to tell if plants need watering, isn’t it?

PaulS:
Surely a range of 650 to 990 is sufficient for you to tell if plants need watering, isn't it?

If it was sufficient for me, i wouldn't be asking right? Also, my concern is not about my lack of conception or knowledge about humidity and the value 990. If you can use a more gentle language, that would be nice.

Yes, due to humidity of air, maybe it says 990 instead of 1023, however my problem is with 650. I will need to show my teacher that when i plunge the sensor in water it gives a value of almost 0. Not 650.

Anyway, after a little research about soil moisture sensors, i have seen that they have a really short life. So, now i consider buying a new moisture sensor.

If you can use a more gentle language, that would be nice.

That'll never happen with PaulS.

Just try to use the information and ignore the tone.