YouTube player

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.

Project Steps

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.

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.

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.

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.

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.

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.

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.

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

}

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

}

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 you 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

}

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.