Street light using LDR & RTC

Hi, I need some guidance on how to make this happen.

I have come out with a project controlling street light with RTC and LDR simultaneously.

My initial idea is when the time is between 5 pm - 7 pm (set by RTC) and the LDR detects the light is low my street light will be on.

If 5 pm - 7 pm LDR detects that the light is high, my street light will not be on.

I tried to search the internet for some guidance all I am able to find is a similar project but instead of RTC and LDR work together, the project added a push button to change mode between RTC and LDR which is not what I wanted.

Really hope someone could guide me along to solve this project thanks!

You have to define a precedence (or cost), whether you prefer the light being on or off if both sources disagree. Then set a variable to that default state and let the LDR and RTC checks eventually turn it to the opposite state. Finally set the light on or off, depending on the state of the variable.

I would have thought a simple "AND".

If RTC(5-7) AND LDR low level, light on.
If either is not true then light is off.

I had thought about it too as I am unable to test it just het so I’m seeing whether there is any other alternative ways :slight_smile:

I had thought about it too as I am unable to test it just het so I'm seeing whether there is any other alternative ways :slight_smile:

Seems to be broken down to it's simplist form as it is.
Could be done with relay or transistor logic , no need for Arduino.

Alright, thanks :slight_smile:

In my opinion, no real need for an RTC either. Have the light come on when natural lighting gets to a low enough point. Turn it off when it gets bright enough.

But I’m guessing that wouldn’t meet the requirements of the project.

So, the basic idea if(timeToTurnOn == true && darkEnoughOutside == true){ powerTheLight = true; } should work, IMO.

Start with a simple code to get the LDR working with an LED. Udjust it so the LED comes on at a specific ambient light level. And goes off at a different specific level. So, if 0 is totally dark. And 100 is bright sun (just numbers I chose). The light would come on at 25 but not be shut off til the ambient level comes back up to 30. That keeps the light from flickering.

Then start on a simple RTC code. A basic alarm clock code would suffice. No need for a speaker. Just use serial prints to test for the time display and alarm going off.

Once you have both working, combine the two. If you get stuck, come back and post your code (between code tags) and explain your issue. Folks will help you out so long as you are trying.

Thank you so much! Will update if I face problem that is unsolved. :slight_smile: