Pages: [1] 2   Go Down
Author Topic: Please help me with my first project.  (Read 1433 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.










Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:


// 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);


  }
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:


// 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:

Code:
// 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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  http://arduino.cc/playground/uploads/Main/relays.pdf

Lefty


So, how do you operate higher voltage devices with the arduino?
« Last Edit: February 07, 2012, 08:52:13 pm by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 07, 2012, 09:09:59 pm by retrolefty » Logged

Berks, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 153
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Texy
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ahhhgh!!  smiley-mad....

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.
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Logged

Pages: [1] 2   Go Up
Jump to: