Please help me with my first project.

Hi guys,

I am very new to arduino and electronics in general. I am starting out and really enjoying it.
I want, for my very first project, to accomlpish the task of watering my lawn.
I attached a drawing (hope I attached it right), and it is a basic Idea of what I would like to accomplish.

I am looking for any helpful info on this project, and would be very grateful.
you prob. saw a few of my other posts on this topic and allot of cool people have helped me out.
I just wanted to re-post it in one central location.

I have been experimenting with so many different sensor designs and I am going to go with the gypsm block sensor for now.
I realize the limitations of these sensors and if all goes well I will probably replace them with the vegetronix ones eventually.

so, I have wasted a week or 2 trying to figure out and build different sensors.
Understanding that they are not the best choice, I am going to go with the gypsm blocks anyway.
mainly because they are the only one that I am recieving a reading high enough to set on/off limits to send a signal
to the valve. and the vegetronix are like $40 a pop.

the point I am at now is trying to figure out how to hook up 2 sensors to the arduino and get a serial read on them,
so that I can compare the 2 readings.

the 2 sensors are right now in my basement in a container of soil.
but I can only hook up 1 at a time.

any help?

this is the code I have so far:

// AVERAGING SENSOR READINGS


int sensePin =0;
int averageReading = 0;

void setup() {
 analogReference (DEFAULT); 
  
 Serial.begin (9600);
 
}
 const int numReads = 15;

void loop()
{
   int averageReading = 0;
   for(int i=0; i<numReads; i++)
   {
      averageReading += analogRead(sensePin);
      delay(500);
   }
   averageReading /= numReads;

  Serial.println (averageReading);


  }

openbahr:
so, I have wasted a week or 2 trying to figure out and build different sensors.
Understanding that they are not the best choice, I am going to go with the gypsm blocks anyway.
mainly because they are the only one that I am recieving a reading high enough to set on/off limits to send a signal
to the valve. and the vegetronix are like $40 a pop.

the point I am at now is trying to figure out how to hook up 2 sensors to the arduino and get a serial read on them,
so that I can compare the 2 readings.

the 2 sensors are right now in my basement in a container of soil.
but I can only hook up 1 at a time.

any help?

this is the code I have so far:

// AVERAGING SENSOR READINGS

int sensePin =0;
int averageReading = 0;

void setup() {
analogReference (DEFAULT);
 
Serial.begin (9600);

}
const int numReads = 15;

void loop()
{
   int averageReading = 0;
   for(int i=0; i<numReads; i++)
   {
      averageReading += analogRead(sensePin);
      delay(500);
   }
   averageReading /= numReads;

Serial.println (averageReading);

}

Well your half way there, to read two sensors you have to wire them to two different analog input pins:

// READING, AVERAGING, AND PRINTING TWO SENSOR READINGS


int sense1Pin =0;  // sensor number 1 wired to analog input pin 0
int sense2Pin =1;  // sensor number 2 wired to analog input pin 1

int averageReading1 = 0;
int averageReading2 = 0;

void setup() {
//  analogReference (DEFAULT); not needed as default is already the default
  
 Serial.begin (9600);
Serial.println ("Begin sampling sensors");
 
}
 const int numReads = 15;

void loop()
{

// read, average, and printout sensor #1 data
   int averageReading1 = 0;
   for(int i=0; i<numReads; i++)
   {
      averageReading1 += analogRead(sense1Pin);
      delay(500);
   }
   averageReading1 /= numReads;
  Serial.print ("Sensor #1 average = ");
  Serial.println (averageReading1);

// now do the same for sensor#2
int averageReading2 = 0;
   for(int i=0; i<numReads; i++)
   {
      averageReading2 += analogRead(sense2Pin);
      delay(500);
   }
   averageReading2 /= numReads;
  Serial.print ("Sensor #2 average = ");
  Serial.println (averageReading2);



  }

Compiled OK but no attempt at running it.

Good luck

it works great!!! thanks so much for your help!

openbahr:
it works great!!! thanks so much for your help!

Your welcome. The best part about how you are proceeding is that you are not trying to write the whole complete program at once. It's always best to write and test in phases of the application. Like here you are working at getting sensor data into the arduino, manipulate and analyze it. Once you have that all understood and tested you can proceed with building and testing the output controls to turn on and off the sprinklers. Then you can work on the control decision part of when to turn on and off which sprinklers, and lastly work on the user interface/display part if required or desired. Then a little glue code to tie them all together and you have your complete project done, and learned step by step as you proceeded in it's design and construction, with a minimum fustration as possible as these projects go.

All to often beginners jump right in and wire up a ton of stuff and write the complete sketch from hell and then really struggle with troubleshooting and trying to figure out what works and what doesn't work and why.

Lefty

This is pretty cool. I will keep posting here my progress/setbacks.
It will serve as motivation to me, and humor to you guys (seeing a newbie screwing up)

well I am gonna let both sensors run for a while as the one I had hooked up originally is reading 14 and the new one(it was in soil for a few days too, just not wired) is reading 46.

