Go Down

Topic: Potted plant watering system. (Involves water pumps.) (Read 26676 times) previous topic - next topic


Well, I saw something.

When I am looking at the sensors, as I am "directly" looking at them by pin number, I realised I am using the "wrong" pins.
LED 5 is looking at Pin 13.  That's the onboard LED.

That isn't going to work.

Ok, so That is one problem detected.  I shall have to change the assigned pins to the analogue inputs.
Though that is going to be a problem as I need 6 inputs and two of the 6 analogue inputs are the I2C bus on which the RTC is going to live.

Hmmmmm...   But anyway.

That aside, I see I can't use the pins listed in the sketch.  BUT - and isn't there always one of them? - even if I negate the reading of the sensor pins for LED 5, it still doesn't glow.


Jul 22, 2012, 02:20 am Last Edit: Jul 22, 2012, 02:23 am by lost_and_confused Reason: 1
After even more head bashing this is what I have learned:

(It seems my posting the sketch is not appreciated, so I won't.)

I shall put the names of the functions in capitols only for effect.

I put a couple of lines in the SETUP() to turn the LED 5 on/off and it works.
That is on Pin 12.
SecondLED is pin 1 - just to let you know now.

Then it goes into the LOOP()
And from there straight into the SOLENOID() function.

On loading the LED 5 blinked.  So all was good.

I then copied the lines from the SETUP() to the SOLENOID() function, but put it after the LED_CONTROL(1) call.
This just turns on another LED indicating the loop is running.

Uploaded it and LED 5 blinked only once.  The "main" LED turned on indicating the loop was running and the other LEDs blinked as per normal, but 5 didn't.

For what ever reason, I copied the lines and put them BEFORE the LED_CONTROL(1) call and uploaded.

Lo and behold, LED 5 blinked TWICE when the sketch was loaded.

Then I copied them again and put them AFTER the LED_CONTROL(1) call.

LED 5 still only blinked twice, not three times.

The only "difference was the positioning of the lines before the LED_CONTROL(1) call.

So, I remarked out that line.

Now excluding the blinking at the start, LED 5 works as per the others.

So, to me:  LED_CONTROL(1) is causing the problem.
All that does is get the (1) which is sent, and depending if it is 1 or 0, turns the LED on or off.
So to "test" what is going on, I simply put
where the LED_CONTROL(1) call was.

LED 5 doesn't work.
How would doing a "digitalWrite(1,HIGH);" prevent a "digitalWrite(12,HIGH);" from working?


Jul 22, 2012, 02:47 am Last Edit: Jul 22, 2012, 02:49 am by lost_and_confused Reason: 1
The definitive bit of code:

This kind of proves my problem and the WHY is beyond me.

There are 6 LEDs in total.  1 - 5 for the loop and a "loop running" LED.

Code: [Select]

#define LED 8

void setup()
   int i;
   for (i=0;i<5;i++)
void loop()
       int i;
       //digitalWrite(1,HIGH);            //  With this line active, LED 5 doesn't glow.
       for (i=0;i<5;i++)

I don't know if I can put it any better than the above sketch.

Oh, and please don't pick the "there is not a # 5 LED defined in the loop".
There are 5 leds in the loop.  1 to 4 glow.  5 doesn't with the line un-commented.
But with the line commented out, # 5 does glow.



This kind of proves my problem and the WHY is beyond me.

After almost 80 post to help you solve your problem without success, it appears you have attempted something that is currently beyond your capabilities. I suggest you start out new with a simple part of your project and get it working, then attempt to move to the next part.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Jul 22, 2012, 06:27 am Last Edit: Jul 22, 2012, 05:46 pm by Techylah Reason: 1
I'd like to take a crack.
Code: [Select]

void loop()
       int i;
       //digitalWrite(1,HIGH);            //  With this line active, LED 5 doesn't glow.
       for (i=0;i<5;i++)
       //digitalWrite(1,LOW);            //  With this line active, LED 5 doesn't glow.
       delay(2000);                       //   Just a longer delay to simulate the long time between waterings.  For now

1.  You don't need the while(1) loop.  Your loop() already is the infinite loop.
2.  I think the LED+i+1  line was accidentally left in.
3.  LED 5 should get turned off after the watering sequence.  I put a 2 sec delay in so you could see what I think you mean,
that LED 5 indicates that a watering cycle is in progress.

Post if this doesn't do what you want.
Good luck.  Keep plugging.
By the way, I water my house plants with a 20 ft coiled thin hose connected with a valve under the sink.
I think gravity will not be forceful enough.  I give each houseplant 12 sec twice a week.
You can cannibalize a cheap battery operated faucet connected sprinkler timer to get the solenoid already connected to valve that can
switch water under presure.
(Ex.   http://www.amazon.com/Orbit-Hose-Watering-Timer-62024/dp/B0013I2MLS/ref=lh_ni_t  
If you need a bunch of them though, it starts to add up.  You don't really ruin it.  If you set it to On, remove the battery(s), and bring out two wires for power then when you provide power, via a digital out, you get a strong flow of water.  I have a similar one.  They're geared; the turn on/off is not instant but takes about a second.)


Code: [Select]
void loop()

Why are you putting an infinite loop inside an infinite loop?
The art of getting good answers lies in asking good questions.



That was a mistake on my part I admit.

Originally it was triggered by a pin going low and causing the LEDs to cycle once.

Just with me cutting it back, and back and back, I made a mistake.

Thanks very much.
You do seem to have the idea of what I am wanting to do.
Yes, you are correct, the +1 bit was an artifact from other trials.
I'll give it a go when I get home.
As a further note:  I have tried other pins for LED 5 and have the same result to a degree.
From what I remember (sorry if that sounds lame, so much has happened since then) if I use a different PIN for LED 5, different LEDs don't glow.
After several attempts, I just gave up on that and went on to the next "problem".


Probably late to the party here and somewhat irrelevant unless you can get the code working but I happened to run across this on ebay while I was looking for cheap arduinos.  Perhaps it could be useful to you.

Arduino Uno;


Dunno if I should put it here or ask in the "design" section but here goes:

Folks "I have a problem".

The analogue inputs.

2 are the I2C bus and so they will be used.

That leaves only ......  3?

I need 6.

One way or the other I will have to switch the remaining/some inputs between sensors.

I guess I could use 2.  1 for the "reserve level" from which the water is taken and one which is switched between the 5 different inputs.

That could work.  Note:  COULD.  As it is I have 5 big relays on the board to drive the solenoids.  Though they are 2 pole change over, the second one is being used to drive the pump's motor.

I'm thinking/guessing I could use something like 2 x 4016/4066 (yeah I know:  CMOS, but as an EXAMPLE) switches and switch the input as needed.

My question/concern is:   Is there a TTL equvilant?  Could I use the CMOS chips if there isn't one?
Anyone done anything like this before?

I know I would need "de-bounce" on the inputs, or a delay before I read them after they changed inputs.  But other than that.....???


Hi, Oz,
I'm sure you realize that analog inputs don't get de-bounced (that's why you used quotes and mentioned a delay).

What are you planning on using for the input sensors?
The "reserve" looks like it could be digital one, like a float switch in the reservoir.

For the diy moisture sensors, I'm thinking you'r looking at something like:

Instead of the 4016 or 4066 you could use a single MAX4617, which has 8 channels.
I think you should play with the sensor first, i.e. a pair of galvanized nails and a cheap voltmeter.
Perhaps a 1 Megohm (or more) resistor to ground on the "input" nail, the one not connected to the voltage source.
Then, when you're confident that a certain low enough voltage, as measured on the meter, corresponds with the dryness you want,
you can add one or two analog switches, and use a single Arduino analog input instead of the meter.

By the way, I think it's way cool, and considerate of the plants, to water each one when, and only when, IT needs water.
Most everybody makes do with a single time schedule for all the plants!
Good luck!.  Mitch



Yeah, the two nails are the way I am wanting to go.

Something along the lines of what you said.  Probably a transistor with bias and the nails only to detect water level placed on the side of the pot which is sitting in a saucer.

Thanks for the chip and that.  Shall look into it.

That link doesn't work.


Yeah, the two nails are the way I am wanting to go.

I'm using a couple of stainless steel cooking skewers about 15cm long as moisture sensors, just pushed into the soil. They're mounted in a chop block electrical connector to keep them parallel and this also gives a convenient way to attach the wires. I'm using the technique of only powering the sensor when I need to take a reading, and reversing the pulse after the measurement to avoid any ionization effects. It took me a while to figure out the resistance and timing to get a consistent reading that reflects water content within the range I'm measuring, but it seems to be working OK now.


Fair enough.

I am torn between moisture detecting and simply monitoring the water level in the saucer below the pot.

The basic idea is that "daily" at "time x" it will look at each (one at a time) level and water for n seconds or until the water level in the saucer is high enough to touch the nails.

Although the water level and moisture content are "just numbers" to compare to fixed ones, the level detection seems easier.

For now I don't have the sensors defined or anything - because I don't have the analogue input resolved - just the turn on, cycle and turn off part.

I don't even have the RTC yet.

Alas I am having a real drama getting the solenoids.

Oh and I need a separate sensor for the main reserve of water, so if it is empty, the pump and solenoids are not turned on.


As I've suggested in similar prior threads - consider raising the reservoir so that the water is gravity fed. Then you don't need a pump and there is no need to sense the water level unless you want an alarm when it's empty.

Go Up