Go Down

Topic: does temperature affect reed switch operation? (Read 10817 times) previous topic - next topic

jbaich

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.  :smiley-confuse:

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!

Cheers,
Joe

Wawa

Are you sure they are reed switches, and not micro switches.
Micro switches are unreliable.
Reed switches (magnets on the door) are fully sealed, so are not affected by temp/moisture.
Leo..

Paul_KD7HB

How are the connections to the reed switches made? Clamped, soldered, etc?

Paul

Wawa

Alarm systems use reed switches on doors/windows for a reason.
Leo..

Archibald

#4
Nov 23, 2016, 02:23 pm Last Edit: Nov 23, 2016, 02:24 pm by Archibald
See https://www.arduino.cc/en/Reference/PinMode and use INPUT_PULLUP.

What is the purpose of the resistors in series with the reed switches?


jbaich

Hey all, thanks for the replies! I'm pretty sure they are reed switches, they are crimped to arduino pin connectors (I picked up a kit of headers and pins for my project)... then I soldered the resistors to a little piece of circuit board with the header connections... The resistors were recommended by others on this forum when I was asking questions during the design phase in order to prevent unintended activation of the switches from residual electricity in the circuit or something? In case you can't tell, I'm a beginner, this is my first project, and I am learning as I go with no background in electronics AT ALL :)

Would you suggest I bypass the resistors and see if there's any change? So far I've had no issues with the bottom switch, only the top one... I've also replaced it once already in case it was faulty with another reed switch (tested and worked 100% with tests before install).

Also, if I understand correctly, there are built in resistors on the mega that are activated so would these additional resistors be redundant?

Thanks,
Joe

gpsmikey

Especially with something like a chicken coop door that you are running into some sort of alignment issue.  The door (typically a wood frame) is going to change shape etc. with temperature and humidity (to say nothing of the coop itself changing slightly with temp and humidity).  I have used reed switches for a number of different projects and never had an issue with temperature causing problems (although never worked with them at -40F either).  When you indicate the bottom works and the top has problems, that would be consistent with the door sagging or changing shape slightly (us older people can tell you - gravity always wins  :o   )
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3

Paul_KD7HB

When circuit performance changes with temperature, the cause can be only one thing: cold solder joints. Using a HOT soldering iron remelt the solder on ALL the exposed connections and see if that corrects the problem.

Temperature sensitive circuits are debugged using heat guns and spray cans with liquid that quickly evaporates and cools the circuit. You have exactly the same symptoms!

Paul

jbaich

Thanks guys, I don't think it's an alignment issue... the door is made of acrylic and the rails or channels are aluminum so besides the little bit of play that I left in on purpose to make sure it didn't bind up anywhere, it's pretty solid...

The only solder joints I have (on the switch circuits) are at the resistors... can anyone confirm if these resistors are correct or necessary?

See https://www.arduino.cc/en/Reference/PinMode and use INPUT_PULLUP.

What is the purpose of the resistors in series with the reed switches?


so you're saying change from:

// top switch
  pinMode(topSwitchPin, INPUT);                    // set top switch pin as input
  digitalWrite(topSwitchPin, HIGH);                // activate top switch resistor


to:

// top switch
  pinMode(topSwitchPin, INPUT_PULLUP);                    // set top switch pin as input
  digitalWrite(topSwitchPin, HIGH);                // activate top switch resistor

and get rid of the resistors? because I have just enabled the internal resistors and no longer need external resistors?

Thanks,
joe

Paul_KD7HB

Once again, how are the reed switches connected? Soldered or clamped?

Paul

jbaich

Hey Paul, I can take a photo tonight when I get home if that helps...

... they are crimped to male Arduino pin connectors (I picked up a kit of headers and pins for my project)... then I soldered the resistors to a little piece of circuit board with the female header connections...
I'm not sure how else to describe it...

Thanks,
joe

Paul_KD7HB

Crimped makes them suspect when weather is involved. I don't suppose you can get to the crimped part and give them a good squeeze with pliers. Probably too late to solder them, but you could try, if you can get needle nose pliers between the crimp and the glass enclosure so you can keep the heat from the glass.

Paul

Archibald

#12
Nov 23, 2016, 07:05 pm Last Edit: Nov 23, 2016, 07:08 pm by Archibald
so you're saying change from:

// top switch
  pinMode(topSwitchPin, INPUT);                    // set top switch pin as input
  digitalWrite(topSwitchPin, HIGH);                // activate top switch resistor

to:

// top switch
  pinMode(topSwitchPin, INPUT_PULLUP);                    // set top switch pin as input
  digitalWrite(topSwitchPin, HIGH);                // activate top switch resistor

and get rid of the resistors? because I have just enabled the internal resistors and no longer need external resistors?
From what I understand from the information you have provided, when a reed switch is open the Arduino input is floating, in other words not connected to anything.  If so it is surprising your set-up is working at all.

I note the Arduino tutorial on Digital Pins says:
Quote
Prior to Arduino 1.0.1, it was possible to configure the internal pull-ups in the following manner:

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors
Now the way to configure the internal pull-ups is simply:
pinMode(topSwitchPin,INPUT_PULLUP);

Your resistors are in series with your reed switches; they are not pull-up resistors.

jbaich

I've attached a little diagram of how the switch is assembled. (I don't know how people have been able to embed images into this part of the message, but I'd love to know!)

If I understand what Archibald is saying, it's that I can change the code to pinMode(topSwitchPin,INPUT_PULLUP), I no longer need " digitalWrite(topSwitchPin, HIGH);", and I can get rid of these external resistors entirely?

Thanks,
Joe

Archibald

#14
Nov 23, 2016, 07:32 pm Last Edit: Nov 23, 2016, 07:34 pm by Archibald
If I understand what Archibald is saying, it's that I can change the code to pinMode(topSwitchPin,INPUT_PULLUP), I no longer need " digitalWrite(topSwitchPin, HIGH);", and I can get rid of these external resistors entirely?
Yes, you need a pull-up resistor between each Arduino input and +5V.  You can activate the internal pull-up resistors within the Arduino integrated circuit or you can provide external resistors.

The code:
digitalWrite(topSwitchPin, HIGH);
is not necessary.

Go Up