Introduction: Smart Solar Panel With Arduino
I have always been interested in measuring the exact angles for ideal solar energy collection. I was looking for a way to measure and record these ideal angles, and finally decided it would be fun to just build my own. Here I'll share with you how I did it.
What you'll need:
- 1 Solar Panel (6V, 1.5W)
- 1 Arduino Uno (w/power cable)
- 1 Standard Servo
- 1 Micro Servo
- 1 Breadboard
- 4 AA batteries and battery container
- Several Jumper Wires
- 2 330KOhm resistor
- Scrap Wood. You won't need much, I used a couple strips from an old broken bed frame and some shelves from a destroyed bookshelf.
Step 1: Step 1: Building the Frame
There are three main parts of the frame.
1. Base: The base simply needs to secure the standard servo in an upright position. In my case, I used an old bookshelf, then attached two thin wooden strips to the bookshelf at the exact width as my standard size servo. I then screwed that servo into the two thin strips.
2. Rotating Platform: The rotating platform is basically a flat piece of wood with two upright beams screwed into the sides. One beam will eventually house the microservo, the other is simply there as a weight bearing beam that ensures the arm won't fall over. The bottom of this platform will eventually connect to the top of the standard servo, so the standard servo's gear should be screwed into the bottom of this platform.
3. Arm: The arm is shown in the last picture. It's purpose is to hold the the solar panel up and allow the microservo to adjust its tilt without falling over. to do this, put two strips of wood into a T-shape. Attach the solar panel to the top of the T (I did this with cardboard strips and strong adhesive). Lastly, attach the microservo's gear to the side of the arm.
Important notes: the most difficult part of building this design for me was getting the arm and the platform to connect properly. Here are some things to keep in mind before you start cutting out your pieces.
a. The lower the height of your pillars are, the more stable your design will be. In my case, I cut the length of the arm to be the length of the microservo's gear, and the beams to be an inch taller than that.
b. The beams have to be a bit taller than the arm itself. Otherwise the arm will graze the bottom of the platform when it moves across its full range of motion.
c. The distance between the two beams should give just enough space for the arm to stand up, without allowing the arm to sag. The easiest way ensure is to build the beam with the micro servo first, then measure and build the arm, then measure how long the arm stretches across and build your weight bearing beam accordingly.
Step 2: Step 2: Putting the Frame Together
Assuming the components are build correctly putting the frame together should be easy
The three parts are connected via the two servos. The rotating platform should be set on top of the standard servo. This connects the base to the rotating platform. The arm is then connected to the microservo (again, make sure there is enough room between the two beams while still ensuring the arm is properly held up by the weight bearing beam.
Don't feel bad if the parts don't fit together perfectly the first time around. Even with all my measurements t took me several tries to get it right.
Step 3: Step 3: Electronics Configuration
This project is really broken up into two circuits, the servo circuit and the voltage divider circuit.
The first circuit is composed of the two servos and is connected to the 4 AA battery pack. The positive leads from both servos are connected to the positive lead of the battery holder, and the negative leads from both servos are connected to the negative lead of the battery holder. Don't forget to connect the negative side of the circuit to ground as well. All that is left to do now is connect the signal leads (or input leads) from both servos to a digital input pin on the Arduino board (I used 9 and 10).
Some of you may be wondering why the batteries are needed when the Arduino board can supply its own power, and the answer is that power isn't enough to run both servos. Trust me, if you try running this from the Arduino board the motors are just going to move sporadically and the computer is going to beep at you a lot.
Which leaves us with the voltage divider circuit, which is where the energy gathered from the panel will be measured. On the other side of the breadboard, connect the positive and negative leads to a middle wire using two resistors of equal value (I used 330KOhms). Then connect that middle wire to one of the analog input pins (I used A0). Lastly, don't forget to connect to ground!
So why use the resistors? The Arduino can only measure up to 5V of input, but solar panel used can generate 6V. Because of this, we run the solar panels output current through what is known as a voltage divider. I won't go into specifics here but simply put because the resistors on both ends of the output wire are of the same value, the voltage drop across them is the same, and the voltage measured by the middle wire will be half of the overall voltage generated by the solar panel. This allows us to accurately measure how much voltage is being produced (just multiply by 2!) without going over the Arduino's 5V max.
Step 4: Step 4: Software
I have attached the code I used to measure the voltage and control the servos. The comments explain the functions and how they work so I won't go in depth about that here.
When the code functions properly it will move through its full range of motion, find the ideal position for collecting solar energy, and move to that position. This process will repeat every 10 seconds. Simply altering some of the functions should make it easy to get the machine to run however you want it to.