Arduino Forum

Using Arduino => Project Guidance => Topic started by: brhyaa729 on Nov 15, 2012, 09:07 pm

Title: CO Alarm
Post by: brhyaa729 on Nov 15, 2012, 09:07 pm
Hi guys... new to the forum and new to Arduino... ok I could have sworn I posted this around 3am but then I must be dreaming because for the life of me I can't find my post. I am trying to connect a motorcycle air horn (12 volts) to my Arduino so that when a carbon monoxide sensor variable exceeds a predefined level it sends an output signal to complete a 12v connection to the horn and sounds an alarm loud enough for the whole house to hear. I know I can't supply 12v from the board but can I use an H-Bridge I have to control a stepper motor (don't know the number off hand since I'm not at home at the moment). I also have a relay that came with the horn. Can I just use a relay without and voltage coming back into the Arduino and frying it or a combination of both? I'm sure I may need some resistors in there somewhere just not sure of the basic layout. Right now I haven't received the CO detector yet since it is coming from China and may get here some time next year lol ... however in the meantime I do have some photo resistors, pots etc to use as input devices to write the basic program. I will be glad to provide more specific information later when I have it available to me but if anyone can nudge me in the right direction working with the few items I have I would greatly appreciate it. Thank you!
Title: Re: CO Alarm
Post by: terryking228 on Nov 15, 2012, 09:13 pm
Hi, I'd seriously think about using optical isolation between the Arduino and the high-power stuff.

Could be relays like these:  http://goo.gl/3mXu0  (Also see the schematics on their pages)

Or do you own with opto-isolator chips. See http://arduino-info.wikispaces.com/Popular-ICs and scroll down to the Opto stuff...


DISCLAIMER: Mentioned stuff from my own shop...
Title: Re: CO Alarm
Post by: HazardsMind on Nov 15, 2012, 09:20 pm
Quote
I know I can't supply 12v from the board but can I use an H-Bridge I have to control a stepper motor (don't know the number off hand since I'm not at home at the moment).


Why would you do that? Just use a relay. Use the arduino to trigger the relay to pick, and have the 12V wired to the common and the other connetion to the horn.

Test with a simple button or something else, if you get a signal the horn should activate.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 15, 2012, 09:28 pm
Thanks Hazard ... that's why I said "I also have a relay that came with the horn. Can I just use a relay without and voltage coming back into the Arduino and frying it" in my first post... it's been ages since I've messed with electrical components but I do remember the purpose of a relay is to use a smaller current (and wiring) to send a signal to switch on a higher current. Just couldn't remember if the relay might have any kind of back flow to the board. So it's as simple as a pinout signal to the relay?
Title: Re: CO Alarm
Post by: HazardsMind on Nov 15, 2012, 09:53 pm
Yes it is that simple, just make sure you include a diode with that output, so that there is no back flow to the arduino.
Yes, there will be some back flow, because you are powering an induction coil and that can easily go back to the arduino if there is no protection.

Refer to this:
http://www.google.com/imgres?imgurl=http://www.rc-float-flying.rchomepage.com/Schieppati/relay.jpg&imgrefurl=http://www.rc-float-flying.rchomepage.com/Schieppati/switch.html&h=575&w=614&sz=61&tbnid=kHyZ81Sdu5HngM:&tbnh=90&tbnw=96&zoom=1&usg=___cJ8v52BkbNEl4q2jzvrmcH1C4Q=&docid=RG2MIHS9qpcXZM&hl=en&sa=X&ei=4FWlULWtHKTE0QGk_YGoCw&ved=0CEMQ9QEwAg&dur=0

WOW, that is a long one, sorry about that.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 15, 2012, 10:05 pm
I believe I have some Schottky diodes around here ... would they be sufficient?
I also have some http://www.datasheetcatalog.org/datasheet/diodes/ds28009.pdf
Title: Re: CO Alarm
Post by: DVDdoug on Nov 15, 2012, 10:49 pm
That diode will be fine.  It needs to have a Peak Reverse Voltage rating above the relay's coil voltage, and a Forward Current rating greater than the coil current.

