Introduction: Arduino Controlled Solar Fountain

Picture of Arduino Controlled Solar Fountain

A fountain can make a nice decorative fixture for your garden. But it isn't always easy to run a power cord out to where you want it. So I decided to run it on solar power. The system is controlled by an Arduino. This allows you to save energy by programming when the fountain will be turned on.

Step 1: Powering the Fountain

Picture of Powering the Fountain

A standard solar panel and battery provide the power for the fountain and the control circuit. Since most fountain pumps run on 120VAC, you will also need a small power inverter to run the pump.

Solar Panel:
The size of the solar panel determines how many hours a day the fountain can be on. If you want the fountain to be on all the time, then you will need a larger panel. If you only want it to run for a few hours each day, then you can get by with a much smaller panel.

Battery:
The battery needs to be a 12V rechargeable battery (preferably one that is designed for solar power applications). It should have a high enough capacity to be able to run the pump for a few hours on a single charge. 

Power Inverter:
The power inverter just needs to be strong enough to power the pump. A small 80 watt inverter should be more than sufficient to power most fountains.

Step 2: Relay Driver Circuit

Picture of Relay Driver Circuit

The control circuit in this project uses a relay to turn the fountain on and off. You could do this with a commercial relay shield. Or you can make your own relay driver.

To make a relay driver, the first thing that you need is a relay. I recommend using a 12V relay. This lets you power it directly from the battery. Then you need a power transistor to activate the relay. I chose a IRF510 MOSFET but other power transistors can also work.

Lastly, you need to add a diode in parallel with the relay's coil in order to protect the transistor from voltage spikes that can occur when the relay turns off. 

Wire up the relay driver circuit as shown in the diagram and you are ready to connect it to the Arduino.

Step 3: Connect the Relay Driver Circuit to the Arduino

Picture of Connect the Relay Driver Circuit to the Arduino

To power the Arduino, you need to connect the negative terminal of the battery to the GND pin on the Arduino and connect the positive terminal of the battery (or the +12V line from the relay driver circuit) to the Vin pin. The Vin pin has a built-in voltage regulator and most Arduino models can accept 7V-12V.

Lastly, you need to connect one of the digital pins (in this case pin 13) to the gate of the transistor. This will provide the signal that will turn the relay on and off.

Step 4: Connect the Solar Panel, Battery and Inverter to the Relay Circuit

Picture of Connect the Solar Panel, Battery and Inverter to the Relay Circuit

I decided that the most convenient way to connect the other components was to wire them all to the circuit board of the relay driver.

If your solar panel does not have a built-in blocking diode, then you need to add one before connecting it to the rest of the circuit. This prevents electricity from flowing back through the panel when it is dark and draining the battery. The negative terminals of each component can be wired together as a common ground. The positive terminals of the solar panel, the battery, the Arduino, and the relay driver can also be wired together. The positive line going to the inverter is connected to the output of the relay.


Step 5: Make a Housing for the Relay Driver and the Arduino

Picture of Make a Housing for the Relay Driver and the Arduino

To help keep things a little more organized, I made a simple housing for the relay driver and the Arduino. I cut slots in one side of the box for a pair of wires that connect to the battery. On another side I drilled two holes and added a pair of screws that I used to attach the clamps from the solar panel. On a third side, I made a 1 1/8" hole and added a 12V DC power outlet for the inverter.

Step 6: Put the Components Into a Weather Proof Enclosure

Picture of Put the Components Into a Weather Proof Enclosure

Since your electronics will be outside, you need to protect them from the weather. I just used a cheap plastic tub with a slot cut in the side for the power cords. It isn't completely air tight but it will keep the rain out. For a better seal, you can add weather stripping along all the edges.

Step 7: Basic Operation

Picture of Basic Operation

Electricity that is produced by the solar panel is stored in the battery. The battery then uses this stored electricity to power all the other components. When the Arduino sends a HIGH signal to the gate of the transistor, the relay is activated. This connects power to the inverter and turns it on. The inverter then takes the 12VDC from the battery and converts it into 120VAC which powers the fountain.


Step 8: Program the Arduino

Picture of Program the Arduino

Now you need to create a program to control the fountain. The first thing that you need to do is set one of the digital pins to output mode. Then you need to decide on which conditions should cause the fountain to turn on. For instance, maybe you want the fountain to turn on at certain times. Below is a simple example. This program turns the fountain on for one hour after being activated. The fountain will then continue to turn on every day at this time. You can also use environmental conditions such as light intensity to activate the fountain. However, this will require you to add some additional sensors. A few examples are given in the following steps.



int RelayPin = 13;                 // relay driver connected to digital pin 13

void setup()
{
  pinMode(RelayPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(RelayPin, HIGH);   // turns the fountain on
  delay(3600000);                     // waits for an hour
  digitalWrite(RelayPin, LOW);    // turns the fountain off
  delay(82800000);                        // waits for 23 hours
}


Step 9: Battery Voltage Sensor

Picture of Battery Voltage Sensor

Because the output of a solar panel is dependent on the weather, you can't always count on it to keep the battery fully charged. So it might be a good idea to have the Arduino monitor the battery's voltage. This would enable the system to turn itself off if the battery gets too low.

You can easily use the AnalogRead function to measure a voltage. Unfortunately, it can only measure voltages up to 5V. So you need to make a voltage divider to reduce the voltage to something that can be measured. To make one, you will need two resistors. One of them should be twice the value of the other. Connect one lead of the larger resistor to the 12V+ line from the battery. Connect the other lead of the larger resistor to one of analog pins in input mode. Also connect one of the leads of the smaller resistor to this same analog pin. Then connect the other lead of the smaller resistor to the negative terminal of the battery or the GND pin of the Arduino. Then you can use the AnalogRead function to measure a voltage as an integer between 0 and 1023. To convert this into volts you can use the formula: V=AnalogRead*0.0049*RLarger/RSmaller. Here is an example of how you could use this setup to monitor the battery's voltage and turn off the fountain when the battery gets low. The chosen resistors are 10K and 4.7K.


int RelayPin = 13;                 // relay driver connected to digital pin 13
int analogPin = 3;                 // Center of voltage divided connected to analog pin 3
int val = 0;                           // variable to store the value read

void setup()
{
  pinMode(RelayPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
val = analogRead(analogPin);    // read the input pin
if (val< 720)          //if the battery's voltage is less than 11
                          //with the chosen resistors of 10K and 4.7K, the voltage divider turns 11V into 3.5167V
                          //this is read by the analogRead function as 720
{
digitalWrite(RelayPin, LOW);    // turns the fountain off if the battery's voltage is below 11V
}

if (val> 785)          //if the battery's voltage is greater than 12
                          //with the chosen resistors of 10K and 4.7K, the voltage divider turns 12V into 3.8364V
                          //this is read by the analogRead function as 785
{
digitalWrite(RelayPin, HIGH);   // turns the fountain on if the battery's voltage is greater than 12V
}
delay(60000);                            // waits for one minute
}

Step 10: Light Sensor

Picture of Light Sensor

You can also use light levels as a condition for turning the fountain on and off. This is a simple example of how to use light sensors so that your fountain will only be on during the day.

To construct the sensor for this example you will need a CdS photoresistor and a 10K fixed resistor. Use them to assemble a voltage divider as in the previous step. The photoresistor should be connected to the positive voltage from the battery and the 10K resistor should be connected to ground. Because photoresistors come in a wide variety of resistances, you may need to change the value of the fixed resistor or the reference value used in the if statement of the code. Otherwise the code should be the same as in the previous step. If your weather proof enclosure from step 6 has clear sides, then you can mount the light sensor to the housing of the relay circuit from step 5. 

It is also possible to use a solar cell as the light sensor. To do this connect the negative terminal of the cell to the GND pin on the Arduino and connect the positive terminal to the analog input pin. 



int RelayPin = 13;                 // relay driver connected to digital pin 13
int analogPin = 3;                 // Center of voltage divided connected to analog pin 3
int val = 0;                           // variable to store the value read

void setup()
{
  pinMode(RelayPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
val = analogRead(analogPin);    // read the input pin
if (val> 720)     //if the light level are high
{
digitalWrite(RelayPin, HIGH);   // turns the fountain on if the sun is shining
}
else
{
digitalWrite(RelayPin, LOW);    // turns the fountain off if the sun is shining
}
delay(60000);                            // waits for one minute
}

Step 11: Finished Programmable Solar Fountain

Picture of Finished Programmable Solar Fountain

Following the previous examples you can add any number of sensors to your fountain. You can add a low water sensor, a rain sensor, or even a motion sensor. Then just program the Arduino to react accordingly. Use your imagination and have fun.

Comments

Raghdado (author)2017-07-17

Nice instructable ! Would you tell me please about the dimensions and the type of the solar panel ? and also the total cost ?
Thank you

Any type of solar panel will work. It just needs to be rated for 12 volts.

MinhN3 (author)2015-06-11

I see 5 components on the circuit board, the diode, resistor, transistor, relay, what is the 5th piece that is wedged in between the transistor and the relay?

That is the diode that is connected between the coil terminals of the relay. This protects all the other parts from voltage spikes when the relay turns off.

There is a second diode on the board. This is the solar panel blocking diode. This prevents the battery from draining back through the solar panel when the sun is not shining. This is not shown on the schematic because some solar panels have one built in.

jdarwish (author)2014-04-16

can this project used Arduino UNO? interested on doing this...

Yes. Any Arduino model will work.

NightLord (author)2013-08-23

Nice project, I am planning something simmilar in the future :)

There are some thoughts for improving your project:

-You could use low cost DC powered pump, to avoid DC-AC conversion losses. They may not seem important, but cheap inverters are not very efficient, and losses may be over 20% at low power usage (e.g. 10W pump for 80W inverter)

- Just like low voltage shutdown, you need at least high voltage shutdown for solar panel, to prevent battery from being overcharged. Since you're already using arduino, it would be realatively easy to add another relay, cutting power supply at around 14V and turning on again at, let's say 12,6V

- I would also suggest you to use higher voltage when you consider battery fully discharged, 11,5V for example, to give longer battery life time. But that's just my thought, I have never killed a battery yet :)

Don't take this critic too hard, I just want to share some of my knowledge, that I gained with my 160W 160Ah solar power arduino controlled system ;)

Idrispo (author)NightLord2014-03-30

hey, i would like to see you project.... i to want to have a solar power arduino control system.

arnab321 (author)2014-01-11

you could make the arduino sleep, insead of delay() to save power. Theres a library for that afaik

sspence (author)2013-08-28

Why an IRF and not an IRL? IIRC, the IRF likes to see about 10v turn on voltage (works less reliably on less, depending on load), where the IRL (5v) is better matched to an Arduino.

I used these parts mostly because it is what I had on hand.

longvu76 (author)2013-08-21

Very interesting project.

I have a fountain, a battery, and a DC converter like yours in the picture. I'm only missing the solar panel so I'm wondering what size and watt of your solar panel that you use?

Also, what do you use the the black housing box?

You can use any 12V solar panel. The only difference is how often you want the fountain to turn on. If you want the fountain to be be on all day then you need the panel that produces at least as many watts as the pump requires. Alternatively, you can have a much smaller panel that spends several hours charging the battery for every hour that the pump is on.This is one of the advantages of using the arduino to control when the pump turns on. For example, a 0.1W panel could run a 1.0W pump for an hour each day.

foobear (author)2013-08-22

wow, such clean and clear instructions with beautiful photos and everything labelled. a great instructable and a cool project!

sifuentesk (author)2013-08-20

Looking forward to trying this out. Fantastic!

About This Instructable

50,644views

342favorites

License:

Bio: My name is Jason Poel Smith I am a Community Manager here at Instructables. In my free time, I am an Inventor, Maker, Hacker, Tinker ... More »
More by DIY Hacks and How Tos:36 Things to Cook in a Coffee MakerHow to Make a Festivus PoleAdd Wings to an Infant's Halloween Costume
Add instructable to: