Sun-Tracking Solar Panel
My main project is the Sun-Tracking Solar Panel. It is essentially just a solar powered charger that follows the Sun’s movement across the sky. I started with a regular charger and then added the sun-tracking feature. Using python, I also made a feature which can graph voltages so I can see how much the sun-tracking feature actually helped.
(For all code and other resources see the bottom of the page)
Engineer
Srikar N
Area of Interest
no clue
School
Lynbrook Highschool
Grade
Freshman
Final Milestone
Reflection
Overall BlueStamp has really helped in exposing me to the world of engineering. In the past, just the thought of sitting at a desk typing up code was enough to bore me to death. But with this experience, I was able to try all of these things that I originally had no clue about. It completely opened up my view of the field and now I know that I have at least some interest in it. I really enjoyed the fact that everything was individual. It gave a lot of room for improvement in terms of an overall understanding of what’s happening and how to solve problems on your own. Even though it was individual, you could also ask for advice from peers or the staff which I think mirrors the real world really accurately. While I struggled a lot, I had a lot of fun getting know all sorts of new things and learning the process of persevering through something alone.
Printed Circuit Board
There honestly wasn’t much to the soldering. It’s basically just copying things from the breadboard to a PCB with the only difference being that you have to make the connections yourself. Usually, this means putting all of the wires right next to each other and connecting it with solder material. One thing I learned was that it’s really important to plan things out before you solder them. It’s a lot more painful to desolder. I made the mistake of switching up a few wires and I ended up spending a lot of time trying to fix things.
Graphing
The graphing took a lot of work but it was definitely worth it. I learned a lot about different coding languages. I started with a little Java but I heard that Python is usually better for graphing. For four full days, I got to know the basics of Python and made some basic sketches. But when I moved on to the actual graphing code, I had a lot of problems importing the modules I needed. I pivoted a lot from text editor to text editor and had no success. The issue ended up being that Plotly (the graphing module) wouldn’t work unless I connected it to my profile. Matplot was a lot simpler and as soon as I switched it worked. I had a framework that just required me to input whatever values I wanted to graph. As it turned out, the Arduino IDE had a built-in graphing feature which I could’ve used the whole time. It was overall easier to use and could even update live so I ended up using that.
- It should be noted that when graphing, you need to directly connect the solar panel to the voltage reading circuit. The lithium polymer charger regulates the output at around 3.75 volts so there will be no variance if connected through that. This can be done with a breakout board.
Demo Night Video
-still working on getting graphs
Third Milestone
Wood
For the wood, there really weren’t any technical problems. It’s a pretty straightforward process. It’s just a lot of cutting, gluing, and then waiting for everything to dry. That process, though simple, ended up being really tedious and long-winded. After spending multiple hours cutting the wood with a hand saw, my hands were completely raw and I was sore. In the future, I would be sure to get properly sized wood in order to minimize the amount of cutting needed. Something thin and not super bulky would probably be the best. One thing I learned that made the process go a lot smoother was that when sawing, it’s better to focus on speed and not strength. Otherwise, the saw gets stuck a lot.
(A good wood size is pictured above)
Putting Everything Together
The rest of the third milestone consists of connecting the solar panel to the servo and making a stable system to allow the panel to rotate. I did this with two steel rods. One went across the wooden structure and one went through the servo’s arm. Both of these ran through a piece of wood at the bottom of the solar panel which turned the panel. The hardest part of this process was calibrating the servo so it could supported the panel. It worked fine until the solar panel reached a certain point. At that point everything went slack and it stopped rotating. I tried changing the code so that it wouldn’t turn as much. It worked but it limited the rotation too much. After doing some research on leverages, I tried putting one of the holes farther out. This spread out the weight and balanced everything out.
Completion
My final milestone is just to transfer everything to a PCB. If it’s possible, I would also like to compare the amount of sunlight gathered with and without the sun tracking feature.
Second Milestone
The Circuit
The circuit uses a lot of new parts. At the center of everything were two photoresistors (LDRs). These are basically just regular resistors with the only difference being that the strength varies based on the light it senses. These are combined with regular resistors to make a voltage divider. Then I attached a servo to the circuit and coded it to rotate based on the strength of the LDRs. To tie everything together, I attached everything to an Arduino. I made a really dumb mistake while putting in the LDRs which was that I connected the two legs together on the breadboard. This is bad because it makes a loop where the + part of the circuit is connected to the – part. It took a while for me to find the mistake but once I did it was easy to fix.
The Code
For the code, I pulled something off the internet and started to edit it. It works by reading the different inputs from the LDRs and comparing them. If one LDR reads more light than the other, it changes the servos position until they’re balanced. If there isn’t enough light, it defaults to facing east. This is so it faces the sunrise during the night. In order to help debug, I added a sequence of Serial.prints that showed the value of each LDR and their difference. I used this to keep things balanced. At first, I had some problems positioning the servo, but with the serial monitor I noticed a common difference and added something to the code to even it out. I expect this value to change once I mount the servo on the wooden structure.
/* Sun Tracker Sketch This sketch is designed for use with a 9gram servo, should be powered with an external power supply such as 3 AA or 3AAA batteries. For the purpose of this project, I'm using a rechargeable 5v battery pack. */ #include <Servo.h> Servo servo; // Create a servo object to control the servo int eLDRPin = A0 ; // Assign pins to the LDR's int wLDRPin = A1; int eastLDR = 0; //Create variables to store to LDR reading int westLDR = 0; int difference = 0; //Create a variable to compare the two LDR's int error = 10; // Variable for if there is a noticable difference between the two LDR's int servoSet = 130; //Variable for position of servo - will be different for each device void setup() { servo.attach(9); //attaches the servo object to PWM pin 9 Serial.begin(9600); } void loop() { eastLDR = analogRead(eLDRPin); //Read the LDR values westLDR = analogRead(wLDRPin); if (eastLDR < 400 && westLDR < 400) { //Check to see if there is low light on both LDR's while (servoSet <=140 && servoSet >=30) { // if so, send panels back to east for the sunrise servoSet ++; servo.write(servoSet); delay(100); } } difference = eastLDR - westLDR ; //Check the difference if (difference > 20) { //Send the panel towards the LDR with a higher reading if (servoSet <= 140) { servoSet ++; servo.write(servoSet); } } else if (difference < -20) { if (servoSet >= 15) { servoSet – ; servo.write(servoSet); } } /*The Serial monitor section is for debugging purposes, or for general interest, one, once the device is functioning correctly, can be disabled. Use it to see if your LDRs are noticeably different when they have equal light shining on them.*/ Serial.print(eastLDR); Serial.print(" - "); Serial.print(westLDR); Serial.print(" - "); Serial.print(difference); Serial.print(" - "); Serial.print(servoSet); //Fine tune the servo settings, to maximise swing available Serial.print(" - "); Serial.println("."); delay(100); }
Toggle For Code
My third milestone is to build a wooden structure to use as a stand for the panel. It will also include finding a way to connect my circuits
First Milestone
The Circuit
To sum it up, the circuit was there to lower the output from 6v to 5v so an Arduino could read the voltage. One huge challenge in this was having to design one on my own. I essentially freestyled everything because I didn’t have a schematic I could reference. To get around this, I tried to mix and match a few smaller circuits I found on the internet. After doing some research and going through a few iterations, I settled on using a voltage divider. A voltage divider uses 2 resistors to divide the voltage proportionally to their strength. I used a 2k and 10k resistor to divide it by a factor of 1.2. I had a lot of issues trying to ground it properly but I eventually got it down.
The Code
The coding proved to be its own little problem. I found some things on the internet that I could use but I decided I wanted to try and make the code on my own. In order to learn the basic of the Arduino IDE, I decided to just jump right into some examples. Using these, I was able to dissect the different bits and pieces to learn what everything does. For my code specifically, I had to apply things like ints, floats, while loops, and other basic formulas. The code works by reading the values from the A2 pin. Then I take an average from a few of these samples to give a more even number. In order to compensate for the voltage divider, I multiplied the average by 1.2 to get the final voltage. Then using Serial.print, I recorded these values.
- For the actual charger, just connect the solar panel to the lithium polymer charger and connect that to a lipo battery. From there you can plug in your phone to the remaining port through an adapter.
What's Been Done:
Code:
const int num_samples=10; int sum = 0; // sum of samples taken unsigned char sample_count = 0; // current sample number float voltage = 0.0; // calculated voltage void setup() { Serial.begin(9600); } void loop() { while (sample_count < num_samples) {//adds 10 sample values sum += analogRead(A2); sample_count++; delay(50); } voltage = ((float)sum /(float)num_samples * 5.0) / 1024.0; /*averages values then puts in terms of volts*/ Serial.print (voltage*1.2);//displays initial voltage (before resisted) Serial.println (" Volts"); //writes volts sample_count=0; //resets values sum=0; }
hover for code
For my next milestone, I plan on adding a feature so that the solar panel can track the Sun’s movement.
Starter Project
Resources:
Sun tracking schematic
Voltage reader schematic
Sun tracking code
/* Sun Tracker Sketch This sketch is designed for use with a 9gram servo, should be powered with an external power supply such as 3 AA or 3AAA batteries. For the purpose of this project, I'm using a rechargeable 5v battery pack. */ #include <Servo.h> Servo servo; // Create a servo object to control the servo int eLDRPin = A0 ; // Assign pins to the LDR's int wLDRPin = A1; int eastLDR = 0; //Create variables to store to LDR reading int westLDR = 0; int difference = 0; //Create a variable to compare the two LDR's int error = 10; // Variable for if there is a noticable difference between the two LDR's int servoSet = 130; //Variable for position of servo - will be different for each device void setup() { servo.attach(9); //attaches the servo object to PWM pin 9 Serial.begin(9600); } void loop() { eastLDR = analogRead(eLDRPin); //Read the LDR values westLDR = analogRead(wLDRPin); if (eastLDR < 400 && westLDR < 400) { //Check to see if there is low light on both LDR's while (servoSet <=140 && servoSet >=30) { // if so, send panels back to east for the sunrise servoSet ++; servo.write(servoSet); delay(100); } } difference = eastLDR - westLDR ; //Check the difference if (difference > 20) { //Send the panel towards the LDR with a higher reading \ if (servoSet <= 140) { servoSet ++; servo.write(servoSet); } } else if (difference < -20) { if (servoSet >= 15) { servoSet – ; servo.write(servoSet); } } /*The Serial monitor section is for debugging purposes, or for general interest, one, once the device is functioning correctly, can be disabled. Use it to see if your LDRs are noticeably different when they have equal light shining on them.*/ Serial.print(eastLDR); Serial.print(" - "); Serial.print(westLDR); Serial.print(" - "); Serial.print(difference); Serial.print(" - "); \ Serial.print(servoSet); //Fine tune the servo settings, to maximise swing available Serial.print(" - "); Serial.println("."); delay(100); }
Voltage reader code
const int num_samples=10; int sum = 0; // sum of samples taken unsigned char sample_count = 0; // current sample number float voltage = 0.0; // calculated voltage void setup() { Serial.begin(9600); } void loop() { while (sample_count < num_samples) {//adds 10 sample values sum += analogRead(A2); sample_count++; delay(50); } voltage = ((float)sum /(float)num_samples * 5.0) / 1024.0; /*averages values then puts in terms of volts*/ Serial.print (voltage*1.2);//displays initial voltage (before resisted) Serial.println (" Volts"); //writes volts sample_count=0; //resets values sum=0; }