Introduction: Smart Solar Panel With Arduino

Picture of Smart Solar Panel With Arduino

A couple of months ago I got really interested in solar energy. It is not the most efficient of the renewable energies but it makes its job by being accesible to most individuals around the world. It is cheap and easy to use you can also find it in a lot of different places. The project I am going to share with you is a smart solar panel that follows the sun. I inspired myself on a giant flower-like structure that opens itself when it detects sun, follows the sun during the day, and closes itself once it is dark. Mine might not be as pretty looking or have as many features and DOF (degrees of freedom) as that one but it is something. So what are we waiting for? lets get started.

Step 1: What You Need

Picture of What You Need

Tools:

  • Hot glue gun
  • Soldering iron
  • Wire strippers
  • Wire cutters
  • Small T-square
  • Marking utensil (I used a pencil)
  • Wood cutting tool (I used a bandsaw, but you can use anything. You just have to be able to make small precise angled cuts.)
  • Measuring tool (I used a standard measuring tape)

Materials:

  • x1) Arduino uno
  • x1) Hobby servo and servo horn
  • x1) Mini solderless breadboard
  • x1) Small solar panel (I used a 4” by 3” form RadioShack)
  • x5) 10k resistors
  • x1) 9v battery and adapter
  • x1) Jumper wire set
  • x1) Heat shrink tubing or electrical tape
  • X1) 1/8 inch plywood
  • x5) Photoresistors (You can use any type you want but you have to make sure that the 5 are the same type because every type outputs has a slightly different value)

Step 2: Wiring Intro

Picture of Wiring Intro

The circuit is pretty straight forward. You just have to follow the drawing above and you will be fine. Still I will walk you through it step by step so that we are all in the same page here. I have a couple of pictures to help through the process although we wont be following this exactly as the picture tells us. If you are more of an old school type of person I have the schematic here also. I didn't invest much time in cleaning up the schematic so it is a bit messy but I hope it is understandable.

Step 3: Wiring Part 1

Picture of Wiring Part 1

I have divided this first step into 3 little steps so that it is easier to follow. Make sure to guide yourself from the picture above too.

  1. First what you have to do is to solder the red wire to one leg of the photocell It should be about 4 inches long. The photocell has no assigned polarity, that means that you can solder it to whatever leg you want. This will be the +5v wire
  2. Then you have to solder one of your 10k resistors to the other leg of the photocell. Again nor the photocell or the resistor have assigned polarity so you can solder it however you like.
  3. And last but not least solder the black wire to the other end of the 10k resistor. I should be also about 4 inches long. This will be the GND wire.

*Tip: to make soldering easier melt a bit of solder to both of the things you want to join together. Then put them together and melt the solder to create a good joint. Feel free to apply more solder if you think it is needed.

Step 4: Wiring Part 2

Picture of Wiring Part 2

This is just one simple step. Again make sure to guide yourself from the picture if you are stuck.

  1. Solder a white wire between the connection of the photocell and the 10k resistor. This will be the output wire.

Step 5: Wiring Part 3

Picture of Wiring Part 3

Now we will connect it to the Arduino. This is where things get a little hard but bare with me, I will divide it into steps to make it as easy to understand as posible.

General connections

  • Connect a jumper from 5v in the Arduino to the + rail on the breadboard
  • Connect a jumper from GND in the Arduino to the - rail on the breadboard

Connecting the servo

  • Connect a jumper from the + rail on the breadboard to the 5v input on the servo(red wire)
  • Connect a jumper from the - rail on the breadboard to the GND input on the servo (black or brown wire)
  • Connect a jumper from the DIGITAL pin 9 on the Arduino to the Signal input on the servo (white or orange wire)

Photocell 1

  • Connect the 5v wire from the photocell to the + rail on the breadboard
  • Connect the GND wire from the photocell to the - rail on the breadboard
  • Connect the Output wire (the 3rd wire we added) to Analog pin 1 in the Arduino

Photocell 2

  • Connect the 5v wire from the photocell to the + rail on the breadboard
  • Connect the GND wire from the photocell to the - rail on the breadboard
  • Connect the Output wire (the 3rd wire we added) to Analog pin 2 in the Arduino

