Guidance please: Zone watering with pumps and solenoid valves.

Hi,

I have made a zone watering which opens instructs 2 solenoid valves and a pump to open and close in sequence as follows:

  • first solenoid valve opens
  • pumps turns on
  • waits 10 seconds
  • second solenoid valve opens
  • wait 2 seconds
  • close first solenoid
  • wait 10 seconds
  • switch off pump
  • close second solenoid
  • wait 12.5 minutes

At the moment I am using a ready made 4 relay board with the following sketch:

// Declare Constants
#define RELAY_ON 0
#define RELAY_OFF 1

//Declare Variables
#define PUMP_1 10
#define RELAY_1 11
#define RELAY_2 12
//#define RELAY_3 13

//Setup to turn off all relays

void setup()
{
digitalWrite(RELAY_1, RELAY_OFF);
digitalWrite(RELAY_2, RELAY_OFF);
//digitalWrite(RELAY_3, RELAY_OFF);
digitalWrite(PUMP_1, RELAY_OFF);

pinMode(PUMP_1, OUTPUT);
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_2, OUTPUT);
//pinMode(RELAY_3, OUTPUT);
}

//Loop 

void loop()
{
digitalWrite(RELAY_1, RELAY_ON);
digitalWrite(PUMP_1, RELAY_ON);
delay(10000);
digitalWrite(RELAY_2, RELAY_ON);
delay(200);
digitalWrite(RELAY_1, RELAY_OFF);
delay(10000);
digitalWrite(PUMP_1, RELAY_OFF);
digitalWrite(RELAY_2, RELAY_OFF);
delay(750000);
}

I am powering the arduino nano using 12v at the Vin and GND - I know this produces too much heat and I want to be able to add a voltage regulator to give it the 5.5v feed it needs efficiently.

The pump is a 12v 5A diaphragm pump.
The solenoid valves are 12v 0.5A
The transformer is a 10A 12v transformer

The program currently cycles the solenoids with no problems when I run it without pumping water but under running conditions with the pump running, the arduino resets back to the beginning of the loop when the second solenoid is activated.

I am loving the arduino but am not an electrical engineer, but once I get the hang of it, I will virtually never leave my armchair!

My questions are:

  1. How do I simply regulate the power to feed the board from 12v to 5.5v without producing too much heat?

  2. Is the board stalling because the power supply is being swamped because the pump and solenoid are drawing too much power or could it just be because it is over heating with 12v at the Vin pin?

  3. I really want to expand this idea so I want to go over to using transistors to switch the pumps and solenoid valves in my next project, so how do I choose the correct transistor or mosfet as a switch that will switch the gates directly off the output pins of the arduino?

  4. Is there a way to make the code smarter so that I can just add a digit to a loop to declare how many relays there are that can also vary the spray time of every zone?

  5. What is the best way to solder wires directly onto an arduino board? I can get them on but the joint often fails.

I hope this makes sense and any help would be really appreciated.

All the very best,

Jason

A lot of questions ! will try and answer some.

  1. You say the Nanos regulator is running hot, find that a bit surprising if you are just running the nano from that 12v. Do you have any other direct 5v load on the Nano such as leds etc.
    Have you measured the current on the 12v line to the Nano, in case something else is shorting etc ?

  2. The Nano could be "swamped" if the pumps etc are draining too much power from the transformer, normally a 220 or 470 or 1000UF across the 12v close to the Nanos Vin should help that.
    However I would also suspect the pump/solenoids/relays are creating a lot of both switch on and switch off 'noise' which will easily reset the micro.
    Any long , loose wires will amplify this problem, particularly if you have input switches with long wires.

  3. Moving to Mosfets along with flyback diodes and capacitors on your pump should make a big improvement over the mechanical relays.
    Use the Logic Level type of Mosfets, like the IRL and similar types, not the IRF ones you often see diagrams for.

  4. Have not looked at your code in detail, but there is often ways to improve any design.

  5. Sounds like you are not running your soldering iron hot enough or with enough flux to make a decent joint. I always suggest the three second rule, as you solder, count 1, 2, 3, if the joint is not made by then, then stop and let the area cool, rather than risk damaging the tracks or components.

Like the Arduino code, soldering is one of those things that just needs practice.

What type of iron are you using ?

Edit 4 - looking at your code, at the moment its just a simple sequence of on and offs.
As your project develops you will find that very restricting; plus you will surely be wanting to do the watering with reference to a Real Time Clock ( aka DS1307 or DS3231 modules) and perhaps some level / moisture sensors ?

