Info about lawn sensor

iko

New member
Hi,

first of all congratulations, really an impressive project.
I'm building my own robot lawn mower from scratch and I'd like to use a lawn sensor instead of the (classic) perimeter circuit.

Unfortunately, I've read the relative page (http://www.ardumower.de/index.php/en/ardumower-topics/sensors/lawn-sensor) but I don't understand how the lawn sensor works. :dry:
Please could anyone explain me how I can build one or where I could buy (and use) it ?

Thanks

Bye
Fred
 
Hello,

The lawn sensor consists of a metal plate, a resistor (2 MOhm) and two Arduino pins:
See here: http://www.ardumower.de/index.php/en/ardumower-topics/sensors/lawn-sensor
Initially, the plate is discharged by pulling the send pin to low. Then, the send pin is set to high - now the plate is charging slowly. By constantly reading the receiver pin, the Arduino measures the time until it becomes high (capacity measurement). Because microcontrollers are fast and precise in time measurement, you can measure very low capacities with this. Because lawn has another capacity as non-lawn, the measured time is different.

Code:

Code:
pinMode(pinSend, OUTPUT);
inMode(pinReceive, INPUT);
int v = measureLawnCapacity(pinSend, pinReceiver);

// measure lawn sensor capacity 
int measureLawnCapacity(int pinSend, int pinReceive){
  int t=0;    
  digitalWrite(pinSend, HIGH);    
  while (digitalRead(pinReceive)==LOW) t++;        
  digitalWrite(pinSend, LOW);  
  return t;
}


Idea for evaluation (lawn /non-lawn evaluation):

if ((lawnSensorUse) && (millis() >= nextTimeLawnSensor)){    
    nextTimeLawnSensor = millis() + 100;               
    double accel = 0.03;
    lawnSensorFront = (1.0-accel) * lawnSensorFront + accel * ((double)readSensor(SEN_LAWN_FRONT));
    lawnSensorBack  = (1.0-accel) * lawnSensorBack  + accel * ((double)readSensor(SEN_LAWN_BACK));        
  }
 if ((lawnSensorUse) && (millis() >= nextTimeLawnSensorCheck)){          
    nextTimeLawnSensorCheck = millis() + 2000;               
    double deltaFront = lawnSensorFront/lawnSensorFrontOld * 100.0;    
    double deltaBack = lawnSensorBack/lawnSensorBackOld * 100.0;        
    if ((deltaFront <= 95) || (deltaBack <= 95)){
      Serial.print("LAWN ");
      Serial.print(deltaFront);
      Serial.print(",");
      Serial.println(deltaBack);
      lawnSensorCounter++;
      lawnSensor=true;
    }
    lawnSensorFrontOld = lawnSensorFront;
    lawnSensorBackOld  = lawnSensorBack;
  }


Let me know if you have any specific question.

Regards,
Alexander
 
I would put the plate in a plastic tube, and install the tube so that the sensor has a distance of about 2.5cm from the ground. See here: http://www.ardumower.de/images/lawn_sensor.jpg
 
Dear Alexander,

very impressive for me is the fact that you and other members of this community spend a lot of time to help many fans of ardumower.de to solve their inividual problems in understanding complex but also simple background questions. You show a lot of patience doing this. In the name of all those who learned a lot about software, hardware, logic, ... by reading, asking and discussing with you and other specialists on this site I would like to say THANK YOU VERY MUCH!

Best regards ...

Peter
 
Would it not be better to use as receive pin an ADC or comparator pin?
The high level of an input pin is not precisely defined, the typical range is 0.6*VCC to VCC+0.5V.

Werner
 
Hi Alexander,

I am trying to make the lawn sensor with my ARDUINO MEGA and I am able to do it until measuring the time, that is:

"
pinMode(pinSend, OUTPUT);
inMode(pinReceive, INPUT);
int v = measureLawnCapacity(pinSend, pinReceiver);

// measure lawn sensor capacity
int measureLawnCapacity(int pinSend, int pinReceive){
int t=0;
digitalWrite(pinSend, HIGH);
while (digitalRead(pinReceive)==LOW) t++;
digitalWrite(pinSend, LOW);
return t;
}
"

But I am not understand the second part (IDEA TO DETECT THE LAWN). Could you please help me to write the code, since I am a novice programmer?.

Thanks in advance and congrats about this great page.
 
Oben