How are speakers wired with a microcontrollers?

hello,

I am currently working on a project where I will measure the temperature, then if the temperature is above a certain temperature, blare a siren.

I'm thinking this siren:

http://www.mouser.com/ds/2/252/MSE14LSN2-594880.pdf

Can I just use a relay breakout board with a 5volt coil, then on the load side run 12v to the speaker, controlled by the relay.

(example relay board)

also, if I wanted to get rid of the relay, could I use a mosfet instead?

Yes you can use a MOS FET to drive the sonalert directly.
Use a logic MOS FET.

.

For buzzers and sirens that is all you have to do. For speakers, you need an analog signal and probably an amplifier

Thank you for your responses

I am not too familiar with mosfets.

would this mosfet work with a 3.3v signal and 12v source??

http://www.mouser.com/ds/2/389/DM00091903-766492.pdf

vds 30v
vgs 20v
gate threashold 1-2.5v
Ids 105a

also, I looking at the datasheet, and it looks like pin one is the signal wire (3.3v), pin two goes too the horns ground, and pin three goes to common ground. Then I need a pull down resistor between pin one and ground and a diode between the horns ground and power.

correct?

is that correct?

Yes, that MOSFET looks appropriate for 3.3V gate voltage.

I would put a 220R between Arduino output and MOSFET gate to snub the inrush caused by the gate capacitance.

Does this look correct for the wiring of the mosfet? I will connect the horn to +12v and HORN(-) on the schematic. GPIO14 will be 3.3v when i want the horn ON, and 0v when i want the horn Off.

This is the mosfet
http://www.mouser.com/ds/2/389/DM00091903-766492.pdf

It's a minor point but R8 is on the wrong side of R9. R8 is there to pull down the GPIO in reset; that problem belongs to the MCU, not the FET, so the resistor needs to be on the MCU, not the FET.

Thank you. I will make the correction.

Paul__B:
It's a minor point but R8 is on the wrong side of R9. R8 is there to pull down the GPIO in reset; that problem belongs to the MCU, not the FET, so the resistor needs to be on the MCU, not the FET.

"R8 is there to pull down the GPIO in reset"

I always thought the purpose was to turn off the MOS FET during the floating condition of the GPIO pin at reset.

.

Yes, because the GPIO is floating.

It is the GPIO that "does" the floating, not the MOSFET, so it is the GPIO that you need to pull down. :grinning:

It may not matter much - 2% loss of turn-on voltage with these component values, but it is just sensible design to make things as efficient as possible. :roll_eyes:

Point of interest, if the MOS FET and the controller were on two separate PCBs (connected by wires), where would be the best place for R8 and R9.

I would suggest R8 on the controller PCB (to prevent accidental output pin to ground shorting) and R9 on the FET PCB (to ensure turn off if cable opens).
What do you think?
.

Two resistors :slight_smile:

A 10k on the MCU side, and a 100k on the mosfet side.
Leo..

LarryD:
Point of interest, if the MOS FET and the controller were on two separate PCBs (connected by wires), where would be the best place for R8 and R9.

I would suggest R8 on the controller PCB (to prevent accidental output pin to ground shorting) and R9 on the FET PCB (to ensure turn off if cable opens).
What do you think?
.

+1
Otherwise, it makes little difference which side of the 220 ohm the 10K pull down is on. The voltage swings that this circuit is designed for, swamp out the difference. The actual difference with the FET turned on, at the drain, would probably be difficult to measure. But it is true, to present a nearly identical voltage on the FET gate as is on the digital output, the 10K would have to be on the digital output side of the 220 ohm.

I would put them both on the MOSFET PCB. That way if the PCB is disconnected and being handled, any static electric charge on the gate is discharged. It is surprisingly easy to put 100V static onto a bare gate pin.

If these two PCBs are mounted in different boxes, then additional protection resistors on the Arduino side may be indicated. It is too easy to brush the wrong pin with a 12V battery connector.