Photocell 3

  • Connect the 5v wire from the photocell to the + rail on the breadboard
  • Connect the GND wire from the photocell to the - rail on the breadboard
  • Connect the Output wire (the 3rd wire we added) to Analog pin 3 in the Arduino

Photocell 4

  • Connect the 5v wire from the photocell to the + rail on the breadboard
  • Connect the GND wire from the photocell to the - rail on the breadboard
  • Connect the Output wire (the 3rd wire we added) to Analog pin 4 in the Arduino

Photocell 5

  • Connect the 5v wire from the photocell to the + rail on the breadboard
  • Connect the GND wire from the photocell to the - rail on the breadboard
  • Connect the Output wire (the 3rd wire we added) to Analog pin 5 in the Arduino

Step 6: Building the Enclosure

Picture of Building the Enclosure

This enclosure is made out of 12 different pieces of 1/8" plywood. Right now we are going to cut 5 of them to create the main frame of the structure. I will give you the measurements and then show you some pictures. That will be more than enough for you to follow this build. I made the base of 1/4 inch plywood but it can also be made out of 1/8 inch plywood if you don't have 1/4 inch.

The base:

5 3/4x3 1/2

*only one


Part #2 the front and the back:

3 1/8 x 2 1/2

*you have to make two of these


Part #3 the two sides:

5 3/4 x 2 1/2

*you have to make two of these


Step 7: Building the Enclosure Part 2

Picture of Building the Enclosure Part 2

Alright so now we are going to do the different angles. I am going to share with you how I did it in my bandsaw and then you can adapt it to your own saw of choice. I will break this into many mini steps so that it is easier to understand.

  1. Set your guide or fence 1 inch apart from the blade. (take in consideration that the saw takes away a little wood normally about 1/8 of an inch.)
  2. Set your table or your blade to a 20 degree angle.
  3. Get a piece of 1/8" wood and run it through. (You need 2 pieces that are 3 1/2" long so I recommend you making your cut 8" long for you to have some room for mistakes.)
  4. Make sure all the edges are straightMake a mark 3 1/2" down the length of the piece and cut it.
  5. Flip it around and do it once again to get 2 pieces that are exactly 3 1/2".
  6. Sand the edges a bit and you are done.
  7. Again set your guide or fence 1 inch apart from the blade.
  8. Set your table of blade to a 25 degree angle.
  9. Get a piece of 1/8" wood and run it through.(Again making sure that it will be enough to make two 3 1/2" pieces, if not don't worry just run another piece.)
  10. Make sure that the edges are straight, if not fix it.
  11. Make a mark 3 1/2" down the length of the piece and cut it.
  12. Flip it around and doit once again to get two pieces that are exactly 3 1/2".
  13. Sand them down to remove any rough edges.
  14. Set your fence or guide to exactly 1 inch apart from the blade.
  15. Get the pieces with the 25 degree angle and flip them around in a way that you 20 degree angle is looking up and is away from the blade. (You should have a straight edge in front of the blade)If you are lost make sure to guide yourself by my horrible drawing above.
  16. Then set your table or blade to a 45 degree angle.
  17. Run your piece through. (Make sure to do this with both of your pieces with the 25 degree angle.)
  18. Sand any remaining rough edges and your are done for this part.

Step 8: Building the Enclosure Part 3

Picture of Building the Enclosure Part 3

