Smart Solar Tracker - Arduino Solar Panel System
by charlieqian222333 in Circuits > Arduino
206 Views, 1 Favorites, 0 Comments
Smart Solar Tracker - Arduino Solar Panel System
This project for IEEE Arduino Contest 2024 is all about creating a solar tracking system that maximizes energy efficiency by capturing the most sunlight, which is realized by adjusting the position of the panel automatically, given limited electronic components allowed to use. I wrote it in a way where users can switch between manual control, automatic scanning, and remote control through a custom interface.
A YouTube video overviewing this project for the contest can be found under my channel @charlieqian6770.
https://www.youtube.com/watch?v=3B3VpSgj0tg
Supplies
System Configuration:
- Arduino MEGA controller board 1pc
- LCD1602 Module (with pin header) 1pc
- Servo Motor SG90 1pc
- DHT11 Temperature and Humidity Module 1pc
- Potentiometer 10K 2pcs
- 830 Tie-Points Breadboard 1pc
- Buttons 2pcs
- Resistors
- Photoresistor 1pc
- Red LED, blue LED, and green LED 1pc each
- Breadboard jumper wires
- Female-to-male wires
Other materials for demonstration and test purposes:
- 2D plastic platform 1pc
- Foam plastic
- Aluminum kitchen foil
- A stable and centralized light source
- USB cable 1pc
Hardware and software:
- A laptop
- The Arduino IDE
- The processing interface
More about Arduino mega: "ELEGOO Mega 2560 Project The Most Complete Ultimate Starter Kit"
Fundamental Logic and Initialization
The potentiometer is used to control that servo motor. As you twist the potentiometer, the Arduino reads the analog value and maps it to a corresponding Servo angle, which is then displayed on the LCD screen.
This part initializes the libraries for controlling servo motors, interfacing with LCD displays, and interfacing with DHT sensors.
We also need to define the pin locations.
A brief overview of the three control modes for this tracker:
1. Manual Mode
- The user will manually controls the movement of the panel using a potentiometer. This mode is activated when Button 1 is pressed.
2. Processing Mode
- This mode is activated when the system receives a command from Processing software, which allow external control of the solar panel. Button 2 or a serial input ("P") activates this mode.
3. Automatic Scanning Mode
- The solar panel will automatically scans for the best position based on light intensity measured by an Light Dependent Resistor (LDR). It will then move to the position with the highest detected light intensity, and importantly, periodic scans will occur if the environment changes significantly (either temperature or light intensity, monitored by a DHT 11 sensor).
We need to complete Button Debounce, and Servo/ LCD objects declaration, as well.
Threshold value setup - you can play around with this critical value so that it truly reflects optimal changes in later modes.
Nuances like serial communication setup, initializations, and LCD welcome message are omitted here.
Manual Control
Button 1 - Manual Mode Activation
Comments:
- The reads the state of Button 1 using a debounce function to prevent false presses due to likely mechanical bounce for smooth operation.
- The state of the corresponding LED is updated to reflect current mode.
- When pressed, Button 1 allows manual mode overring any automatic or processing-based control.
Manual Mode Servo Control
Comments:
- When manual mode is active (manualMode == true), the system reads the value from the potentiometer connected to potPin.
- The potentiometer value (0 to 1023) is mapped to a range suitable for the servo motor (0° to 180°), which allows precise control of the solar panel position.
- The servo position is updated in real-time based on the potentiometer’s position.
- The LCD displays the current mode as "Manual Mode" and the current position of the servo.
- The map() function ensures that the potentiometer has the full range.
LEDs for Visual Feedback
Comments:
- In manual mode, LED1 is turned on; in any other mode, it will be turned off.
- For visual confirmation for user accessibility.
Button 2 - Reset to Manual Mode
Comments:
- It allows the user to return to manual mode by pressing Button 2 from other modes by overriding.
Remote Control Via Processing Interface
Part 1/2 - Arduino IDE Code
Task A Serial Input to Trigger Processing Mode
Comments:
- When this code detects the character "P", Processing Mode is activated by setting useProcessing to true and manualMode to false.
- If the character "A" is received, the systems switches to automatic mode.
- In Processing Mode, the code will read servo position values sent via the serial connection and adjust the servo based on where the user is going to click on the interface map where sunlight intensity is laid.
Task B Processing Mode Servo Control
Task C LEDs for Visual Feedback
Task D Resetting to Manual or Automatic Mode
Part 2/2 - Processing Code
Task E Import and Serial Initialization and Grid Setup Variables
Comments:
- Several things are achieved here. First off, a serial communication between the Arduino and the Processing is established through the declaration of a Serial object.
- Secondly, cols, rows, and rectSize define the number of columns, rows and the size of the rectangle of the grid generated, respectively. This will visualize the intensity map.
Task F Setup Function
Comments:
- size(800, 600) sets the window dimensions to 800*600 pixels.
- Serial.list()[0] obtains the first available serial port.
- myPort initializes the serial communication on portName at a baud rate of 9600.
- noLoop() will make draw() run only once, which only allows the interface to refresh when redraw() is called.
Several Important Functions to Outline:
Task G Draw function
Task H Generating the Random Intensity Map Function
Task I Color mapping function
Task J Drawing the legend
Task K Mouse and keyboard interactions
Automatic Scanning
Automatic scanning mode initialization
Initial scan for optimal light position
Comments:
- The system performs an initial scan across a specified range (scanRange) when first activated at each step.
- The servo moves based on the stepSize across the range from the LDR values.
- If it stores the highest light intensity value (maxLdrValue) and the position at that scan (bestServoPos), it will be set as the panel's 'optimal' position.
Panel position adjustment based on environmental changes
Comments:
- The system will continuously monitors light intensity and temperature in this mode.
- If the changes in temperature and light exceed the defined thresholds (i.e. Current panel position could no longer be at the position where sunlight is maximum), the system triggers a new scan.
- The LCD will display the current temperature and light intensity for user as a real-time feedback.
Testing, Results and Summary
After assembling (this could be tricky when you are attempting to wrap your carefully pre-holed foam block with foil into a perfect cuboid) and calibrating the solar tracker which will be placed on a 2-direction electro-mechanical head supporter (this could be tricky when you are attempting to determine the angle 0 position of the motor to make sure your panel installed later on will not crash into the supported due to angle miscalculations).
Overall, each mode demonstrated its unique advantages depending on the environmental conditions. This overall meets my initial expectation of building a all-around solar energy capture system, which can be potentially produced largely and function well in all terrains and contexts. Control Mode 3 - the automatic scanning mode - achieved the most optimal energy yield under variable sunlight. Up to 25% more of solar power can be collected comparing to other configurations.
To conclude, what this project can bring you (it definitely brought me!) are the following: real-world applications, optimizing hardware-software interaction, and troubleshooting hardware issues. Again, due to the nature of this competition, these skills are critical when you are trying to innovate something purposeful, helpful and situational.
In the future where constraints will be minimized, I will suggest investigators to study how a 3D supporter with 2+ servos will benefit the accuracy and operability of the system.