# How to use a photo cell to open and close a chicken coop door

#### marcovlusa

Joined May 12, 2021
25
For my school project, I built a chicken coop and I installed a microwave synchronous motor to lift the door that works just fine. Now, I need to know how to install a photo cell to turn on and off the synchronous motor for only one minute at sunrise and at sunset using a photocell. What kind of photocell should I buy? Do I need an electronic relay and what kind? I'm at odds because normally a photocell turns on a light at darkness and stays on. Then, it turns off the light when the sun rises and I need the synchronous motor to be turned in just for one minute at sunrise and sunset because that's the time it takes to roll up and down the chicken coop. I already installed a relay, but it only can be programmed to turn on and off every 12 hours or so. Chickens go out at sunrise and go inside to sleep at sunset

#### LowQCab

Joined Nov 6, 2012
1,321
Since this whole project is strictly a theoretical exercise,
a simple "Flood-Light-Photo-Cell" from Home-Depot will work just fine.

This is assuming that you are using Gravity to Close the Door.
The small synchronous Motor can withstand "Locked-Rotor" or "Stalled"
conditions for quite a long period of time,
although a full day, outside, in hot weather will eventually over-heat it, and kill it.

This will simply leave the Motor Powered all day, and off at night.

This Motor is not designed for Continuous-Duty-Service.

If this is not an acceptable solution, you will have to install limit-switches and
actually power the Door shut.
.
.
.

#### marcovlusa

Joined May 12, 2021
25
Since this whole project is strictly a theoretical exercise,
a simple "Flood-Light-Photo-Cell" from Home-Depot will work just fine.

This is assuming that you are using Gravity to Close the Door.
The small synchronous Motor can withstand "Locked-Rotor" or "Stalled"
conditions for quite a long period of time,
although a full day, outside, in hot weather will eventually over-heat it, and kill it.

This will simply leave the Motor Powered all day, and off at night.

This Motor is not designed for Continuous-Duty-Service.

If this is not an acceptable solution, you will have to install limit-switches and
actually power the Door shut.
.
.
.
So, could you help me then with how to install limit switches? Which ones should I buy on the internet? Right now, I'm using a relay to turn the synchronous motor on every 12 hours, but chickens tiring is not dictated by that, but by sunrise and sunset. That's why I thought about the photo cell. I've tried to use an intelligent plug with the Alexa app with a routine which turns on the motor as I want, but it's not precise and it takes more than the minute the door takes to be closed it opened. Yes, I take advantage of gravity to lift the door. Fortunately, the synchronous motor is not exposed to the outside heat of the day. I have covered the whole chicken coop with a tarp to avoid my chickens to get over overexposed to the sun.

#### LowQCab

Joined Nov 6, 2012
1,321

What you are proposing is guaranteed to fail on a regular basis.
What you actually need is going to easily cost over ~$150.oo, and probably closer to ~$250.oo,
to create a reliable system that will not fail every ~3 to ~4 days.

A Synchronous-Motor from a Microwave-Oven is going to fail,
and it can't run in Reverse.
Using String to open the Door is going to fail.
Putting a Micro-Controller outside will guarantee rapid failure.

You need a Water-Proof, Screw-Drive, ~12/~24-Volts DC, Linear-Actuator,
with built-in Limit-Switches,
and with at least ~12" (~300mm) of travel.

Then the wiring is a simple job,
and, if you keep the Linear-Actuator well Greased and out of the weather,
it will probably work just fine, for around ~5-years or more.

Linear Actuator .......
https://www.amazon.com/dp/B077Q9P2GC/ref=emc_b_5_t

Power Supply .........
https://www.amazon.com/Pyramid-PS9K...a-923c-8152c45485fe&tag=ezvid-wiki-reviews-20

Relay .............
https://www.amazon.com/URBEST-Plast...eywords=dpdt+relay+120v&qid=1620861158&sr=8-6

Flood Light Photocell
https://www.amazon.com/Photoelectri...keywords=Photocell+120v&qid=1620861522&sr=8-8

If you can afford to buy these things, I will show you how to wire them together.
.
.
.

#### marcovlusa

Joined May 12, 2021
25
I forgot to mention in my first post that the rules I have to follow state that I have to recycle as much as material as possible, my budget should not go over \$150. For the chicken house, I used an old dog house. I've been testing the synchronous motor and it does reverses when it reaches the limit of time when actually it turns off because of the minute that has been programmed in the relay. When it starts again, the synchronous motor turns the other way its course.

#### Irving

Joined Jan 30, 2016
2,311
While @LowQCab is right from a formal engineering approach I rather like the Heath Robinson cobbled together approach. Yes, there are issues around the motor longevity but these are solvable in the long run.

The biggest issue with adding sunrise /sunset control to your project is the unreliability of a photocell with regard to weather.. An overcast day could confuse the whole thing. I don't know where you are, maybe overcast rainy days are rare where you are, in which case it could work. That aside, turning the motor on at sunrise and off at sunset isn't hard. It's the reverse of the unit I have for turning my driveway/porch lights on at dusk and off when it gets light.