Alright so now we have to glue the different angles together. Again I will divide this into steps to make it more understandable.

  1. You have to glue the 20 degree angle to one of the edges of the main frame.
  2. You have to glue the other 20 degree angle to the other edge of the main box.
  3. Wait until it dries.
  4. You have to glue the 25 degree angle to the other side of the piece with the 20 degree angle. (for it to be well aligned you can use a T-square to check that the 45 degree angle on the other end of the piece is complete straight up.
  5. Do the same on the other side.
  6. Make sure to guide yourself from the picture above.

Step 9: Building the Enclosure Part 4

Picture of Building the Enclosure Part 4

Now we are going to do the upper walls.

For this I didn't do any measurements. I just laid the enclosure on a piece of plywood and traced down de edges. Then I cut it on the bandsaw. I then mixed some homemade wood filler that I made with wood glue and some sawdust and added it on all the edges to make a nice fit. I did the same for both sides and it turned out good.

*Tip: cut bigger than what you drew and then make small adjustments to make a good fit.

Step 10: Adding the Electronics Part 1

Picture of Adding the Electronics Part 1

For this part I just drilled some holes in every different angled piece, and then cut out a piece for the top. And drilled a hole on the center of it too. I cannot tell you exactly the measurement of the top because it will vary a little depending on how you placed your angles. but take a measuring tape and measure the whole between your 2 sides and then cut a piece of wood to cover it.

*tip: make sure to guide yourself from the pictures above.

Step 11: Adding the Electronics Part 2

Now we have to glue the photocells into the holes in the frame. You can use whatever glue you have in hand, just make sure it doesn't produce heat because I screwed up some photocells with some hot glue and had to go buy new one and repent this hole step.

*tip: as you are pasting your photocells lay the box flat on the angle you are glueing so that it is at the same angle as the piece of wood.

Step 12: Adding the Electronics Part 3

Now just make the same connections as we did on step 5. I used a smaller breadboard just so it was more organised inside of the box. But you can stay with the one we used before. Once you made all the connections connect a 9v battery with a dc plug and upload the program and then just for everything inside and close the top with some hot glue so that you can open it to change the battery latter. Now you have a perfectly functional robotic sunflower.

Step 13: The Code

This code is very simple. I have to say that I feel proud that it works because most of the time my code doesn't work that well. This code basically reads the input from the photocells finds which one has the higher value and that is how it decides to what angle to set the servo with the solar panel.

The code should be in a file make sure that you have the Arduino programming software downloaded. If not go to www.arduino.cc and download it, it is completely free.

Step 14: Closing

So now everything is running and it is up to you how you wan to use the solar panel. I am thinking of maybe doing a something to recharge the 9v battery so that it would run on it's own energy. Or using it to charge a battery during the day and then charing a pocket charger. I don't know what you could do with it but it has a world of different uses. Please let me know what you are doing with it on the comments, and give me some feedback for my next Instructable since this is my first one.

Comments

technomatic (author)2015-10-27

where do i get the servo motors?

plz provide links

MohanMaker (author)technomatic2016-12-24

You can get servo motors online at places like amazon.com, eBay.com and hobbyking.com and most other large online shopping sites. The servo motor you chose also depends on what your trying to move. If your moving a small solar panel you can use something like a 9 gram servo, but if you are moving a huge thing you might want a servo that weighs more/is more powerful (like a 55 gram servo). Here a a few options.

https://www.amazon.com/s/ref=nb_sb_noss_2?url=sear...

https://www.amazon.com/Qunqi-MG996R-Digital-Torque...

https://www.amazon.com/TowerPro-SG90-Micro-Servo-2...

http://www.ebay.com/itm/US-10pcs-9G-SG90-Mini-Micr...

https://hobbyking.com/en_us/power-hd-1900a-servo-1...

http://www.ebay.com/itm/201606181242?_trksid=p2057...

MohanMaker (author)2016-12-24

I found one error with your code as I built your sun tracker. You have if statements between line 31 and 56. You write your if statements like this: if(photocell1Reading > photocell2Reading, photocell3Reading, photocell4Reading, photocell5Reading) (See image of this below). This doesn't throw any errors but it doesn't work (at least for me). All it did was move the servo to one side and then stop doing anything even why I shined flashlights on the sensors. I did a little research and found you have to write it like this: if(photocell1Reading > photocell2Reading && photocell1Reading > photocell3Reading && photocell1Reading > photocell4Reading && photocell1Reading > photocell5Reading) (See image of this below) Thanks for this great intructable.

MohanMaker made it! (author)2016-12-24

This is a fabulous project. Nice job explaining everything in detail. Great job! It was a good challenge being one of my first Arduino projects. Keep on making great intructables like this. Here are some photos of the one I built.

brsguler (author)2016-01-14

Thank you to Nice and detailed expression of your project. i like your programing logic :)

gearup500 (author)2015-12-08

Nice!

seamster (author)2014-11-04

This looks very interesting!

About This Instructable

5,991views

40favorites

License:

More by diegoch2001:3D Printing Filament Spool HolderControll an LED With Your Muscles3D Printer Setup
Add instructable to: