Solar panels need sunlight to generate the electricity but as we all know our renewable light source sun is not always stable at one position, it rises from east and sets at west one horizon to another. So if we place our solar panel in any one direction they wont get the most of the light throughout the day. So in that scenario Sun light tracking system comes into role. This system faces the panels towards the incomming light source to get more out of it.
This is an example of how you can create for real time bigger solar panels but you need to implement with more heavy duty components for durability during winds.
So lets get started with looking at the required components for this project.
- ESP8266 NodeMCU with MicroPython installed
- Light dependent resistors (LDR). X 2
- MG90S Servo – generic X 1
- 10k Resistor X2
- Connecting wires.
- 2 diodes for stable readings (1N4004 )
Connect the above components as shown in the below circuit diagram.
In the above circuit diagram we connected two LDR to the D1 and D2 pins along with diodes in series and other side of the LDRs are connected to one side of 10k Ohm resistors and other side of the resistor to ground GND.
Next connect the servo motor as power wire to the 5V supply of nodeMCU Vin, and blackwire to the Ground, and signal wire to the D5 digital pin.
Servo motor Setup:
To build the moving face we need to add a base plastic panel on servo motor and the rotating shaft of motor should be sticked to ground surface. for reference look at the below image. this setup works only for mini sized project.
Upload the code to the nodeMCU with MicroPython installed in it through uPycraft. If you dont know how to install refer the below tutorials.
Copy the code from below and paste it in the main.py file and upload it to board.
ldr1 = machine.Pin(4, machine.Pin.OUT)
ldr2 = machine.Pin(5, machine.Pin.OUT)
ldr1val = 0
ldr2val = 0
direction = 40
adc = machine.ADC(0)
servopin = machine.Pin(14)
servo = machine.PWM(servopin, freq=50)
ldr1val = adc.read()
ldr2val = adc.read()
ldrsum = (ldr1val - ldr2val)
if (ldrsum >= 99):
elif (ldrsum <= -99):
# print("nothing to do")
if (direction < 40):
direction = 40
elif (direction > 120):
direction = 120
directiont = direction
After uploading the code press reset button on the board, then to test weither it is working or not use a flash light and move over it. The motor moved according to the light.