If I understood correctly you open the door for 1 minute every 12 hours. So the door is not open during the day?

#### marcovlusa

Joined May 12, 2021
25
What I need is the motor to be turned on at sunrise for one minute to lift the chicken coop door. Then the door remains open the whole day. Then, I needed the motor to be turned on again to lower the chicken coop door. Then all night the door remains closed. The synchronous motor currently does it every 12 hours, but the chickens' nature need them to go out to free forage at sunrise and then they go to sleep at sunset. I'm currently in Southern California in the San Diego suburbs. The synchronous motor automatically reverses its way when it reaches a stop or when the electrical current is turned on. So, what I need is to learn how to wire a photocell to let the electricity run at dusk and dawn.

#### Irving

Joined Jan 30, 2016
2,311
I'm intrigued how the motor knows which way to go. So during the day the motor is a powered off but still holds the door up? Then in the evening when you apply power it winds the door down?

Tell me more about your motor controller, what is it? And what do the numbers on the display signify?

#### marcovlusa

Joined May 12, 2021
25
Well, the synchronous motor changes its course automatically all the way around when energy is cut out when it's forced to stop. As the door is hung from the motor rotation axis by a drapes cord, it takes one minute to lift the door or close it. The controllers is a relay that can be programmed to let electricity go to the synchronous motor for one minute every 12 hours. It lets you program it in tenths of a second, seconds and minutes. The numbers you see on the display are the remaining seconds to complete 12 hours. I took the pictures a few seconds after it opened the door in the morning. So, if you divide that figure by 60 and then the result by 60 again you'll get almost 12 hours.

#### marcovlusa

Joined May 12, 2021
25
Actually, first you have to multiply that figure by 10, then divide it by 60 and then 60 again. You'll get almost 12 hours.

#### Irving

Joined Jan 30, 2016
2,311
Ah OK. I had hoped it was a programmable controller of some description.

The difficulty as I see it is that there's no programmability in that device so a simple on/off photocell is of no use. You don't have anything to implement the conditional logic around the transitions dark-light and light-dark.

Does your timer have a trigger input? Can it time 1 minute on demand?

#### Irving

Joined Jan 30, 2016
2,311
Another issue, how do the chicken know when it's time to come inside? What happens if your system says it's sunset before they think it is?

#### marcovlusa

Joined May 12, 2021
25
Ah OK. I had hoped it was a programmable controller of some description.

The difficulty as I see it is that there's no programmability in that device so a simple on/off photocell is of no use. You don't have anything to implement the conditional logic around the transitions dark-light and light-dark.

Does your timer have a trigger input? Can it time 1 minute on demand?
Yes, the relay also can be triggered as well as programmed (as a timer, then it turns on the synchronous motor for one minute. After that minute has elapsed, the relay enters in a stopwatch mode for 12 hours.

#### marcovlusa

Joined May 12, 2021
25
Another issue, how do the chicken know when it's time to come inside? What happens if your system says it's sunset before they think it is?
Chickens are amazing. I've been watching them at sunset and the rooster starts walking towards the door followed by his flock, if it's opened, all of them get inside after him, but if the door is closed because of the 12 hours seeing in using now, all of them wait in line until I or someone else opens the door manually. I read they know their sleeping quarters are a safe place to be at night because of chicken predators mainly attack at night. During the day, roosters take care of their flock mainly watching for flying predators. If a hawk, for example, approaches y flock area, the roosters make a lot of noise and fight the bird even if their life may be lost.

#### Irving

Joined Jan 30, 2016
2,311
Wouldn't it be cool to give the rooster a button to peck to open the door? I wonder if he can be taught to do that?

Seriously though, I'm thinking that the 'sunset' closure needs to be some time after the actual sunset to allow time for the chickens to roost.

If your timer can be triggered, what is the electrical specification for the trigger input?

#### marcovlusa

Joined May 12, 2021
25
Your right! Actually, right now, the door closes just a few minutes after sunset. In that way I'm make sure all the chicken are already inside the sleeping area. Regarding the trigger input, I need to read they instructions carefully. Most of these circuits are made in China and the instructions, at least for this one, although are in English, the transition is not that accurate, but I'll let you know. I'll attach them here if you want to read them. Perhaps, you could help me decipher their English.

#### ericgibbs

Joined Jan 29, 2010
14,169
hi marco,
Post the Chinese specification.
E

#### Yaakov

Joined Jan 27, 2019
3,744
The problem with using a photosensitive detector to determine sunrise and sunset is that they don’t necessary correlate to the amount of light on the sensor.

If you don’t want to depend on a network connection to a source of local sunrise and sunset data, the alternative is a realtime clock (RTC) and a precalculated table of sunrise/set data for the location of the coop. Quite a few years of data could be compactly stored and a very small MCU would be enough to manage the whole thing.

#### Irving

Joined Jan 30, 2016
2,311
Yes, I was getting to that, but its a big step for Marco I suspect... plus I doubt the coop has an internet connection!

With a bit of leeway and given the location which generally has (I'm led to believe) reasonably constant weather a simple light detector should work (its useless here in UK!)