The sun tracking project is the project that you can used it to track the most power of the sun in this moment.
According to the interesting about sustainable development goals, the renewable energy is one of these especially the solar energy applications.
The source of the idea:
The Fusion 360 software is used for design.
First, designing the sides (front, back, right, left, top, and bottom sides).
Secondly, the sides are assembled in Fusion 360.
Fusion 360 icon
3D view of sun tracking
3D view of sun tracking
Front side
Back side
Right side
Left side
Top side
Bottom side
The fabricate using the laser cutter machine and the Rdworks software.
First, cutting all parts by a laser cutter machine.
Second, assembling all the parts using T-slots.
Using Plywood for the materials.
El Malky ML149 Laser Cutter
RDworks icon
Plywood Materials
The input for this project is a light-dependent resistor (LDR). LDR is a type of passive electronic sensor used to detect light.
The output is the servo motors that move PV panels.
Arduino is used as a brain for this project. When the sun is high on a side, then servo motor moves the PV panel in this direction.
Wiring circuit as follows:
Connecting LCD to Arduino
Connecting current and voltage sensors to the LED circuit
Connecting LDRs to the Arduino
Connecting servo motor to the Arduino
The power source for the project is the Adaptors.
Adaptor
Description of the sun tracking code:
1- Define analog inputs, floats, integers, and libraries.
2- Setup Serial Monitor.
3-Initialize the LCD.
4- Attach the servo pin.
5- Read the current sensor and the voltage sensor.
6- Define power equation (Power= voltage * current).
7- Display power in LCD.
8- Read values of right and left sensors of LDRs.
9- If conditions for working of servo motor after sensing of right and left LDRs sensors.
Description of the Arduino code in the real code:
1- Define analog inputs, floats, integers, and libraries:
#define ANALOG_IN_PIN A0
//A0 voltage sensor
//A1 current sensor
// Floats for ADC voltage & Input voltage
float adc_voltage = 0.0;
float in_voltage = 0.0;
// Floats for resistor values in divider (in ohms)
float R1 = 30000.0;
float R2 = 7500.0;
// Float for Reference Voltage
float ref_voltage = 5.0;
// Integer for ADC value
int adc_value = 0;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <Servo.h> // Servo library
//Servos
Servo trackerLR; // Create servo object for left/right movement servo
Servo trackerTB; // Create servo object for top/bottom movement servo
//Photoresistor Pins
int rightLDRpin = A2; //LDR right
//Analog pins for photoresistors
int leftLDRpin = A3; //LDR left
//Photoresistors
int rightLDR = 0; //Variables for the sensor values
int leftLDR = 0;
//Not a real sensor. This will be the average of right and left photoresistors.
//Differences between right/left and top/bottom photoresistors
int horizontalError = 0;
int verticalError = 0;
int trackerLRPos = 90; //Create a variable to store the servo position
void setup(){
2- Setup Serial Monitor:
Serial.begin(9600);
3-Initialize the LCD:
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
4- Attach the servo pin:
//Servo pins
trackerLR.attach(2);
}
void loop(){
5- Read the current sensor and the voltage sensor:
// Read the Analog Input
adc_value = analogRead(ANALOG_IN_PIN);
// Determine voltage at ADC input
adc_voltage = (adc_value * ref_voltage) / 1024.0;
// Calculate voltage at divider input
in_voltage = adc_voltage*(R1+R2)/R2;
// Print results to Serial Monitor to 2 decimal places
//Serial.print("Input Voltage = ");
//Serial.println(in_voltage, 2);
// Short delaydelay(500);
unsigned int x=0;
float AcsValue=0.0,Samples=0.0,AvgAcs=0.0,AcsValueF=0.0,Power=0.0 ;
for (int x = 0; x < 150; x++){ //Get 150 samples
AcsValue = analogRead(A1); //Read current sensor values
Samples = Samples + AcsValue; //Add samples together
delay (3); // let ADC settle before next sample 3ms
}
AvgAcs=Samples/150.0;//Taking Average of Samples
//((AvgAcs * (5.0 / 1024.0)) is converitng the read voltage in 0-5 volts
//2.5 is offset(I assumed that arduino is working on 5v so the viout at no current comes
//out to be 2.5 which is out offset. If your arduino is working on different voltage than
//you must change the offset according to the input voltage)
//0.185v(185mV) is rise in output voltage when 1A current flows at input
AcsValueF = (2.5 - (AvgAcs * (5.0 / 1024.0)) )/0.185;
6- Define power equation (Power= voltage * current):
Power = in_voltage * AcsValueF;
7- Display power in LCD:
Serial.print(Power);//Print the read current on Serial monitor
delay(50);
lcd.setCursor(2,0);
lcd.print("Power =");
lcd.setCursor(10,0);
lcd.print(Power);
lcd.setCursor(14,0);
lcd.print("W");
8- Read values of right and left sensors of LDRs:
//Values of the right and left sensors
rightLDR = analogRead(rightLDRpin);
leftLDR = analogRead(leftLDRpin);
9- If conditions for working of servo motor after sensing of right and left LDRs sensors:
horizontalError = rightLDR - leftLDR; //Difference between the two sensors.
if(horizontalError>20) //If the error is greater than 20 then move the tracker to the right
{
trackerLRPos--;
trackerLRPos = constrain (trackerLRPos, 0,179);
trackerLR.write(trackerLRPos);
}
else if(horizontalError<-20) //If the error is less than -20 then move the tracker to the left
{
trackerLRPos++;
trackerLRPos = constrain (trackerLRPos, 0,179 );
trackerLR.write(trackerLRPos);
}
delay(25);
}
Assembling in some steps like:
1- Connecting LCD to Arduino
2- Connecting current and voltage sensors to the LED circuit
3- Connecting LDRs to the Arduino
4- Connecting servo motor to the Arduino
5- Assemble the plywood parts using T-slots
Connecting LCD to Arduino
Connecting current and voltage sensors to the LED circuit
Connecting LDRs to the Arduino
Connecting servo motor to the Arduino
Assemble the plywood using T-slots
During these two weeks, I worked to make a sun tracking project using Arduino as the brain, LDRs as the sensors, and the servo motor as the output .
My challenge is in using LCD:
First: the LCD is not working.
Second: I searched about the problem on the internet. The internet told me maybe the problem is in the library.
Third: I saw some codes and chose one to put in my Arduino code.
Fourth: I found two problems:
a. The correct library that matches with my LCD.
b. Number of rows and columns that match with my LCD.
Fifth: After choosing the correct library and the correct rows and columns, the LCD worked.
If I had more time, I would use the linear actuator motor instead of the servo motor and make this project in the real world.