Potted plant watering system. (Involves water pumps.)

But it still has me perplexed why different LEDs are glowing at different brightnesses in "the other sketch" where I have the pin modes defined.

The operation LEDs generally is generally straight foward. The apparent brightness of an LED can be changed by varying the level of voltage applied, or pulsing the LED on/off faster than the eye can detect, making it seem dimmer. Check to see if the LED is being subjected to some type of fast on/off action in your code (most likely in a loop).

Zoomkat,

Thanks. I realise what the problem was. I fixed it and have actually removed that post.

But I am sitting here looking at the 5 LEDs blink quite happily with a simple sketch.

The output pins are declared (I won't say defined in case it is the wrong word) and written to.
Then the HIGH, LOW cycle is done. All LED's glow/work as expected.

In my "real" sketch, it is pretty well the same code but LED 5 doesn't want to play the game.

Sure it is a programming issue - it has to be as with another program the LED works.

But I can sit here "until the cows come home" and I am not seeing the problem.

I have cut/pasted lines in case there is a mistake in it which I can't see and change the pin number. Same result.

I honestly don't see what is stopping LED 5 glowing in one sketch but it does in the other.
Yes, there are differences - they are different sketches - but I have cut/pasted/remarked things out to try and see where/what is causing the problem to no avail.

I can read command structure (again) until the cows come home. Something isn't "jelling" and so I am missing it.

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.

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
digitalWrite(SecondLED,HIGH);
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?

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.

#define LED 8

void setup()
{
    int i;
    for (i=0;i<5;i++)
    {
        pinMode(LED+i,OUTPUT);
        digitalWrite(LED+i,LOW);
    }
    pinMode(1,OUTPUT);
    digitalWrite(1,LOW);
}
void loop()
{
    while(1)
    {
        int i;
        //digitalWrite(1,HIGH);            //  With this line active, LED 5 doesn't glow.
        for (i=0;i<5;i++)
        {
            digitalWrite(LED+i,HIGH);
            delay(500);
            digitalWrite(LED+i+1,HIGH);
            digitalWrite(LED+i,LOW);
            delay(500);
        }
    }
}

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.

You're connecting LEDs to the serial pins?

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.

I'd like to take a crack.

void loop()
{
        int i;
        //digitalWrite(1,HIGH);            //  With this line active, LED 5 doesn't glow.
        for (i=0;i<5;i++)
        {
            digitalWrite(LED+i,HIGH);
            delay(500);
            digitalWrite(LED+i,LOW);
            delay(500);
        }
        //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
}

Notes:

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

void loop()
{
    while(1)
    {

Why are you putting an infinite loop inside an infinite loop?

Paul,

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.

Techylab,
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.
Explaination:
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.

http://www.ebay.com/itm/Moisture-Sensor-For-Arduino-urban-garden-tool-Arduino-Compatible-/150845999918?pt=LH_DefaultDomain_0&hash=item231f1f4b2e

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:
http://makeprojects.com/Project/Garduino-Geek-Gardening/62/1#.UEogRqNvB8E

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

G'day.

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.

P.S.
That link doesn't work.

lost_and_confused:
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.

lost_and_confused:
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.

I don't see any requirement for a RTC here. All you need to do is water the plants every few hours - whether that is once in 24 hours, or once an hour, or whatever. The plants couldn't care less what time it is when they're watered.

For my system I am using a "Javtop JT-180 Solar/DC Water Pump" made in China and bought from an eBay retailer in HK for a couple of quid each including postage. It's tiny, draws almost no current, and works on anything from 3V to about 12V.

I suggest it's worth using a moisture sensor per plant, because the water requirements vary a lot with temperature/wind/humidity. Mine seems to work OK just measuring resistance between a couple of stainless cooking skewers pushed into the soil, although it took quite a lot of experimenting to find how to get a sensible reading from this design. I'm not sure the 'out of water' LED adds any value compared to just looking at the reservoir, but I am using an RF24 module to send the moisture and water delivery stats to a PC so I can generate an alarm if anything goes out of range - whether it's worth the hassle is for you to decide.

"That link doesn't work"
Here is the image with the important part.
Note: I said to use a 1 Megohm resistor. It's not critical, especially if using it as a switch.
10k would probably be more reliable, though less sensitive.

abXXxtQlDAakLi2x.medium.jpg

Well here are some pictures for those who may be interested.

It still isn't complete, but it is getting there.

But biggest problem right now is the power cables, de-coupling and the box into which it all goes.