In order to drive the relay directly from the Arduino, the relay coil voltage should be 5V (a 12V coil won't work) and the activation current (coil current) needs to be 40mA or less.

FYI - You don't need a microcontroller or programming if all you want to do is turn on/off an alarm based on the CO level.  ;)    Assuming the CO sensor has an analog output, you can use an op-amp as a comparator (http://www.radio-electronics.com/info/circuits/opamp_comparator/op_amp_comparator.php) and the same sort of driver/relay for the alarm.
Title: Re: CO Alarm
Post by: oric_dan on Nov 15, 2012, 11:01 pm
If you google "gas sensors", you'll find many places to buy in the USA. Figaro makes many, and has
data online.You'll probably also have a 10X better idea of what you actually have bought. If you're
really lucky, China might include a datasheet.

Title: Re: CO Alarm
Post by: brhyaa729 on Nov 15, 2012, 11:02 pm
Thanks guys for the help ... I know the really simple solution would be just buy a CO Detector on Amazon but that would take all the "fun" out of it lol .... thanks again.
Title: Re: CO Alarm
Post by: oric_dan on Nov 16, 2012, 12:10 am
If this is for your robot, then experimenting is fun.

Quote
haven't received the CO detector yet since it is coming from China


Gives me the willies.

If this is for your house, and you want to keep your family safe, you're better off going to Walmart or
Home Depot or the local hardware store, and buying an approved CO detector. I certainly wouldn't buy
something like this cut-rate from China for use in the baby's bedroom.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 16, 2012, 12:39 am
No, not for any "real" protection ... I have a propane heater I use in the garage once in a while and I am the only one out there tinkering. I never let it burn more than 10 mins and always leave the door up a few inches just to be sure. Just more of a "tinker" thing.
Title: Re: CO Alarm
Post by: oric_dan on Nov 16, 2012, 02:41 am
Since it's you, it's ok, but we don't want no babies with blue lips and finger nails around here.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 16, 2012, 11:27 am
Well between 1978 and now I've had 5 babies and have managed to not fry or gas any of them so I'm 0 in 5 in that category haha. I think it's great that you guys share your knowledge and we all enjoy "playing" with our Arduinos. Since I am new to this where do you guys prefer to order your parts? I'd like somewhere in the U.S.A. that is priced reasonably with fast shipping and good customer service. Of course I'd pay slightly more providing the last two criteria were exceptional.
Title: Re: CO Alarm
Post by: terryking228 on Nov 16, 2012, 03:02 pm
Quote
where do you guys prefer to order your parts?


As you mentioned you don't get good, fast and cheap at once...

Paying for DHL/FEDEX (about $17 for a physically small order) will get you fast (2 to 5 days) from China.  Some Ebay sellers will do it.

DISCLAIMER: Mentioning stuff from my own shop...!!  Leave now if you want :-)

I am trying to provide Good, Cheap (on-the-Shenzhen-Street prices) and Fast-If-You-Want with http://YourDuino.com  PLUS lots of How-To on the http://ArduinoInfo.Info WIKI.   Plus a live (if aged) Engineer who answers Customers's questions. I'm having fun, being very busy, and making a little money added to Social Security so I can buy my wife an Iphone for Christmas. Don't tell her!

Seriously, please critique the WIKI, suggest new topics, and pass the link along. It's at about 2000 hits a day, which motivates me to keep on adding to it.
Title: Re: CO Alarm
Post by: radman on Nov 16, 2012, 04:56 pm
I am a little off topic but, out of interest, how does a CO detector work?

I can figure out roughly how a smoke detector might work but telling the difference between CO and N2, O2, Ar, and CO2 seems like a neat trick.

Is is a chemical reaction, can the detector be used multiple times?
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 16, 2012, 05:23 pm
Ok guys I promise I will stop with the dumb questions... I have a 5 prong relay, I understand where the wires go except for the "trigger" from pin 12 on my Arduino ... using digitalWrite HIGH signal to activate the relay... where do I ground pin 12? To the 12v power supply? It seems if I ground to the Arduino it isn't a complete circuit. Please go easy on me I'm on my first cup of coffee. :-)
Title: Re: CO Alarm
Post by: HazardsMind on Nov 16, 2012, 05:42 pm
Put it to ground with a current limiting resistor, of say 3-5K ohms. If that is too much resistance, drop it to 1K.

Also as stated earlier, make sure you include a diode with that output, so that there is no back flow to the arduino.

DVDdoug also said,
Quote
It needs to have a Peak Reverse Voltage rating above the relay's coil voltage, and a Forward Current rating greater than the coil current.

Title: Re: CO Alarm
Post by: brhyaa729 on Nov 16, 2012, 06:19 pm
Thanks Hazard, I have a diode on the output .... I'll stick a resistor on the neg side... the neg of the external power supply, not the Arduino correct?
Title: Re: CO Alarm
Post by: HazardsMind on Nov 16, 2012, 06:22 pm
Wait!! If your triggering the relay with one of the pins from the arduino then you need to ground it from the arduino, unless both the external power supply and the arduino have a common ground, then it wont matter. But just in case they dont, ground it to the arduino.
Title: Re: CO Alarm
Post by: oric_dan on Nov 16, 2012, 06:40 pm
Quote
Since I am new to this where do you guys prefer to order your parts? I'd like somewhere in the U.S.A. that is priced reasonably with fast shipping and good customer service. Of course I'd pay slightly more providing the last two criteria were exceptional.


I buy most small parts from digikey.com, mouser.com, and jameco.com. All three have inexpensive Priority Mail
shipping that typically takes only 2 days. They also all carry a lot of Arduino stuff nowadays, especially jameco.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 02:37 am
OK I think I'm going to hold off on this for a bit until I have a better understanding of what I need to do. This relay I have is rated for 30 amps and the horn specs says it draws up to 18 amps. I think the optoisolator sounds like the best idea so far to avoid frying the Arduino. I just don't know where I can find one that would handle 18 amps. All the ones I'm seeing are rated much much lower than that.
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 02:45 am
As long as the arduino has its own reccomended power supply and the horn has it own power supply AND they both have a common ground; the arduino will not fry.
Title: Re: CO Alarm
Post by: oric_dan on Nov 18, 2012, 03:06 am
An 18-amp horn ought to wake up the neighborhood, "shoot, that darn guy is
gassing himself again!"
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 03:32 am
LOL good one... yeah it is VERY loud ... you'd think there was a semi in the house .... my electrical background is very poor it's been ages since school and I'm not even sure I know what a "common ground" is... the relay has 5 pins 30, 85,86, 87 and 87a (in the middle). Every article I read on relays tells me something different and then people post saying that the article is wrong, I have yet to find two articles that agree on which pin is what. From what I gather the 30 in the signal input for the Arudion and 85 and 86 are the coils pos/neg I'm using an old ATX power supply (the yellow and black wires, 12volts) to sound the horn. Don't know where to hook both grounds, one coming from the power supply should go to the horn, would I connect the 5v Arduino ground to the horn also? Forgive me for being so confused, just not sure how everything goes.
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 03:48 am
ok a "common ground" is when the ground pin from the arduino is connected to the ground wire on the horn.

Can you post a picture of the relay you have, top and bottom, also any part numbers on top.
Title: Re: CO Alarm
Post by: oric_dan on Nov 18, 2012, 04:39 am
5 pins likely means 3 pins for SPST contacts and 2 pins for coil. With a DMM, you can figure out
the connections in 30-sec. 10-20-50 ohms for the coil, short for the NC [normally closed]
contacts.

You will probably need a relay driver to interface with the Arduino,

http://www.google.com/search?num=10&hl=en&safe=off&site=imghp&tbm=isch&source=hp&biw=1012&bih=830&q=npn+relay+driver&oq=npn+relay+driver&gs_l=img.3...1777.5836.0.5961.16.7.0.9.9.0.119.620.6j1.7.0...0.0...1ac.1.eJ74_MOVo-c
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 04:47 am
Thanks Hazard, here are pictures of the relay... the horn is nothing special, just a pos/neg post on it. The specs are 18amps/12v.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 05:38 am
Thanks Dan, I have a DMM and checked the posts... I have 78 ohms between 85 and 86, and 2.5 ohms between 87a(center pin) and 30. 87 pin gives no reading with any combination of the others. So as I suspected 85 and 86 is the coil and I'm guessing 30 would be the 12v pos in and 87 would be the Arduino connection in the NC configuration.. when my code sends a HIGH signal to 87 it will complete the connection? Does this sound right? I take the ground from the ATX PS and connect it to my Arduino ground. I'm starting to understand but just afraid to connect it all and throw some juice into it lol.
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 06:22 am
ok on the top of the relay shows you what connections are what. 85 and 86 are the contacts to the coil, connect the diode to those two contacts. the other three are going to be for the horn. 87 and 87a are your SPDT (single pole, double throw) contacts. One is normally open meaning NO connection to the common contact (that is the 3rd contact of the 3 contacts), it should also be numbered (look on top). the other contact is your normally closed contact that IS connected to the relay when the relay is not in use, or not triggered by the coil.