I think the elec. going through the sensor dries it out a bit as time goes on because the numbers are dropping on both and seem to have stabilized on 14 for sensor #1

So i guess now i need to start figuring out how to send a signal to and activate a sprinkler valve.
I believe they are 24volt. Sooooooo if the arduino puts out 5volts how do i operate these valves?

I have read some on this but i am not sure.

So, how do you operate higher voltage devices with the arduino?

openbahr:
So i guess now i need to start figuring out how to send a signal to and activate a sprinkler valve.
I believe they are 24volt. Sooooooo if the arduino puts out 5volts how do i operate these valves?

You drive either transistors or relays from the arduino output pins and they do the 24 volt switching of the valves. There should be many examples of switching circuits in the arduino playground section under outputs. First thing is you have to careful understand the ratings on the sprinkler valves (solenoid valves really), what is there voltage rating?, AC or DC?, and what amount of current do they draw with turned on? This current value is important for sizing the transistor switches and to determine how much current your external sprinkler power supply should be able to supply in total for all the sprinklers. Say if each sprinkler requires 100ma or current and you have 4 sprinklers, that is 400ma total if all are turned on at once, and you should probably size to power supply to 200% of that so maybe 1 amp capacity for the supply.

I have read some on this but i am not sure.

Keep reading. Here is an example of a arduino using a transistor to active a relay coil, you can just replace the relay coil (K1) with your sprinkler solenoid coil and it works the same. This assumes your sprinklers are DC operated, if AC operated you have to use an intermediate relay and use it's contacts to switch the AC current on and off to the sprinkler coil, or use a SSR (solid state relays) which is simpler to wire to a arduino but do cost a little more then relays in most cases. Arduino Playground - HomePage

Lefty

So, how do you operate higher voltage devices with the arduino?

Great info. Thanks so much again Lefty.

To step back for a moment, do you think that the length of the wires going to the sensors will be a problem?

openbahr:
Great info. Thanks so much again Lefty.

To step back for a moment, do you think that the length of the wires going to the sensors will be a problem?

Depends on the sensor electrical design, noise picked up on long wire runs could come across as noisy readings, however you are averaging 15 readings so that is acting like a low pass filter. I own an oscilloscope, so I would just hook it up at the arduino side and see how much noise was on the line. But most here don't have a scope so you just are going to have to look at the readings you get and see if they seem stable enough or not. Sometimes using shielded cable can help, grounding the shield to an arduino ground pin and left floating at the sensor end.

Now on the output wiring depending on the current draw for the sprinklers long runs can cause voltage drops but can be compensated for by using larger gauge wire size.

Of course the solenoid will not neccessarily be too far from the arduino, just because the sprinkler is.

Texy

That's true, I can keep the valves close to the house.

openbahr:
That's true, I can keep the valves close to the house.

With the trade off of possibly longer water piping runs. Usually wire is cheaper and easier to run then water lines.

Lefty

ahhhgh!! :0....

these sensors are killing me. I had them sit in the same soil overnight and all day and the readings are all whacky.
last night i had readings of 11 and 32, so, I was hoping that today after work I would hook them up again and have the same 32 point difference.
but... noooo... I am getting now readings of, 39, and 769!! what the heck?
I really gotta find a way to get a more reliable reading or I may have to scrap this part of the project.

I think I will let it sit and adjust for a couple of hours and maybe It will go back to the 32 point difference. I hope so.

@openbahr

I am curious...What type of sensors ? Did you have any datasheets ? Vendor ?

My instinst tell me, the outside ( wet, dust, humidity, rains, sun , etc ) may disturb sensor reading... And the long wire goinf toward the Arduino is not going to help... ( noise pick-up, rodents chew the cables , ect ).

My opinion.

I made the sensors using plaster of Paris.
They are inherently unreliable.

I am not having luck with these sensors that i am making.

i think i am gonna just bite the bullet and buy the vegetronix one

My question is... Which model do i buy?

There is a high, and a low frequency one.

I think the vg400 is the right one.

Almost $50 with shipping. Ugh!
Didnt order yet.

If I buy just 1 and put it in only 1 zone of my yard, can I (with code)

  1. have that zone turn on until saturated and then the sensor says turn off.
  2. use the length of time that that cycle took (will change day by day) and run zone 2 and then 3 for identical times in succession ??

Can this be done??..

Yes, if you can convince yourself that the multiple areas have similar enough characteristics (drainage, shade, slope etc). You could also put in some weighting to account for these differences, if you can decide on a weight.

Ok, after much thought, I think I am not going to use the moisture sensor afterall . Mostly because of cost but also because i have visions of a backyard party and sprinklers kicking on. Haha.

So I will prob try some variation of the open spRinkler project.

My ?? Now is... Does anyone know of a way that I can tap into a NOAA feed to tell my controller not to turn on if rain is in the forecast.

I think that there are products on the marketthat do this.

Thanks for any knowledge!