0% found this document useful (0 votes)
22 views8 pages

Arduino Solar Tracker Project Code

This document describes a solar tracker project created by five students using an Arduino board. The solar tracker uses light dependent resistors (LDRs) and servo motors to automatically or manually track the sun's movement and maximize solar energy capture. It can be controlled by the LDR sensors to follow sunlight or a potentiometer for manual adjustment. The code explains how it functions in automatic and manual modes.

Uploaded by

Zelalem E
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views8 pages

Arduino Solar Tracker Project Code

This document describes a solar tracker project created by five students using an Arduino board. The solar tracker uses light dependent resistors (LDRs) and servo motors to automatically or manually track the sun's movement and maximize solar energy capture. It can be controlled by the LDR sensors to follow sunlight or a potentiometer for manual adjustment. The code explains how it functions in automatic and manual modes.

Uploaded by

Zelalem E
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JIMMA UNIVERSITY

JIMMA INSTITUTE OF TECHNOLOGY


FACULTY OF MECHANICAL ENGINEERING
INTRODUCTION TO MECHATRONICS
ARDUINO PROJECT- SOLAR TRACKER

Group Members [Link]


1. Zelalem Esubalew RU 1530/12
2. Sirawudink Getachew RU 2197/12
3. Natinael Gebeyehu RU 1298/12
4. Tariku Buzayew RU 3988/11
5. Surafel shetie RU 0662/12
Solar Tracker
Solar tracker is a device that follow the sun’s angle of radiation to capture the
maximum solar energy. It uses Light dependent resistor (LDR) sensors to measure
light intensity and adjust itself to the direction which has high light intensity. The
solar tracker can be controlled automatically using LDR or manually using
potentiometer.

Components

Name Quantity

Arduino Uno board 1

Micro-servo Motor 2

Rpot1 1

Resistor (330 ohm) 4

Rotary potentiometer 2
Pushbutton 2

LDR 4

Working principle
It is based on a solar tracker that can be rotate automatically to track the sun with help of four LDR
sensors and two servomotors or manually using a potentiometer. To switch between the two modes, a
push button is used. Another push button is used to link either the up-down servo meter or left-right
servo meter to the potentiometer to control their movement. Moreover a computer is used as virtual
instrument to visualize the mode and current, voltage and power of the pv panel. Arduino Uno board is
utilized to implement all software requirement of the system.

Code

#include <Servo.h>

//Servo motor library

#include <Servo.h>

//Initialize variables

int mode = 0;

int axe = 0;

int buttonState1 = 0;

int buttonState2 = 0;

int prevButtonState1 = 0;

int prevButtonState2 = 0;

int ldrtopr= 0; // top-right LDR

int ldrtopl = 1; // top-left LDR

int ldrbotr = 2; // bottom-right LDR

int ldrbotl = 3; // bottom-left LDR

int topl = 0;

int topr = 0;

int botl = 0;

int botr = 0;
//Declare two servos

Servo servo_updown;

Servo servo_rightleft;

int threshold_value=10; //measurement sensitivity

void setup()

[Link](9600); //serial connection setup //opens serial port, sets data rate to
9600 bps

[Link]("CLEARDATA"); //clear all data that’s been place in already

[Link]("LABEL,t,voltage,current,power,Mode"); //define the column headings (PLX-DAQ


command)

pinMode(12, INPUT); //Mode switch Button

pinMode(11, INPUT); //Axis switch

pinMode(A4, INPUT); //Potentiometer for right-left movement and for up-down movement

servo_updown.attach(5); //Servo motor up-down movement

servo_rightleft.attach(6); //Servo motor right-left movement

void loop()

// pv_power();

char Mode;

float volt = analogRead(A5)*5.0/1023;

float voltage = 2*volt; // Volt=(R1/R1+R2)*Voltage / R1=R2=10Ohms => voltage=2*volt)

float current = voltage/20; // I=voltage/(R1+R2)


float power = voltage*current;

[Link]("DATA,TIME,"); // PLX-DAQ command

[Link](voltage); //send the voltage to serial port

[Link](",");

[Link](current); //send the current to serial port

[Link](",");

[Link](power); //send the power to serial port

[Link](",");

// [Link](Mode);

buttonState1 = digitalRead(12);

if (buttonState1 != prevButtonState1) {

if (buttonState1 == HIGH) {

//Change mode and ligh up the correct indicator

if (mode == 1) {

mode = 0;

} else {

mode = 1;

prevButtonState1 = buttonState1;

delay(50); // Wait for 50 millisecond(s)

if (mode == 0) {

Mode='M';

[Link](Mode); //send Mode "Manual" to serial port

manualsolartracker();

} else { // mode automatic


Mode = 'A';

[Link](Mode);

automaticsolartracker(); //send Mode "Automatic" to serial port

void automaticsolartracker(){

//capturing analog values of each LDR

topr= analogRead(ldrtopr); //capturing analog value of top right LDR

topl= analogRead(ldrtopl); //capturing analog value of top left LDR

botr= analogRead(ldrbotr); //capturing analog value of bot right LDR

botl= analogRead(ldrbotl); //capturing analog value of bot left LDR

// calculating average

int avgtop = (topr + topl) / 2; //average of top LDRs

int avgbot = (botr + botl) / 2; //average of bottom LDRs

int avgleft = (topl + botl) / 2; //average of left LDRs

int avgright = (topr + botr) / 2; //average of right LDRs

//Get the different

int diffelev = avgtop - avgbot; //Get the different average betwen LDRs top and LDRs bot

int diffazi = avgright - avgleft; //Get the different average betwen LDRs right and LDRs left

//left-right movement of solar tracker

if (abs(diffazi) >= threshold_value){ //Change position only if light difference is bigger then the
threshold_value

if (diffazi > 0) {
if (servo_rightleft.read() < 180) {

servo_rightleft.write((servo_updown.read() + 2));

if (diffazi < 0) {

if (servo_rightleft.read() > 0) {

servo_rightleft.write((servo_updown.read() - 2));

//up-down movement of solar tracker

if (abs(diffelev) >= threshold_value){ //Change position only if light difference is bigger then
thethreshold_value

if (diffelev > 0) {

if (servo_updown.read() < 180) {

servo_updown.write((servo_rightleft.read() - 2));

if (diffelev < 0) {

if (servo_updown.read() > 0) {

servo_updown.write((servo_rightleft.read() + 2));

void manualsolartracker(){
buttonState2 = digitalRead(13);

if (buttonState2 != prevButtonState2) {

if (buttonState2 == HIGH) {

//Change mode and ligh up the correct indicator

if (axe == 1) {

axe = 0;

} else {

axe = 1;

prevButtonState2 = buttonState2;

delay(50); // Wait for 50 millisecond(s)

if (axe == 0) { //control right-left movement

servo_rightleft.write(map(analogRead(A4), 0, 1023, 0, 180));

} else { // //control up-down movement

servo_updown.write(map(analogRead(A4), 0, 1023, 0, 180));

Common questions

Powered by AI

The servos adjust the solar tracker's position by interpreting the light intensity data from four LDR sensors. The average readings from the top and bottom, as well as left and right LDRs, are calculated. Differences in these averages determine whether the servo motors move the tracker up or down, left or right, based on threshold values to ensure maximal sunlight exposure .

Axis distinction in manual control allows users to selectively adjust either the elevation or azimuth of the solar tracker. Technically, this separation is managed through an additional button that switches the axis controlled by the potentiometer, sending appropriate signals to the servos for movement in the desired direction, either up-down or left-right .

The threshold value in the solar tracker system is critical in mitigating unnecessary movement. Movements of the solar tracker are only executed if the difference in light intensity between the LDRs exceeds this threshold. This constraint ensures that the system reacts only to significant changes in sunlight positioning, thus optimizing servo activity and reducing wear .

The Arduino Uno board is pivotal in implementing the software requirements of the solar tracker system. It processes sensor data, controls servo motors, and manages the switching between manual and automatic operation modes. The board also interfaces with a computer to visualize operational parameters such as mode, current, voltage, and power of the photovoltaic panel .

To ensure optimal sunlight exposure, the solar tracker utilizes LDR sensors positioned on four corners, calculating the average light intensity for top, bottom, left, and right. By adjusting based on these readings, the system maximizes energy capture, significantly important for solar energy systems as it enhances efficiency and energy output .

Using a push button for mode switching offers simplicity and direct control, facilitating ease of use and rapid response to user preferences. However, it may also limit the flexibility for more nuanced adjustments and could be less intuitive for non-technical users unfamiliar with system feedback indications .

The Light Dependent Resistor (LDR) sensors in the solar tracker system are used to measure light intensity. They adjust the solar tracker's position to maximize the capture of solar energy by orienting towards the direction of highest light intensity .

The system visualizer, via a computer interface, helps users understand the solar tracker’s performance by displaying the mode (Automatic or Manual), alongside crucial electrical parameters like current, voltage, and power. This real-time data enables users to gauge the functionality and efficiency of the solar tracker, providing feedback for possible adjustments .

Switching between manual and automatic modes is controlled via a push button connected to the Arduino. When pressed, it toggles between two predefined states, altering the functionality either to respond automatically to LDR sensor input or letting the user manually adjust the positioning using a rotary potentiometer. This flexibility allows the system to operate optimally under varying conditions .

In manual mode, transitioning from elevation to azimuth movement involves a button that switches the control axis by changing the variable 'axe' from 0 to 1 or vice versa. This effectively changes the rotary potentiometer's control from up-down (elevation) movement to left-right (azimuth) movement, enabling focused manual adjustments in different directions .

You might also like