Hey all, I have something weird going on with a project I built this summer and I’m wondering if it’s related to the seasons changing… I built an automatic chicken coop door that opens and closes based on light levels and uses reed switches to determine the door status (open or closed) and to tell the motor when to start and stop. Lately and with increasing frequency, I’ve found that the door is not stopping at the open position as if the reed switch is not triggering the motor to stop. I’m considering changing out the top switch with a door switch from a refrigerator, but before go to all that trouble I thought I’d check with the experts first in case it is something else… hopefully simpler that doesn’t require me to take everything apart
I’ve noticed that the frequency of the issue is increasing lately and the temps are getting colder and days getting shorter as we head into winter so I thought maybe that might have something to do with it? Has anyone else ever heard of reed switches being affected by temperature?
Also, it only seems to happen at dawn, when the door opens to start the day… when I go to fix it, i just have to hold my hand over the photoresistor, dropping the door back down, remove my hand causing the door to raise back up and it stops where it’s supposed to every time. If I go out in the dark with a flashlight and go through the motions I get the same result, operates as expected every time… just that first stop in the morning that seems to be the problem… kind of like how your car never makes “that noise” when you have the mechanic standing there.
I thought maybe the switch components weren’t lined up well enough so I adjusted what I could and as far as I can tell they should be well within acceptable parameters, hence it working perfectly every time I’m standing out there fussing with it.
In case the issue is code related, I have attached a copy of the code I’m running and have commented out all the other parts to isolate the door operation… these are commented out on the Arduino board as well, many of these functions are still works in progress that I am stumbling through, but getting the door working flawlessly is priority number 1. I have also attached a diagram of the switch configuration in case that sheds any light… As far as the switches go, it’s pretty standard (I think), I have pull down resistors on both switches.
If the consensus is that I should replace the top switch with the fridge door switch and see if that resolves the issue, can anyone confirm that all I need to change in the code is the top switch values from 0 to 1 as the reed switch is normaly open and the fridge switch is normally closed?
Thanks so much for taking a look and your advice is always very much appreciated!
working_door_and_led.ino (21 KB)