Adding a variable timing to each action is easily done, either by preset variables or , for example, 10k pots on your input pins.

Like you opening timig sequence, write out what you would like it to do , then you can consider what extra hardware and code is needed; one step at a time though !

Hi Ricky,

Thank you for your reply, I really appreciate your help.

  1. You say the Nanos regulator is running hot, find that a bit surprising if you are just running the nano from that 12v. Do you have any other direct 5v load on the Nano such as leds etc.
    Have you measured the current on the 12v line to the Nano, in case something else is shorting etc ?

The transformer has two COM outputs and two +v. I have the nano on one set and the solenoids and pump running from the other. There are no other LEDs or peripherals running. I haven't checked the current running through the arduino but it is just connected straight to the power so not too much chance of shorting?

  1. The Nano could be "swamped" if the pumps etc are draining too much power from the transformer, normally a 220 or 470 or 1000UF across the 12v close to the Nanos Vin should help that.
    However I would also suspect the pump/solenoids/relays are creating a lot of both switch on and switch off 'noise' which will easily reset the micro.
    Any long , loose wires will amplify this problem, particularly if you have input switches with long wires.

The nano is connected to a 4 relay board like this one . The relays are in the project box with the arduino and there is a 2m run from the relays to the solenoids. Would that create enough noise in the box? I like the capacitor idea though, I will add a capacitor and try that though. I will let you know how it goes. I have never used a capacitor, do they just go inline on the +ve side?

  1. Moving to Mosfets along with flyback diodes and capacitors on your pump should make a big improvement over the mechanical relays.
    Use the Logic Level type of Mosfets, like the IRL and similar types, not the IRF ones you often see diagrams for.

That sounds great and more like what I wanted to do, can you give me a little more detail on that or refer me to something that will teach me please? I was just looking at some RFP12N10L mosfets for the pump and perhaps a BSP316 for the solenoids. Does that sound about right? Shall I just look up flyback diodes and capacitors and how they work with pumps?

  1. Have not looked at your code in detail, but there is often ways to improve any design.

I got really excited about for loops but perhaps I should get this running first!

  1. Sounds like you are not running your soldering iron hot enough or with enough flux to make a decent joint. I always suggest the three second rule, as you solder, count 1, 2, 3, if the joint is not made by then, then stop and let the area cool, rather than risk damaging the tracks or components.

Thank you fro that advice, I am using a 30w soldering iron but I have just opened some mail and my 60w one has just arrived! That might be better (or too hot and worse!)

Edit 4 - looking at your code, at the moment its just a simple sequence of on and offs.
As your project develops you will find that very restricting; plus you will surely be wanting to do the watering with reference to a Real Time Clock ( aka DS1307 or DS3231 modules) and perhaps some level / moisture sensors ?

Adding a variable timing to each action is easily done, either by preset variables or , for example, 10k pots on your input pins.

Like you opening timig sequence, write out what you would like it to do , then you can consider what extra hardware and code is needed; one step at a time though !

That sounds really intriguing, I can see I am going to have another late night figuring out just how far I can go! I am always rubbish at one step at a time when I get over excited!

First WELCOME !!!

and a hearty THANKS for actually doing some work and them coming to make it better !

Please take a minute and read the forum rules.
It is at the top of every forum, called how to use this forum.

Items 6 and 7 apply. you can edit your first post, the edit / modify button is at the bottom right of your post.

Thanks Dave, I have modded accordingly! :slight_smile:

Hi,

Just tested out a nano on a 12v supply and with the relay board and 4 relays activating, yes it gets too hot.

This is where you need the Mosfet outputs instead; circuit attached.
It will suit most N channel mosfets, when Rin = 220R and RGS = 10K.
The Flyback diode, say a 1n4001-6, should be used on the solendoids and pump.
A small capactitor around 100pf over the motor terminals may also help.

Any long DC power cable pairs then twist them together.

While that Mosfet you list is a proper logic level type with correct voltage and current, the other key parameter is the RGS ON value, ie, its ON resistance.
The one you show has a quite high 200 milli ohm, so it will get warm when passing more than 1A, so look for something like this for example FDP 7030 with a much lower On resistance of below 20 m ohms

The BSP mosfet is P channel, stick with the Ns and use the same type for all outputs.

Your 60w soldering iron, a 'firestick' or a solder station ?

