Fountain Project
I was wanting to created a fountain that has three separate pumps. Each pump would turn off and on for several seconds at a time, or even be randomized. I have been told that I might be able to create something using a Raspberry Pi. Unfortunately, I am completely unfamiliar with this product. Does anyone have suggestions. There is an aftermarket product that has three pumps and 12 different settings but it is over $750. All help would be greatly appreciated.
Comments
-
Well, you're going to need to learn some python to do this. If you're a newbie, my advice would be to find a similar project and use that as a basis for your own project, by modifying their code. You're basically going to be controlling a relay switch on a timer, via the GPIO. There's are a lot of guides online for this, controlling relays via the GPIO on Raspberry Pi. There's a guide here that covers more of the hardware side and working with relays: https://www.instructables.com/id/Controlling-Any-Device-Using-a-Raspberry-Pi-and-a-/
-
For something as simple as controlling a set of pumps an Arduino would be more than adequate and most likely end up being less expensive. You'll need a relay for each pump (Something like this 2 channel version would work well). Your code would be identical to the code for flashing an LED, but you would connect the pin on your Arduino to a relay instead of an LED. This tutorial from Arduino's website would be a great starting point. Regardless of what hardware you choose you'll want to avoid using a function that pauses your code (delay() on an Arduino or time.sleep() in Python) unless you're planning on turning the pumps on and off together.
-
Nick,
I appreciate your comment and followed your advice. Unfortunately, when I purchased my equipment they only had 2 two relay boards as opposed to a four relay board to go with my Arduino Leonardo. All was well in the initial phases of code writing until I tried to add the additional two relay board. The initial relay board is operating according to the corresponding code but the additional relay board appears to have a mind of its' own, or perhaps the devil in it. Below I have listed the code I developed based off of my VERY limited experience with this type of project. Any and all suggestions would be greatly appreciated as I am wondering around in the dark with little more than YouTube videos to guide me on this bizarre quest.
Code for "2" two relay boards with an Arduino Leonardo.void setup() {Serial.begin(3000);// setup Serial Monitor to display information;pinMode(2, OUTPUT);// connected to Relay 1pinMode(4, OUTPUT);// connected to Relay 2pinMode(7, OUTPUT);// connected to Relay 3pinMode(8, OUTPUT);// connecteed to relay 4}void loop() {digitalWrite(8,LOW); // turn relay 4 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);// turn relay 3 ONSerial.print("Pin 7 HIGH");digitalWrite(4,LOW); // turn relay 2 OFFSerial.print("Pin 4 LOW");digitalWrite(2,HIGH);// turn relay 1 ONSerial.println("Pin 5 HIGH");delay(3000);digitalWrite(7,LOW);// turn relay 3 OFFSerial.print("Pin 7 LOW");digitalWrite(8,HIGH);// turn relay 4 ONSerial.print("Pin 8 HIGH");digitalWrite(2,LOW);// turn relay 1 OFFSerial.print("Pin 5 LOW");digitalWrite(4,HIGH);// turn relay 2 ONSerial.println("Pin 4 HIGH");delay(3000);// keep in relay 1,3 OFF and relay 2,4 ON for 3 secondsdigitalWrite(8,LOW); // turn relay 4 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);//turn relay 3 ONSerial.print ("Pin 7 HIGH");delay (1000);digitalWrite(7,LOW);// turn relay 3 OFFSerial.print("Pin 7 LOW");digitalWrite(8,HIGH);// turn relay 4 ONSerial.print("Pin 8 HIGH");digitalWrite(4,HIGH);// turn relay 2 ONSerial.print("Pin 4 HIGH");digitalWrite(2,LOW);// turn relay 1 OFFSerial.println("Pin 5 LOW");delay(1000);// keep in relay 1,3 OFF and relay 2,4 ON for 3 secondsdigitalWrite(8,LOW); // turn relay 4 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);//turn relay 3 ONSerial.print ("Pin 7 HIGH");digitalWrite(4,HIGH);// turn relay 2 ONSerial.print("Pin 4 HIGH");digitalWrite(2,LOW);// turn relay 1 OFFSerial.print("Pin 5 LOW");delay (500);digitalWrite(7,LOW);// turn relay 1,3 OFFSerial.print("Pin 7 LOW");digitalWrite(8,HIGH);// turn relay 2,4 ONSerial.print(" Pin 8 HIGH");digitalWrite(2,LOW);// turn relay 1 OFFSerial.print("Pin 5 LOW");digitalWrite(4,HIGH);// turn relay 2 ONSerial.println ("Pin 4 HIGH");delay(500);// keep in relay 1,3 OFF and relay 2,4 ON for 3 seconds}
Code that worked great with only 1 two relay board, on 2 fountain pumpsvoid setup() {Serial.begin(3000);// setup Serial Monitor to display information;pinMode(7, OUTPUT);// connected to Relay 1pinMode(8, OUTPUT);// connecteed to relay 2}void loop() {digitalWrite(8,LOW); // turn relay 2 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);// turn relay 1 ONSerial.println("Pin 7 HIGH");delay(3000);digitalWrite(7,LOW);// turn relay 1 OFFdigitalWrite(8,HIGH);// turn relay 2 ONSerial.print("Pin 7 LOW");Serial.println(" Pin 8 HIGH");delay(3000);// keep in relay 1 OFF and relay 2 ON for 3 secondsdigitalWrite(8,LOW); // turn relay 2 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);//turn relay 1 ONSerial.println ("Pin 7 HIGH");delay (1000);digitalWrite(7,LOW);// turn relay 1 OFFdigitalWrite(8,HIGH);// turn relay 2 ONSerial.print("Pin 7 LOW");Serial.println(" Pin 8 HIGH");delay(1000);// keep in relay 1 OFF and relay 2 ON for 3 secondsdigitalWrite(8,LOW); // turn relay 2 offSerial.print("Pin 8 LOW");digitalWrite(7,HIGH);//turn relay 1 ONSerial.println ("Pin 7 HIGH");delay (500);digitalWrite(7,LOW);// turn relay 1 OFFdigitalWrite(8,HIGH);// turn relay 2 ONSerial.print("Pin 7 LOW");Serial.println(" Pin 8 HIGH");delay(500);// keep in relay 1 OFF and relay 2 ON for 3 seconds}
Again thank you in advance for your help and stay safe! -
I don't see anything in your code that should be causing an issue. Have you tried running code for 1 relay board with the second board? There should be 4 pins on the relay boards, 2 logic pins to control the relay and 2 for power (probably labeled VCC and GND). Do you have the power pins connected to the Arduino or to an external 5v PSU?
Also, some relay boards are active low, not active high. This means writing a pin low will energize the coil and switch the relay out of its normal position, and writing it high will deenergize the coil and leave it in its standard position. -
It's the darnedest thing. It works fine on the first two relay board, even if I switch it to the second board, it works, but when both boards are hooked up, which ever board is operating as the 3rd and 4th relay it doesn't mirror the code operating as the first relay board does. Once again any help would be greatly appreciated. Thanks and stay safe.
-
Also I do have the power pins connected to the Arduino board. Both are receiving 5 volts.
-
Try running this code and see what happens. Hopefully all 4 will turn on and off at the same time:
<div>void setup() { </div><div> pinMode(2, OUTPUT);// connected to Relay 1 </div><div> pinMode(4, OUTPUT);// connected to Relay 2 </div><div> pinMode(7, OUTPUT);// connected to Relay 3 </div><div> pinMode(8, OUTPUT);// connecteed to relay 4 </div><div>} void loop(){ digitalWrite(2, LOW); digitalWrite(4, LOW);</div><div> digitalWrite(7, LOW);</div><div> digitalWrite(8, LOW); delay(1000); digitalWrite(2, HIGH); digitalWrite(4, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); <span> delay(1000); </span> } </div>
-
I appreciate your response. I have worked out the code and found several sequences that work. But occasionally, it is sticking in an on position with one of the four pumps. It it does this at random. The code will operate flawlessly for quite some time then one of the pumps sticks in the on position. Other times it will only make through a half or quarter of the loop code and stick on in another pump. The code is correct. I am receiving a solid 5 volts to the Ardunio. Could this be because I am using alternating current? My relay boards can certainly handle the draw as they are 10 amp and each pump only draws .4 amps. Once again, any and all help would be greatly appreciated.
Stay safe,
Andy -
By the way. If I just have the Arduino and relay boards plugged in all relays switches turn on and off flawlessly for at least 30-40 minutes. The issues seem to only appear when the four pumps are plugged in to 110 ac after the Arduino and the relays.
-
It sounds like the issue is not isolated to a single relay, so it's unlikely to be defective hardware. If 3 of 4 relays worked fine I'd be tempted to say you have a bad relay, but it's unlikely all 4 are defective. Can you post a link to the exact boards you bought? I'm also assuming the rest of the Arduino continues running and the remaining relays continue to operate after a relay sticks. Is this correct?
Have you tied unplugging the pump when the relay sticks? If the relay doesn't click back when you do this the problem is probably caused by the contacts welding dues to the spark created at actuation. It sounds like you're well within spec on the relays, but it's possible there's some other variable with your load that is causing the contacts to weld shut. The easy fix for this would be to use solid state relays, but they're larger, more expensive, and run hot enough they generally need to be attached to a fairly large heat sink. If the relay does click open it's more likely caused by the load, and can most likely be fixed with a snubber across the contacts. -
Here is a link for the exact relay boards I have https://www.microcenter.com/product/486581/keyes-2-channel-5v-relay-module. When the system "sticks" all relays stop "clicking" if you will. If I unplug the Arduino and plug it back in it will operate normally for a while but sooner or later it returns to a "stuck" position on one of the 4 pumps, once again in no particular order, and all relays stop "clicking", which I'm sure also means functioning. As always, any help is greatly appreciated. My wife tells me this project has become an obsession!
Thanks,
Andy -
Okay. Most likely you're getting noise from the 120v circuit into the Arduino which is causing it to reset or lock up. This explains why all 4 relays stop working and why it only happens if the 120v is connected.
I believe those relays are optically isolated, meaning the relay is switched through an optoisolator rather than directly by the Arduino. Without going too in depth, the Arduino lights ups a small light in one of the ICs which illuminates a phototransistor (or other photosensitive device) which switches 5v through a transistor. This energizes the coil and switches the relay. Try disconnecting the ground between the Arduino and the relays. Assuming the relays are optically isolated they will still operate properly, and the Arduino will be fully isolated from the relay. Hopefully this will be enough to fix the issue.
If that doesn't work the next thing to try is an RC snubber across the relay. An RC snubber is a resistor and capacitor placed across the terminals of the relay to absorb the electrical noise that's causing issues. You can buy remade ones like these available on eBay, or buy appropriately rated resistors and capacitors and assemble the snubber yourself. -
Most importantly, I really appreciate your help. I tried the removal of the grounds from the Arduino to the relays and it did not work. I have an additional question regarding the RC snubbers, I have noticed that there are only two terminals to attach the 120v to. The relays have two 120v connections, I'm assuming an in and an out. Do I need these RC snubbers on both sides of each relay, since it is alternating current or will one per relay do the job. I just wanted to know before ordering because Micro Center does not have them in stock, nor does anyone around me, and I'm pretty sure I lack the skills to create one. Thank you again for all your help.
Stay safe,
Andy -
The snubber should be wired across the switch you're using to switch the load.
Ignoring the Arduino and relay coil, you basically have this. R2 is your pump, SW1 is the 120VAC side of the relay, and R1 and C1 are your snubber
In your case, this means you'll need to wire the snubber between the middle (common) terminal of the relay and whichever outer terminal you're using (presumable NO, which would be the left side if the terminals are facing towards you). -
generally if you also have a noisy power supply an easy solution is to start throwing ferrite beads at unshielded cables, not an elegant solution by any means but generally an easy quick fix in most cases
Categories
- All Categories
- 1 The Blog
- 1 What's Trending
- 7.4K The Community
- 3K General Discussion
- 102 New Members
- 789 Consumer Tech
- 197 Prebuilt PCs and Laptops
- 154 Software
- 30 Audio/Visual
- 50 Networking & Security
- 4 Home Automation
- 5 Digital Photography
- 12 Content Creators
- 28 Hobby Boards & Projects
- 75 3D Printing
- 83 Retro Arcade/Gaming
- 60 All Other Tech
- 287 PowerSpec
- 2.5K Store Information and Policy
- 140 Off Topic
- 40 Community Ideas & Feedback
- 596 Your Completed Builds
- 3.6K Build-Your-Own PC
- 2.6K Help Choosing Parts
- 303 Graphics Cards
- 324 CPUs, Memory, and Motherboards
- 134 Cases and Power Supplies
- 50 Air and Liquid Cooling
- 46 Monitors and Displays
- 88 Peripherals
- 57 All Other Parts
- 62 Featured Categories
We love seeing what our customers build
Submit photos and a description of your PC to our build showcase
Submit NowLooking for a little inspiration?
See other custom PC builds and get some ideas for what can be done
View Build ShowcaseSAME DAY CUSTOM BUILD SERVICE
If You Can Dream it, We Can Build it.
Services starting at $149.99