It should say which contact is NO or NC on the top in the picture. You want the horn to only be triggered when you tell it to by the arduino, so you will wire it like this:
Code: [Select]

        NC o    o NO => to horn, other wire to ground (only triggered by ard)
            \
             o <==12V (common)
(Ard) coil o====o coil (ground)
           --|<|--  (diode)
Title: Re: CO Alarm
Post by: oric_dan on Nov 18, 2012, 06:33 am
Sorry I meant to say SPDT.

You seem to have the relay pinout wrong. It's right there on the case. Coil = 85-86, polarity probably
does not matter. Put the voltage source for the horn on pin 30 and the horn on pin 87.

Appears to take 14V on the coil to pull in the contacts [12V will likely work], and as mentioned last time,
you'll need a transistor driver, so see the link I gave.
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 06:42 am
Btw, it is kinda hard to see the information in the pictures even when double clicked. Their blurry
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 07:20 am
To  me it appears it is a dual outlet... in my mind the diagram indicates that if the horn is connected to either 85 or 86 and the Arduino to 87a (center prong) then when the relay receives the 5 volts from the Arduino it will pull the contact closed to complete the circuit for the coil on either 85 or 86. Just when I think I see what is going on I start looking at it from a different viewpoint ... I think I will splurge a few bucks on a couple of optoisolators that way I will know for a fact that I am keeping the 5v side completely away from the 12v side so I can afford a few screw ups and maybe learn something in the process. I've been doing ok with the Arduino sketches that lead me through step-by-step like a recipe but venturing into something like this is all new to me. Thank you guys for being so patient.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 07:21 am
Sorry about the picture quality... my daughters took my AA batteries out of the good camera (without telling me of course lol) so I had to use my cell phone.
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 07:33 am
The coil is what changes where the output is going. Wire it the same way I showed in my crudely made drawing. The output pin from the arduino is going to change the output from the relay to normally closed => normally open when a current is applied to the coil. The horn does NOT get wired to the coil contacts.

Can someone else post a video or better picture then mine that is wired with something like an LED.

87a is NC (not used)
87 is NO (horn)
30 is common (12v power supply for horn)
85 (ARD)
86 (ground)
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 07:54 am
Your relay:

            ___ (either 87 or 87a check)

(86) |   ___   |(85)

              |(30)

Hope this helps you understand your relay connections.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 09:05 am
           87 |

| 86     87a|      85 |

           30 |

87a (Center Prong) Reads 2 1/2 ohms with DMM.


     
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 18, 2012, 09:21 am
Thanks Hazard, I found this YouTube video -
http://www.youtube.com/watch?v=By8tbu4AqtA&feature=related

It actually matches my relay exactly and makes me see your previous explanation... it totally clicks now (pun intended) :-) Do I connect a ground wire from ARD AND the Horn to neg on the coil?
Title: Re: CO Alarm
Post by: HazardsMind on Nov 18, 2012, 03:00 pm
Yes
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 19, 2012, 01:24 am
Well guys I put some juice into it.... and.... I don't think 5 volts is going to drive the relay... I need a different relay or transistor. I put a 2N3904 in the equation and nothing. I did test the relay by putting the 12v PS to the coil terminals and it's clicking so it's a good relay. Now with my completely non-existent electrical background I need to figure out exactly which parts I need. The voltage on the relay says both the NO and the NC are 14 volts. Do they make relays that one is like 5 volts and the other is 12?
Title: Re: CO Alarm
Post by: HazardsMind on Nov 19, 2012, 02:07 am
It might take 14v to trigger the relay.
Title: Re: CO Alarm
Post by: brhyaa729 on Nov 19, 2012, 02:32 am
The voltage reading I get from my ATX PS wires indicates 12.7 volts on the DMM. I just found in my POP (pile of parts) a 2N4401. I "think" this may be enough to trigger the relay if I can figure out how to wire it. Looking at the specs for the 4401 it should handle up to 600ma from the ARD (which I've read it only takes about 200ma to trigger a relay) and the 4401 can handle up to 40v out which should definitely be enough power. Time to start probing with the DMM again ....