Regarding the Delays, when everything stops while the delay is counted down, what you need to look at is using the Millis. if you see this tutorial is explains everything.
While thats good for short timings, if you want to control your watering at specific times or periods during the day , then thats when you need to add one of those RTC modules , but do the Millis first as thats a key principle of basic coding.

000543.jpg

Hi,
What relays are you using?? What powers them? Is this a relay board you bought, or separate relays...?

ricky101:
Hi,

Just tested out a nano on a 12v supply and with the relay board and 4 relays activating, yes it gets too hot.
Is there a simple way of reducing that voltage down using some components rather than a buck converter? Or is that heat just due to the load of switching the relays?

This is where you need the Mosfet outputs instead; circuit attached.
It will suit most N channel mosfets, when Rin = 220R and RGS = 10K.
The Flyback diode, say a 1n4001-6, should be used on the solendoids and pump.
A small capactitor around 100pf over the motor terminals may also help.

Excellent, I have just watched some lectures on YouTube and I now know what a flyback diode does

Any long DC power cable pairs then twist them together.
Really? That simple? Ok I will do that too.

While that Mosfet you list is a proper logic level type with correct voltage and current, the other key parameter is the RGS ON value, ie, its ON resistance.
The one you show has a quite high 200 milli ohm, so it will get warm when passing more than 1A, so look for something like this for example FDP 7030 with a much lower On resistance of below 20 m ohms

The BSP mosfet is P channel, stick with the Ns and use the same type for all outputs.

That is all really useful information, Thank you!

Your 60w soldering iron, a 'firestick' or a solder station ?

Not yet graduated to a solder station, still burning myself with a firestick

Regarding the Delays, when everything stops while the delay is counted down, what you need to look at is using the Millis. if you see this tutorial is explains everything.
While thats good for short timings, if you want to control your watering at specific times or periods during the day , then thats when you need to add one of those RTC modules , but do the Millis first as thats a key principle of basic coding.
https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

Thank you, I was looking at millis the other day and I think I came to the same conclusion as I want to add other functions to the sprayers that might happen in the time off.

If I were to want it to go to a different routine at night could I have a small light sensitive resistor checked in an if statement between cycles?

terryking228:
Hi,
What relays are you using?? What powers them? Is this a relay board you bought, or separate relays...?

Hi Terry,

One of these: 5V 4-Channel Relay Board Module for Arduino Raspberry Pi ARM AVR DSP PIC | eBay

Bad choise.
If you had bought a 12volt relay board, you could have powered the board and the Nano from 12volt.
Now you have to add a separate 5volt supply for the relay board.
5.5volt, as you mentioned in post#0 is too low for the Nano's onboard regulator to work.
A solution could be a small 5volt buck converter to supply the relay board and the Nano (5volt pin).
And as explained, logic mosfets could be a better solution.
Leo..

... here's a good way to power and configure it

Thanks guys, I am taking this all on board and will be re-making the unit with logic level mosfets.

Any words of advice before I commit to making some more schoolboy errors? :slight_smile:

You have not made errors as such, just part of the learning curve for us mere morals. :wink:

As you develop your code, you can alway post it here for critique by the more advanced members who will surely give you good guidance.

My only thoughts would be regarding your soldering problems.
Practice makes perfect, so do try thing out on some old board / pins /wires to perfect your technique.

Regarding the soldering irons, today you see a lot of high powered mains irons, like the adjustable one below, which I expect is what you have got ?

I used to used Antex fixed mains irons for many years, a 15w one for fine pcb /micro work and a 25w one for heavier joints like relays.

I've only tried one of those modern firesticks and found they do not regulate the temparature very well, so it can be way to easy over heat the joint/track/component.

While you will find masses of debate about solder stations, and the hundreds of dollars/pounds you can spend on them, for a beginner I do not think you can beat one of these little '936' colnes, typically around GBP £20 - £25; use one myself and its way, way, better than any firestick.

000544.jpg

000545.jpg

Wise to post a (hand-drawn) circuit diagram before you build anything.
Leo..

jasonhr:
Thanks guys, I am taking this all on board and will be re-making the unit with logic level mosfets.

Any words of advice before I commit to making some more schoolboy errors? :slight_smile:

if you chose to use Fritzrig, find the screen view of the schematic, not the picture view of the board.

this is last place we want to you wind up.

https://forum.arduino.cc/index.php?topic=382458.0