Read this in other languages: English, 中文.
This is a solar tracker repository for the ES2C6 course. This project includes two distinct Arduino implementations to demonstrate and compare different solar tracking strategies.
- Simple LDR: A pure "active" tracker that uses four LDRs (Light Dependent Resistors) to find the brightest light source.
- Advanced Hybrid + Web UI Tracker: A "hybrid" tracker that uses an Arduino R4 WiFi to fetch precise UTC time, calculate the sun's astronomical position (azimuth/elevation), and then uses LDRs for fine-tuning. It also hosts a modern Web UI for status monitoring.
This is a classic "active" solar tracker. It doesn't care about time or location; it only cares where the light is coming from.
- Active Tracking: Purely based on the difference in readings from the four LDRs to move the servos, always pointing towards the brightest direction.
- Solar panel voltage
- Raw readings of the 4 LDRs
- Current servo angles (Horizontal/Vertical)
- Average light intensity
- Startup Scan: Executes a
findMaxLightPosition()function on boot, scanning the sky (0-180 degrees) to find the initial brightest spot. - Voltage Monitoring: Optionally connect a small solar panel to pin
A4to monitor its output voltage.
- Arduino Uno / Nano (or any compatible board)
- 2x Servo Motors (for Pan/Tilt)
- 4x LDRs (Light Dependent Resistors)
- 4x Pull-down Resistors (e.g., 10KΩ)
- 1x Small Solar Panel (for A4 pin reading)
- 2-axis Pan/Tilt bracket
- Breadboard and jumper wires
ServoAdafruit_SSD1306Adafruit_GFX
- Download the code into the
Codes/sdynamic_Step/folder. - Open
sdynamic_Step.inoin the Arduino IDE. - Install the
Adafruit_SSD1306andAdafruit_GFXlibraries using the Library Manager. - Check Pins: Ensure your OLED and servo pin definitions match the
#definesection at the top of the code.- OLED (SPI):
OLED_MOSI,OLED_CLK,OLED_DC,OLED_CS,OLED_RESET - Servos:
5(horizontal),6(vertical) - LDRs:
A0(TL),A1(TR),A2(BL),A3(BR) - Solar Panel:
A4
- OLED (SPI):
- Upload the code to your Arduino.
- When the device boots, it will first perform a "find max light" scan. The OLED will then light up with real-time data, and the tracker will begin active tracking.
This version uses an Arduino R4 WiFi board, combining time-based predictive tracking with LDR-based corrective tracking.
- Hybrid Tracking:
- Predictive: Connects to
worldtimeapi.orgto get UTC time and accurately calculates the sun's Azimuth and Elevation based on a given Latitude and Longitude. - Corrective: Uses a 4-quadrant LDR sensor array to fine-tune the calculated position, compensating for any misalignments or atmospheric effects.
- Predictive: Connects to
- Web Console: Hosts a web server that provides a modern, responsive dashboard built with Tailwind CSS.
- Solunar API: Fetches the day's sunrise, sunset, and solar noon times from
api.sunrise-sunset.org. - Night Mode: Automatically enters "Night Mode" when the sun's elevation is below a threshold (e.g., after sunset), moving the servos to a preset night position (e.g., facing east, ready for sunrise).
- WiFi Management: Automatically attempts to reconnect to WiFi if the connection is lost.
- Arduino R4 WiFi
- 2x Servo Motors (for Pan/Tilt)
- 4x LDRs (Light Dependent Resistors)
- 4x Pull-down Resistors (e.g., 10KΩ)
- 2-axis Pan/Tilt bracket
- Breadboard and jumper wires
WiFiS3ArduinoJsonServo
- Download the code into the
Codes/Dynamic_Step_wtih_Website/folder. - Open
dynamic_Step_wtih_Website.inoin the Arduino IDE. - Install the required libraries using the Library Manager.
- Crucial Configuration: Modify the constants at the top of the sketch:
WIFI_SSID: Your WiFi network name.WIFI_PASS: Your WiFi password.LATITUDE: Your geographic latitude (e.g.,52.378753f).LONGITUDE: Your geographic longitude (e.g.,-1.570225f).
- Upload the code to your Arduino R4 WiFi.
- Open the Serial Monitor (Baud Rate: 115200) to view the connection status and the IP address.
- On a device on the same network, open a web browser and navigate to that IP address (e.g.,
http://192.168.31.166) to see the web console.
This model uses a simple Feedback Loop:
- Compare the average of the top LDRs vs. the average of the bottom LDRs (
diffVertical). - Compare the average of the left LDRs vs. the average of the right LDRs (
diffHorizontal). - If the vertical difference is greater than the
tolerance, move the vertical servo up or down. - If the horizontal difference is greater than the
tolerance, move the horizontal servo left or right. - This process repeats, constantly minimizing the LDR differences to stay pointed at the light source.
This model uses a Predict-Correct loop:
- Predict (Every 10 seconds): The device gets the precise time from an API and uses the
solarPositionUTCfunction to calculate the sun's theoretical position in the sky (azimuth/elevation). - Correct (Every 50 milliseconds):
- The LDRs read the light differential (
azDiff,elDiff). - The new target position for the servo is a combination of (LDR correction) + (a gentle pull towards the theoretical position).
currentPan += deltaPan + SOLAR_CORRECTION_RATE * (targetPanFromSolar - currentPan);- This ensures the tracker not only points accurately at the sun (LDR part) but also knows where the sun should be, even after it's temporarily hidden by clouds (time-based part).
- The LDRs read the light differential (
This project was a collaborative effort for the ES2C6 module, and the successful outcome is a result of the dedicated work of the entire team. We extend our sincere thanks to the following members:
| Name | Assigned Role |
|---|---|
| Monteiro, Marcus | Background Research |
| Zhao, Haoxiang Owen | Mechanical Design and CAD Work |
| Jackson, Josh | Electronic Design |
| Stephan, Freddy | Manufacture of Mechanical Components and Electronic Circuit Boards |
| Maini, Rohan | Assembly |
| Boyu Zhang Bob (me) | Programming and Testing |
| Charusirisawad, Pun | Overall Project Management and Assigned Task Lead |
This project is licensed under the MIT License. You should add a LICENSE file to your repository.
