element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog Forget Me Not: Episode 13: Watering System Finalization
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: michaelwylie
  • Date Created: 15 Oct 2014 5:38 AM Date Created
  • Views 1236 views
  • Likes 1 like
  • Comments 4 comments
  • forget_me_not
  • iot_auto_monitor
Related
Recommended

Forget Me Not: Episode 13: Watering System Finalization

michaelwylie
michaelwylie
15 Oct 2014

Previous Posts:

 

Epidode 1: Forget Me Not: Application

Episode 2: Forget Me Not: The Best Laid Plans ...

Episode 3: Forget Me Not: Setup EnOcean with openHAB

Episode 4: Forget Me Not: Medication System

Episode 5A: Forget Me Not: Using Notify My Android with OpenHab

Episode 6: Forget Me Not: Plant Watering System Design

Episode 7: Forget Me Not: Medication System Demo

Episode 8: Forget Me Not: Using Twitter

Episode 9: Forget Me Not: Sunshine, Lollipops, and Rainbows

Episode 10: Forget Me Not: It's so hot!

Forget Me Not: Episode 11A: Watering System Construction

Forget Me Not: Episode 11B - Soil Sensor Design

Forget Me Not: Episode 12: An Update

 

Introduction

If you've been following along, you know that I originally wanted to use a two threshold system to activate and run my watering system. After completing my initial design, the RPiSoC boards became available to the Forget Me Not Challengers. The RPiSoc system has an analog to digital converter, something which the RPi lacks. At that point I decided to create a soil sensor that could read the soil moisture level directly and offload the rest of the complexity to software. That is, all thresholds and any other implementation would be completely in software. I spent some of my time designing a soil sensor based on a constant current source, but I lack the parts to build the sensor at this moment. So, in order to move forward I have decided to revert to the two threshold system from my original design. That soil sensor (Funduino) that I ordered from DX.com has still not showed up. It's been almost three months now. I've been in contact with them; the experience was terrible. Therefore, I used a simple resistive divider I mentioned in this post. The non-linear response won't matter for the two threshold system.


The System

Having said all that, I have a watering system that works. I just need to tweak the threshold values over the next few days. Figure 1 shows a photo collage of the Watering System.


image

Figure 1: [Left] Complete watering system in action (laboratory action) Sump & Reservoir, Sensor, and Watering Controller are shown. [Upper Right] Photo showing the preparation of the watering controller enclosure (Rubbermaid dish - not all of us have 3D printers image). [Middle Right] Watering Controller photo showing the internal circuitry. [Bottom Right] Soil Sensor made from a resistive divider.


The Sump & Reservoir are simply a container for water and a sump pump. The sump pump delivers water through the tubing when activated. The Water Controller consists of a custom board, Raspberry Pi B, and a TDK LAMBDA  LS5012 AC to DC power supply. OpenHAB is running on the Raspberry Pi with the EnOcean Pi installed.


GPIO in OpenHAB


This part was, by far, the most time consuming and frustrating for me. I noted early in the competition some other challengers using python scripts and Arduinos to interface to the Raspberry Pi. There is an exec binding for openHAB that allows one to execute commands via the line interface. So, if you wrote a script in python or any other language you like, you could call it from openHAB. I also noted there was a GPIO binding for openHAB that allows the user to directly access the GPIO of the system. The GPIO binding essentially brings in inputs as contact switches and outputs as switches.


Enabling GPIO


1. To enable the gpio binding you have to copy two files into the addons folder:

  • org.openhab.io.gpio-1.5.0.jar
  • org.openhab.binding.gpio-1.5.0.jar

 

2. You also have to modify the config file as such:

#################################  GPIO Binding #####################################

# Optional directory path where "sysfs" pseudo file system is mounted, when isn't
# specified it will be determined automatically if "procfs" is mounted
gpio:sysfs=/sys

# Optional time interval in miliseconds when pin interrupts are ignored to
# prevent bounce effect, mainly on buttons. Global option for all pins, can be
# overwritten per pin in item configuration. Default value if omitted: 0
gpio:debounce=10

 

3. Add this line to your start.sh file after java

-Djna.boot.library.path=/usr/lib/jni


The Implementation

I added three items to my system. A pump control, low threshold, and high threshold. The code added to my item file is as follows:


Switch PumpControl "Pump Status" { gpio="pin:4 debounce:10 activelow:no" }
Contact LowThreshold "Low Threshold" { gpio="pin:27 debounce:10" }
Contact HighThreshold "High Threshold" { gpio="pin:22 debounce:10" }

 

Again, note the PumpControl is an output and it's a Switch in the code. The three attributes setup GPIO pin 4 as active high with a debounce of 10 ms. The switch has two states: ON and OFF. For example, to check the state against ON, try:

 

if (PumpControl.state == ON)

 

If, however, you want to change the state use:

sendCommand(PumpControl, ON)

 

Here is a video demonstrating the use of the PumpControl switch through OpenHAB (warning I meant to say MOISTURE SENSOR):

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Once again, I meant to say Moisture Sensor in the video ...

 

The LowThreshold and HighThreshold contacts are the inputs. This is where it gets weird. Contacts have two states: OPEN and CLOSED. So, in my system I'm checking to see if the LowThreshold and HighThreshold are OPEN or CLOSED. Weird right?

 

OPEN is OFF, and CLOSED is ON. Below is the implementation of the two threshold system. It checks every hour for watering. I will eventually modify this so that it mimics the behaviour of my original design, but this serves to illustrate the working hardware.

 

rule "Watering Check"
when
    Time cron "0 34 * * * ?"
then
    if (LowThreshold.state == OPEN)
    {
        wateringFlag = 1
        sendCommand(PumpControl, ON)
    }
    if (wateringFlag == 1)
    {
        if ((LowThreshold.state == CLOSED) && (HighThreshold.state == OPEN))
        {
            sendCommand(PumpControl, ON)
        }
        if(HighThreshold.state == CLOSED)
        {
            wateringFlag = 0
        }
    }

end

rule "Watering Off"
//Check every 30 seconds to turn off the pump
when
    Time cron "15 * * * * ?"
then
    sendCommand(PumpControl, OFF)
end

 

I've tested this system in my "lab" using a cup of water (100% moisture) and in open air (close to 0% moisture). I'll be installing the unit on my deck in the next few days. Should be interesting to see how it behaves.

 

The last thing I wanted to mention was a quirk I noticed when I reboot my Raspberry Pi. The pump turns on, because gpio 4 floats. Adding a pulldown fixed the problem.

  • Sign in to reply
  • DAB
    DAB over 10 years ago

    Nice update.

     

    I agree, it will be interesting to see how well your system works.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • michaelwylie
    michaelwylie over 10 years ago in reply to mcb1

    This is true. I never explored it any further, but there may be one in place. The wiki never mentioned anything though.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago

    Nice work.

     

    In theory you should be able to map the inputs, and therefore change the OPEN/CLOSED to 1/0 or HIGH/LOW to suit the more conventional thought.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 10 years ago

    Cool stuff image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube