Solar Containment Device

by sambriz565 in Circuits > Arduino

56 Views, 0 Favorites, 0 Comments

Solar Containment Device

Screenshot 2024-11-26 184757.png

This Solar Containment device aims to solve one of the biggest issues with solar power today, being that they can only charge under sunlight. This causes all of these devices to typically be installed on high up or otherwise incontinent places such as roofs making it difficult for them to be used by those who live in apartments and limiting where and when solar panels may be used.

This project is an attempt to rectify this by tracing the sun and keeping low to the ground even being portable.

Supplies

IMG_7006.jpeg

Arduino Uno (specific Arduino model is not important the R3 that I used is linked)

Solar Panels 6V

Photo Resistors (5539)

10k Resistors

9g Servo Motor

MG995 Servo Motor

9V Rechargeable Lithium Battery

Box This is the specific box that I used. Any box L 8inches, H 12inches, W 4inches will work

Designing the Solar Panel Mounts

Screenshot 2024-11-24 135736.png
Screenshot 2024-11-24 142643.png

The main component of the project is the solar panels movement as such the mounts are the first thing that needs to be tackled. The STL files are attached bellow.

  1. Print using PLA
  2. Generate supports everywhere
  3. Infill 60%


Code

Screenshot 2024-11-26 183759.png

With only four sensors and two motors to deal with the code is not difficult at all to write.

Before beginning to program ensure that the My Servo library is installed:

Something important to note is that the My Servo library limits the servo to move in 180 degrees.


#include <Servo.h>

const int pinUR = A3; // Upper Right
const int pinUL = A1; // Upper Left
const int pinLL = A0; // Lower Left
const int pinLR = A5; // Lower Right

int UL = 0;
int UR = 0;
int LL = 0;
int LR = 0;

Servo myServo; // Create a servo object
Servo myServo2;

void setup() {
  Serial.begin(9600);   // Initialize serial communication
  myServo.attach(9);    // Attach the first servo to pin 9
  myServo2.attach(10);   // Attach the second servo to pin 10
  myServo2.write(120);   // Initialize the second servo at 120°
}

void loop() {
  // Read the Photo Resistors
  UR = analogRead(pinUR);
  UL = analogRead(pinUL);
  LL = analogRead(pinLL);
  LR = analogRead(pinLR);

  // Print sensor values for debugging
  Serial.print("Sensor UR: "); Serial.print(UR);
  Serial.print(" | Sensor UL: "); Serial.print(UL);
  Serial.print(" | Sensor LL: "); Serial.print(LL);
  Serial.print(" | Sensor LR: "); Serial.println(LR);

  // Determine which sensor detects the most light
  if (UL < UR && UL < LL && UL < LR) {
    myServo.write(180); 
    myServo1.write(90);
// Move servo to 90° for UL
    Serial.println("Servo moved to 90° (UL has the most light)");
  } else if (UR < UL && UR < LL && UR < LR) {
    myServo.write(90); // Move servo to 0° for UR
    myServo1.write(90);
    Serial.println("Servo moved to 0° (UR has the most light)");
  } else if (LL < UL && LL < UR && LL < LR) {
    myServo.write(180);
    myServo1.write(90);
 // Move servo to 180° for LL
    Serial.println("Servo moved to 180° (LL has the most light)");
  } else if (LR < UL && LR < UR && LR < LL) {
    myServo.write(0);
    myServo1.write(90);
 // Move servo to 135° for LR (simulating 270°)
    Serial.println("Servo moved to 135° (LR has the most light)");
  } else {
    Serial.println("No clear light direction detected.");
  }

  delay(550); // Delay for stability
}


Downloads

Wiring

Screenshot 2024-12-24 131342.png
Circuit1.png

Wiring in relation to The following wiring is assuming that the Photoresistors are using the same analog pins as the code states. Any analog pin will work for any of the four so to change that simply change. Same goes for the digital pins that the servos are attached to.

Power

Another thing to note in the Wiring that will be displayed in the real Circuit is that the 9V Battery is supposed to be a lithium battery that is charged by the solar panels. The power system works by having the lithium battery be charged up by the solar panels and then have the power go back into the system. This is to have a larger power reserve that a capacitor cannot provide. As well as smooth out the power even more than the capacitor can.

Photo resistors

Photo resistors are not polarized like a majority of electrical components or sensors are, they act most like resistors because at their core that is what they are. The sun causes the resistance within these photo resistors to lower. This resistance can be read using the analog pins of the Arduino.

Soldering

Due in part to the size of the box wires are going to have to be soldered onto the ends of all four photo resistors to ensure that they can connect to the Arduino on the bottom.

In addition the solder and wires that come on the solar panels from the factory is brittle and should be resoldered to prevent it from falling off.

Uploading program

In order to avoid possible overload for the system turn off the external lithium battery or simply disconnect from the VIN pin on the Arduino.

Box Assembly

IMG_6970 (1).jpeg
  1. Using a 3MM drill bit create four holes, one in each corner of the box
  2. feed the wires of the photo resistors through
  3. In the middle trace the 180 Large motor
  4. Drill four holes where the screws of the large motors would lie
  5. Unscrew the screws from the bottom of the motor
  6. Be careful as these screws hold the motor together
  7. Screw the motor using the original screws through the holes
  8. In the inside of the box screw in the Arduino towards the middle and the Battery underneath it.
  9. Use the original mounting tape of the bread board

Motor Assembley

0.jpg
  1. Screw the panel flaps into the motor hinge using four screws
  2. Using screws and nuts mount Part 1 into the motor hinge
  3. Screw the servo horn into the motor mount
  4. Screw the motor mount onto the large servo motor

Place in the Sun

Solar Containment Device

While the photo resistors do react to florescent lights, the specific model type specified works best in the sun as do the solar panels attached to it.

In the attached video shade is used to intentionally abstract the photoresistors for demonstration purposes