Example code and electric scheme to sensor soil moisture

Good afternoon guys, im from Brazil, so sorry for poor english.
Lets go...

I have this sensor:
http://www.ebay.in/itm/Digital-Soil-Moisture-Sensor-Working-voltage-of-3-3-v-5-v-/151236267428?pt=LH_DefaultDomain_203&hash=item2336624da4&_uhb=1

But I could not create code to run it, do not know if it's the connection or even the code or who knows if both schema eletricoquanto code is wrong.
I want a sample code and the electric scheme.

Thks.

connect sensor to 5V, GND and outpin to analog in (eg A0)

int val;
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  val = analogRead(A0);
  Serial.println(val);
  delay(1000);
}

use pot according to datasheet for sensor

doesn´t work.

output 207 or 208 even watering the earth.

I need help.

More detail about my sensor:

http://www.aliexpress.com/store/product/Soil-moisture-meter-soil-moisture-sensor-detection-module-robot-intelligent-car/914980_813125772.html.

I dont know schema eletric this sensor.

The sensor is made with a comparator that is ment to give a digital output.
You should tune the onboard restistor to a level that switch 'when too dry)

Try this prog

void setup()
{
pinMode (A0,INPUT_PULLUP); //same pin as list time... can be any I/O pin except 13
pinMode(13,OUTPUT); // onboard led
}
void loop()
{
digitalWrite(13,digitalRead(A0));
}

You shoud be able to switch led on/off by connection the two rods with wet fingers.
..tune the pot to find suitable switchposition..

Need example schema to connect of sensor to Arduino.

My schema link pin Arduino:

Do on 13
middle on Gnd
vcc on 5v.

I try your code but dont work.

I need help.

thnks

If you follow my previous setup - connect Dout to A0

then importent: pinMode(A0,INPUT); and later: digitalRead(A0);

A0 can be 'any' pin, but since 0,1 and 13 have other use in addition, select pin 2..12 or 14..19(which is same as A0..A5)

My Code:

void setup()
{
 pinMode (2,INPUT_PULLUP);  //same pin as list time... can be any I/O pin except 13
 pinMode(13,OUTPUT); // onboard led 
}
void loop()
{
  digitalWrite(13,digitalRead(2));
  
  Serial.println(digitalRead(2));
}

Don´t work and don´t print.
I don´t know if i make correctly every think.

Thank for your help.

void setup()
{
pinMode (2,INPUT_PULLUP); //same pin as list time... can be any I/O pin except 13
pinMode(13,OUTPUT); // onboard led
Serial.begin(9600); // set serial window to same speed
}
void loop()
{
digitalWrite(13,digitalRead(2));
Serial.println(digitalRead(2));
delay(1000); // not to run too fast in window (will show 1, I guess)
}

It looks correct. Should now be possible, with the onboard potensiometer, to adjust so switchpoint is at suitable humidity
(..if the card has been fed incorrectly, it may even be possible that the opamp is 'RIP')
(I'd check around with a multimeter at the opamps pins. You got the full schematic)

The output of the code is: 0 Maximum in potentiometer
Output 1: to minimum.
If I wet the sensor, nothing happens, it amounts to no light, no minimum or maximum for adjusting the potentiometer.
And now?

when the extreme points at pot changes output, it tells me that the comparator is OK
"Wet pins" means that current can flow between them : e.g. :

  • they are put into moist soil, into salty water or you press your wet fingers over both pins.
    At some position of pot, you shoud be able to change output with "connection" activated/deactivated.

I found this schematic, but it doesn't fit 100%. http://m2.img.dxcdn.com/CDDriver/sku.200142.jpg
A0 is not at pin, but gnd is. I believe this is the correct diagram.
Got a 10k resistor? Connecting that between pins will split 5V to match a point of change near middle position on potmeter

moist.jpg

moist1.jpg

hi,can i ask,what can i use for the moisture sensor for your schematic? two wire or it has a specific prove? thanks!

Attached: your sensor.
Try: Disconnect sensor and put a resitor between those two pins (range 1k..100k)
(the voltage divider you make, will result in a voltage at positiv input of amplifier)
use pot to change voltage at negativ input.
Output is high when (voltage at +) > (voltage at -), else low.