Maker Pro
Maker Pro

Solar tracker problem - LED generates variable voltage in the sun picked up by pico ADC

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
Hi all

I am trying to build the worlds simplest, cheapest solar tracker. Basically I am using a pi pico, a servo which rotates an LED mounted on the side of the vertical part of a "sundial". The servo rotates the sundial and when the LED moves into the shadow of the sundial upright, its voltage drops from say 1.2V to 0.2V. This voltage I read on pin 26 of the pico, an ADC pin. When the voltage suddenly drops I know the LED has passed into the shade thus with the LED readings, I know the direction of the sun.

So the servo turns through 160 degrees and at some point the voltage drops and the ADC measures 0 for about 4 seconds, but then it starts to rise again. Does anyone know why it drops to 0 (surely even in the shade there should be some voltage generated by the LED) and why it rises again? The only component I am using besides the servo is a LED with one leg on ground and the other leg to pin 26 which reads ADC.

Thanks for your help.
 

Attachments

  • LEDonServo.jpg
    LEDonServo.jpg
    213 KB · Views: 4

kellys_eye

Jun 25, 2010
6,514
Joined
Jun 25, 2010
Messages
6,514
I am trying to build the worlds simplest, cheapest solar tracker.
Using and Arduino, components and software.....?. the cheapest/simplest method is a mechanical (clockwork or just a powered microwave platten motor - suitably geared) mechanism turning a platform that is angled for the latitude.

Are you using an LED as the light sensor or an LDR?
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
Using and Arduino, components and software.....?. the cheapest/simplest method is a mechanical (clockwork or just a powered microwave platten motor - suitably geared) mechanism turning a platform that is angled for the latitude.

Are you using an LED as the light sensor or an LDR?
I am using a LED as the sensor since it generates 1.5 V facing the sun and 0.5V when shaded.
I have thought of strapping my PV panel to a sunflower :)
 

Bluejets

Oct 5, 2014
6,901
Joined
Oct 5, 2014
Messages
6,901
The servo rotates the sundial and when the LED moves into the shadow of the sundial upright, its voltage drops
Why an LED...?
Seems to me a photodiode would be more appropriate for several reasons.
 

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
Photo diode definitely slow enough response for a sundial. I'm thinking photo transistor. For no other reason then an option,perhaps?
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
Why an LED...?
Seems to me a photodiode would be more appropriate for several reasons.
Because I have LED's, hundreds of them, but no photodiode. And because I want to build the worlds simplest and cheapest sun tracker.
The LED works great on a multimeter, generating a V of 1.5V in full sun. So I am 95% of my way to the solution. But for some reasons it does not produce consistent readings on the ADC port. It goes from say 25000 to 0 as I turn the LED into the shade, and keeps giving me 0 for 3 more 10 degree rotations which tells me exactly where the sun is and is not, but then it starts generating higher numbers again. Its this inconsistency I am trying to figure out.
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
Photo diode definitely slow enough response for a sundial. I'm thinking photo transistor. For no other reason then an option,perhaps?
I do have a photo transistor and will try that. But I think that may require more than one component, like a resistor to limit the current and both to be connected between the +3.3V and ground, which is fine if it works. I will try it tomorrow when the sun rises where I am working. I suppose the ADC pin will be connected between the resistor and the photo transistor, so that when the sunlight reduces the resistance the voltage will change.

The smart part of this setup which I like is how strapping a sensor to one side of the vertical of a rotating sundial, one can very simply detect the sun. And I like the fact that it uses one component, the LED, not even a resistor.
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
Here is my pi pico code, which seems fine

#This program turns a servo through 180 and reads
#ADC V from a LED attached to pin 26 and GND
import machine
import utime
from machine import Pin, PWM, ADC

servo_pin = machine.Pin(0)
servo = machine.PWM(servo_pin)

pin_26 = Pin(26, mode=Pin.IN, pull=Pin.PULL_DOWN)
adc= ADC(Pin(26))


sleeptime = 1
MID = 1500000
MIN = 1000000
MAX = 2000000

pwm = servo

pwm.freq(50)
pwm.duty_ns(MID)

def read_voltage():
vin=(adc.read_u16())
return vin

while True:
for x in range (MIN,MAX,50000):
pwm.duty_ns(x)
utime.sleep(1)
vin = read_voltage()
print("Voltage in:", vin, " V")


Here is a circuit diagram of the world's simplest solar tracker since it only has one component to detect the sun.

Can I ask if this is the new home of electronicspoint? I recognise some of the old names are here.

1684120035698.jpeg
 

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
Could not help myself, apologies.
Anyway, As you have just experienced.LEDs are also sensitive to temperature. That is only one of your problems. I'm thinking a comparator along with temperature sensor right next to your LED so we can compensate for the error voltage
 

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
I must say, you put a lot of work into it, should be proud of yourself. This is a good read
 

Attachments

  • sensors-20-05200-v2.pdf
    2.7 MB · Views: 1

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
What color is your LED?
For future reference. Even though you are using an Light Emitting Diode as a light or photon detector the arrows should go the other way.
photodiodesymbol.png
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
I must say, you put a lot of work into it, should be proud of yourself. This is a good read
Thanks so much Delta Prime. You are right, it is a very good read for this project of mine, and absolutely relevant. I will finish reading it.
I am colour blind, but my LED looks yellow or green.

I was wondering if I am being an idiot. I have been trying out my solar tracker indoors where my computer is, using sunlight coming through a window. Maybe as the sundial rotates, it is picking up faint light coming through another window and giving a greater than zero reading.
 

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
The term or word "Volts" was named in honor of Alessandro Volta.
And I quote:
You must be ready to give up even the most attractive ideas when experiments show them to be wrong.
-Alessandro Volta.
This has happened to me multiple times, it is why I quoted it so often. Also..I have learned each time.
For me that is what makes it fun!
You made a decision and you pursued it.
I salute you!
:)
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
What color is your LED?
For future reference. Even though you are using an Light Emitting Diode as a light or photon detector the arrows should go the other way.
View attachment 59042
I see from the datasheet on LED's as sensors that you recommended, that you are right about the arrow having to point towards the LED.

I have all colours of LED's. I will try various ones. Also it seems that higher power LED's work better. I am using a cheap, low power one currently. Thanks again.
 
Last edited:

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
That's the spirit!!
Go get'em tiger.
How do you think Volta came up with that quote!
It probably happened to him like 50 times!
;)
 

iouae

May 14, 2023
24
Joined
May 14, 2023
Messages
24
That's the spirit!!
Go get'em tiger.
How do you think Volta came up with that quote!
It probably happened to him like 50 times!
;)
I used a clear powerful LED and now am getting consistent readings and it is tracking and pointing perfectly at the sun. Your help was invaluable Delta Prime, especially pointing me towards that pdf file. Many thanks. I put the finished build on youtube at
 

Bluejets

Oct 5, 2014
6,901
Joined
Oct 5, 2014
Messages
6,901
If you must use an LED, use one with a clear lens.
Can't make head nor tail out of your meter readings explanation.
Good luck with the cardboard, your layout and the Guinness book of records.
 

Delta Prime

Jul 29, 2020
1,913
Joined
Jul 29, 2020
Messages
1,913
Well if you really think about it, this is all @Bluejets fault! he's the one who mentioned photo diode in the first place. And I have to work on my humility so... I would appreciate it, if you don't mention me. I'm out here! :cool:
 
Top