How to Make an Arduino Solar Tracker : The Light Sensor
One of the most important parts of the solar tracker is the Light Sensor whose job is to accurately detect the position of the sun.
What is a light dependent resistor or photo-resistor?
The resistance of a light dependent resistor or photo-resistor changes according to the intensity of the light. In other words, the resistance of the LDR is inversely proportional to the light intensity. We shall use this property to track the sun
Design of the light sensor
Circuit diagram
Circuit Diagram: Light Sensor for an Arduino Solar tracker |
The light sensor works by creating a voltage divider by using a fixed resistance, in this case a 15 kilo-ohm resistor and an LDR. The value of the resistor was chosen as the illuminated resistance of my LDR was approximately 12 kilo-ohm. The corresponding voltage created is fed to the ADC of the arduino. Since the one end of the LDR was tied to ground, an increase in illumination would correspond to a higher ADC output
Physical Design
Mechanical aspect of light sensor design |
The light sensor was constructed on a piece of perfboard with some ribbon cable for easy connectivity to the Arduino.
The light sensor is in a T shaped design with a piece of perfboard/veroboard perpendicular between the two LDRs. The reason for the "divider" is that if the position of the son is on either side of the light sensor, a shadow will fall on one sensor and only the LDR facing the sun will be illuminated
Connecting it to the Arduino and the Software
Connection of light sensor to arduino |
The outputs form both the LDR are connected to ADC pins AnalogPin0 and AnalogPin1 of the arduino.
Here is a simple arduino sketch that reports the value of both the LDRs and reports it on the serial monitor
/*
LDR Calibration test for solar tracker
Sketch by Sarang Gupta
For more info visit www.mysolaradventures.com
*/
int ldr1 = 0; //LDR1 is connected to analog pin0
int ldr2 = 1; //LDR2 is connected to analog pin1
int ldr1_value = 0; //variable to store LDR1 values
int ldr2_value = 0; //variable to store LDR2 values
void setup()
{
Serial.begin(9600); //start outputting data to serial monitor
}
void loop()
{
ldr1_value = analogRead(ldr1); //reads the light hitting LDR1
ldr2_value = analogRead(ldr2); //reads the light hitting LDR2
Serial.print("LDR1 reading= ");
Serial.println(ldr1_value); //prints the LDR values to serial monitor
Serial.print("LDR2 reading= ");
Serial.println(ldr2_value); //prints the LDR values to serial monitor
delay(50); //wait for 50 ms
}
In the next post i will outline the actuator for the solar panel and a video of the final working tracker!