Shop OBEX P1 Docs P2 Docs Learn Events
bs2 analog I/O — Parallax Forums

bs2 analog I/O

BullwinkleBullwinkle Posts: 101
edited 2006-01-10 13:36 in BASIC Stamp
Kicking around ideas for a rain sensor for my irrigation controller. Would it be possible to rig up a resistive pair of tin foil plates, say, and supply it with +5v and have the stamp read the voltage on the other side?

If the voltage is zero, the the plates are dry, but if the voltage is 0.25v (say) then that plates are wet, therefore it is raining, or has rained recently?

In other words is there an analog input on the stamp somewhere that I could read the 0.25v ( or whatever ) voltage from. Or would I somehow have to convert this to a digital (TTL level) input?

Thanks.

Comments

  • BullwinkleBullwinkle Posts: 101
    edited 2006-01-06 00:06
    D'oh - found my answer in the FAQ!

    RTFM!!! smile.gif

    What can I use the I/O pins for?
    The BASIC Stamp’s I/O pins are perfectly suited for digital input and output with TTL/CMOS level (0 to 5 volt)
    signals. However, you can use some special commands and techniques to input and output limited analog signals.
    For example, the RCTIME and PWM commands can be used to read a variable resistance or output a variable
    voltage from 0 to 5 volts. The I/O pins can not be used to read analog voltages by themselves, however, but this
    can be done by interfacing the I/O pins to an A to D converter chip.
  • Robert KubichekRobert Kubichek Posts: 343
    edited 2006-01-06 00:30
    Bullwinkle said...
    Kicking around ideas for a rain sensor for my irrigation controller. Would it be possible to rig up a resistive pair of tin foil plates, say, and supply it with +5v and have the stamp read the voltage on the other side?

    If the voltage is zero, the the plates are dry, but if the voltage is 0.25v (say) then that plates are wet, therefore it is raining, or has rained recently?

    In other words is there an analog input on the stamp somewhere that I could read the 0.25v ( or whatever ) voltage from. Or would I somehow have to convert this to a digital (TTL level) input?

    Thanks.

    The links below are great for a personal weather station, which you should need in order to set up an accurate irrigation controller.

    Here is a link to a 1-wire weather station;
    www.maxim-ic.com/products/ibutton/solutions/product.cfm?id=11


    Here is a link to 1-wire I-button site, with very good links towards bottom of page (humidity sensor, rain gauge);
    www.maxim-ic.com/products/ibutton/weather/index.cfm#humid


    Here is a web page that is titled " An instrumentation network for weather data on the Web ":
    www.javaworld.com/javaworld/jw-05-1999/jw-05-javadev.html


    This info should get you going, besides interfacing to the stamp, it can also be interfaced to a PC, or the PINK module...yeah.gif

    Bob N9LVU scool.gif
  • BullwinkleBullwinkle Posts: 101
    edited 2006-01-06 00:55
    Thanks Robert!

    Some great ideas in those links. I love the seesaw rain gauge idea. Since all I want to do is detect rain, I can probably build a much simpler device based on the same principle, and it's digital - which solves another problem right there!

    My idea at this stage is to have the software poll the rain sensor at regular intervals and add to a counter each time the sensor is detected as being "on". Then, once the rain sensor returns to the "off" position, start decrementing the counter every x cycles until it reaches zero once again. If the counter is non-zero then disable all watering events. Calibrating the counter decrement rate will take some trial-and-error.

    This is GREAT. I'm having fun already! smile.gif
  • BeanBean Posts: 8,129
    edited 2006-01-06 01:00
    Bullwinkle,
    If you use the BS2px you could use the built-in comparitor to do what you want.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    "I hope the goonwave is not vaporware"
    ·
  • BullwinkleBullwinkle Posts: 101
    edited 2006-01-06 01:13
    Thanks Bean!

    An analog comparitor! That's fantastic. These little guys can do just about anything.
  • Robert KubichekRobert Kubichek Posts: 343
    edited 2006-01-06 01:46
    Bullwinkle said...
    Thanks Robert!

    Some great ideas in those links. I love the seesaw rain gauge idea. Since all I want to do is detect rain, I can probably build a much simpler device based on the same principle, and it's digital - which solves another problem right there!

    My idea at this stage is to have the software poll the rain sensor at regular intervals and add to a counter each time the sensor is detected as being "on". Then, once the rain sensor returns to the "off" position, start decrementing the counter every x cycles until it reaches zero once again. If the counter is non-zero then disable all watering events. Calibrating the counter decrement rate will take some trial-and-error.

    This is GREAT. I'm having fun already! smile.gif

    If you calibrate the rain sensor, take the total for say a"24hr time period" store the amount, and subtract that amount from your "daily" plant requirement.
    The remainder will be the amount that you need to "make up".....
    You don't need to figure the ramp up/down that way....
    Plus you will have a baseline as to cost of "water pumped" and a great record of "rainfall, humidity, temp, wind" and don't forget RECEIVED SUNLIGHT.... tongue.gif

    Bob N9LVU scool.gif
  • GenesisGenesis Posts: 42
    edited 2006-01-06 03:32
    A simple possibility for a rain sensor is to use a darlington transistor and two metal plates which are close-spaced and will be bridged by rain.· Make sure you use appropriate resistors to limit the bias and collector currents and also protect the Stamp in the event you accidentally try to drive the "input" pin in your code.

    I've used this with great success for a "wet" or "touch" sensor in the past; it works very well.

    The only potential "gotcha" with this arrangement is the possibility of "gunk" bridging the contacts.· To get around this you could use a pair of reed switches and a tipping-bucket range gauge, and look for the tips - if the switches are cycling, its raining.....

    As was mentioned you can also count the actual rain amount with the tipping bucket gauge, and then calculate how much irrigation you actually need.· This is even better!
  • BullwinkleBullwinkle Posts: 101
    edited 2006-01-06 06:06
    So many good ideas, so little time. I can't wait!

    "Received Sunlight" is not a problem - I live in inland Australia (Canberra). It's sunny (and hot) here most days when I'd want to be irrigating anyway.

    Depending on memory I may add a "fully auto" mode to my controller where it irrigates based on a table of values depending on the month. That way it will automatically ramp up as summer really bites hard in late January/early February, then easy down until it does not need to run at all between late autumn and early spring.

    Designing the user interface will be fun. I plan to use a 4x20 LCD screen and a few momentary contact switches on the front panel. Maybe an ethernet interface (wireless?) later on - the Rolls Royce edition. smile.gif
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-01-06 17:01
    Corrosion gunk can build up if DC currents flow across a wet metal grid. Pulse the grid briefly and infrequently (from one Stamp pin as an output while another Stamp pin is an input). Or, better yet, use AC excitation of the grid. Here are a couple of links:
    [noparse][[/noparse]urlhttp://www.emesys.com/OL2mhos.htm
    www.emesys.com/lwet_dat.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2006-01-10 03:04
    Just to take a different tack, you could use a small container sitting on a mirco switch. Vessel collects water, then toggles switch.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-10 13:36
    Bullwinkle said...
    Thanks Robert!

    ·I love the seesaw rain gauge idea.
    I love shishi-odoshis, especially when they are tuned to musical notes and the water is timed so they make improvisational·music. (I know its not quite the same, but its the same principle)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
Sign In or Register to comment.