Capacitive Leaf Wetness Sensor Mk1

Capacitive Sensor

General Description

Leaf wetness sensor developed by YetiSystems is capacitive. It has low consumption, quality of the data and long operating life.

It operates at 3V3 or 5V and needs to be connected to a digital input PIN (GPIO).

It is easy to integrate and provides an easy interpretation of the data collected.

The output range from 0 Hz (wet) to 1200Hz as the sensor gets drier. The user can select the threshold level under which the sensor is considered wet .

 

Capacitive Sensor

 

Specification

PARAMETERMINTYPMAXUNITS
Operating Voltage33.3 or 55.5V
Operating Temperature Range -40-+85°C
Storage Temperature Range-55-+125°C
Consumption0.50.851.0mA

 

Pinouts

PINOUT(DIN 47100)
GreenVCC (3.3V or 5V)
Brown DATA - OUT
WhiteGND

Mechanical Informations

 

 

Example 1: Reading YetiSystems Leaf Wetness Sensor MK1 with Archimede

YetiPi YetiSystems
Capacitive Sensor

This module works with acme boards using acmepins library which provide raspberry-gpio-python like GPIO functions for Acme boards.

 -*- coding: utf-8 -*-
from acmepins import GPIO
from time import sleep
import time

# GPIO lw sensor
anem_input = GPIO('N17', 'INPUT')

# initialize vars
last_click = 0
event_started = 0
now_freq = []


def median(lst):
    n = len(lst)
    if n < 1:
            return 0
    if n % 2 == 1:
            return sorted(lst)[n//2]
    else:
            return sum(sorted(lst)[n//2-1:n//2+1])/2.0


# interrupt handler
def event_handler():
    global last_click
    global now_freq
    now = time.time()*1000.
    delta_t = now - last_click

    # first click
    if (last_click != 0) and (len(now_freq) < 10):
        last_click = now
        now_freq.append( freq(delta_t))
    elif (last_click == 0):
        last_click = now
    else:
        sleep(5)


# calculate freq in Hz from milliseconds
def freq(delta_t):
    return int(1./(delta_t/1000.))


# return 1 if the sensor is weat (frequency above threshold) or 0 otherwise
def is_weat(threshold=150):
    global now_freq
    global event_started
    now_freq = []
    # polling
    if event_started == 0:
        event_started = 1
        anem_input.set_edge("falling", event_handler)
    # wait 1 sec
    sleep(2)
    now_freq_med = median(now_freq)
    return int(now_freq_med < threshold), now_freq_med

Example 2: Reading YetiSystems Leaf Wetness Sensor MK1 with Raspberry

In this example we use the RPi.GPIO Python Module. The sensor data cable is connected to port 25 of Raspberry.

# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
from time import sleep
import time

# GPIO lw sensor
anem_input = GPIO('N17', 'INPUT')

# initialize vars
last_click = 0
event_started = 0
now_freq = []


def median(lst):
    n = len(lst)
    if n < 1:
            return 0
    if n % 2 == 1:
            return sorted(lst)[n//2]
    else:
            return sum(sorted(lst)[n//2-1:n//2+1])/2.0


# interrupt handler
def event_handler():
    global last_click
    global now_freq
    now = time.time()*1000.
    delta_t = now - last_click

    # first click
    if (last_click != 0) and (len(now_freq) < 10):
        last_click = now
        now_freq.append( freq(delta_t))
    elif (last_click == 0):
        last_click = now
    else:
        sleep(5)


# calculate freq in Hz from milliseconds
def freq(delta_t):
    return int(1./(delta_t/1000.))


# return 1 if the sensor is weat (frequency above threshold) or 0 otherwise
def is_weat(threshold=150):
    global now_freq
    global event_started
    now_freq = []
    # polling
    if event_started == 0:
        event_started = 1
        GPIO.add_event_detect(25, GPIO.FALLING, callback=event_handler)
    # wait 1 sec
    sleep(2)
    now_freq_med = median(now_freq)
    return int(now_freq_med < threshold), now_freq_med

 

Example 3: Reading YetiSystems Leaf Wetness Sensor MK1 with Arduino

The example prints the frequency detected on sensor connected on pin 7 of Arduino board.

int pin = 7;
unsigned long duration;
unsigned long frequency;

void setup() {
  Serial.begin(9600);
  pinMode(pin, INPUT);
}

void loop() {
  duration = pulseIn(pin, HIGH);
  frequency = 500000/duration;
  Serial.println(frequency);
}

Contact US

For more info or suggestions to improve the documentation