I made an arduino-powered doorbell for certain reasons (a couple pics attached). The power source is the existing 24vac supply that was already there, going through a diode and then a voltage regulator like an LM2596. The two doorbell buttons are connected to two analog inputs and there is a third common wire that is connected to ground. The output uses a relay that then puts the same 24vac power through an old-fashioned bell. So far it works as it should...except:
There are two switches in the house (one is a ceiling fan on the opposite end of the house, and the other is a fluorescent ceiling light very near to the doorbell) that, very rarely, trigger the doorbell when I switch them on. Of course, this causes dogs to bark, and is especially unnerving when it happens late at night when I turn the bedroom ceiling fan on. It has happened about 10 times in a year, so it's very rare, and impossible to reproduce on demand.
I don't know enough about electronics to understand exactly what is causing this, but something tells me it's just interference and maybe I have the wrong value resistor across the analog input and ground terminals on the Arduino. Checking now, I see they are not the same: one is 130 ohm and the other is 330 ohm.
I'd really appreciate any thought or input as I try to better understand these resistors, their purpose, and whether I am also doing some things wrong in my approach (the use of the same power supply for both the arduino and the job it's doing, for example).
I was hoping that one of your pictures was showing a schematic of how you have everything wired together, but, sigh, that is not the case. Sorry can't help without a schematic.
Please read the post at the start of any forum , entitled "How to use this Forum".
OR http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
How have you got your door switches wired and how long is the wiring?
Have you got bypass capacitors fitted to the input circuit?
Without a real schematic I only have questions... how are the button wires run? What’s the voltage they are running? 5v? 24v?
You ran 24VAC through a diode into a DC-DC converter? Which I don’t even see connected.
The two resistor values you show are 100 and 330
Again without clear schematics it’s impossible to help.
What are the white wires with black markings going to the 5v pin?
None of this stuff makes much sense, I suspect a few issues but again without a good circuit diagram we would only be guessing. If you really want to fix the issue we need to look over the entire system no magic solution without it.
I’m surprised this actually works from what I can make out.
I'm not sure how to prepare a schematic -- never done that. Any suggestions for a good way for a beginner to make one? The photo is pretty complicated to look at and I can see why it would be confusing. There is a bunch of stuff there just for fun -- the 10 segment LED, the bell and the bright LED are just extras and were for learning purposes only.
I think the issue is related to my pulldown resistors. I don't know what the appropriate values for those is, but I should just research that issue first and find out if I'm on the right track or not.
@wolframore, the DC-DC converter is visible in the photo. The input is on the right side and the output on the left. There's a diode and capacitor near the input. I probably didn't do that part correctly -- it seems like I need more than a simple diode.
Thanks a lot for taking the time to read this. I'll do some further research on my own.
The safest way (no 5volt to the switch) of wiring a switch to an Arduino is between Pin and ground.
With pull UP to VCC (5volt for a 5volt Arduino).
You can enable internal pull up with pinMode,
pinMode(buttonPin, INPUT_PULLUP);
but that weak pull up current might not be enough with long wires (aerials) between button and Arduino.
You can replace (or complement) that pull up with an external pull up resistor, say 1k.
Remember that logic is now reversed
if (digitalRead(buttonPin) == LOW) // if button is pressed
Add a 100n ceramic cap between pin and ground (close to the Arduino) if interference is present.
That shorts any RF/spikes on the button wires to ground.
Shielded, or twisted pair (CAT-5/6) also helps.
I see you have connected the supply to the V-in pin.
V-in of an official Micro is specified for 7-12volt (6volt minimum).
If your DC/DC converter outputs 5volt, then connect it to the 5volt pin.
Leo..
Thank you, @Wawa! That's so helpful! Funny, I've been reading about using input_pullup. Should I use a digital input or analog?
I read that there is an option to use an internal pullup resistor. Does your solution incorporate that? How can I test to out if I need to complement the resistor due to long wires? They're the old doorbell wires that are built into the house, so I can't change them, though the twisted pair suggestion is great for future projects. I'm using the LM2596 and it's set to about 9 volts.
I'm going to play with this tomorrow and see if I can make it work.
fionaellie:
I've been reading about using input_pullup. Should I use a digital input or analog?
Analogue pins are just digital pins with the added functionality of analogue-in.
pinMode(12, INPUT_PULLUP); // this works for digital pin 12
pinMode(A0, INPUT_PULLUP); // this works too, for analogue pin A0
Add that external resistor with old house wiring, but the 100n cap is definitely needed to kill that interference.
9volt on V-in is fine, but
if you set the DC/DC converter to 5volt, and connect it to the 5volt pin, then you can also power the relay module from that 5volt rail.
Leo..