Google Analytics

Monday, July 4, 2016

Security System - Local Alarm From Kit

As part of my Security System, I wanted to place an audible alarm near whatever sensor I'm using.

My sensors are going to be networked, feeding information to the main security control.  Currently I'm using a NodeMCU which makes use of a ESP8266's WiFi network capabilities.  This also means I can send a request, from the main security control, to turn on the alarm remotely, should I desire to do so, as its under the control of the ESP8266 device.

In this post, I'm not showing any type of sensor.  However, in most cases, I'll be using a PIR or a ultrasonic sensor to set the ESP8266 in alarm output for pin 5, and then enabling the local sensor alarm sound.  So, I'm just showing the alarm device and ESP8266 here.

Because the ESP8266 is a 3.3 vdc device, it can only supply 3.3 vdc and a limited amount of current; this wasn't enough to directly drive the audible alarm, so I've added a switching transistor to supply the switching current.

Scroll down for circuit description, construction, and construction photos.

In this post, I'm showing the use of a cheap commercial Window and Door Open/Closed Sensor Alarm, that I picked up for $1.00 at a local Dollar Store.  It contains a circuit board with:

  • square wave generator
  • battery holder
  • transformer
  • on/off switch
  • piezo electric speaker
  • 3 1.5 vdc batteries

I'm not making use of the magnetic switch in this post.  Instead, I'm making use of the audible piezo alarm (hereafter referred to as ALARM), when enabled by the NodeMCU device.

Circuit Description
In this design (software in a later post), the NodeMCU is driving pin 5 high to 3.3 VDC.  The output of this pin is connected to a 6.8K resistor, then to the base of a 2N3904 NPN transistor, which is biased as a switch.

The negative battery post of the ALARM has been separated from the ALARM circuit board, with the transistor inserted between the negative battery post and the circuit board, with the ALARM circuit board connected to the transistor's collector, and the negative terminal connected to the circuit common ground.

When a high value (3.3vdc) is applied to the base of the transistor, it turns on, basically connecting the circuit board through the transistor to ground - the ALARM sounds.

When a negative value (0vdc) is applied to the base of the transistor, it turns off, stopping current flowing from the collector to the emitter, so that the circuit is open, and no ALARM sounds.

Any 3.3vdc supply can be applied to the base to turn the transistor on - you don't have to use a NodeMCU.

If other voltages are used, such as a 5vdc from an Arduino, then you should resize the base resistor.

The 2N3904 has a beta of around 200 (varies somewhat), and is limited to 200ma and 625mwatts.

I wanted to restrict the current through the transistor to 100ma.

For 100ma at 3.3vdc and beta of 200, this equates to:
CollectorCurrent (Ic) = BaseCurrent(Ib) x Beta(200)
Ic = Ib x Beta
Ib = Ic / Beta
Ib = 100ma / 200
Ib = .5ma

Base Resistor (Br) = Vdc/ma
Br = 3.3/.5ma
Br = 6.6Kohm

While I'm showing 3.3 vdc above, a closer approximation would be 3.3 - .7 = 2.6 vdc, which includes the voltage drop across the base-emitter, which would yield about 76 ma instead of the 100 ma.  However, that's good enough for this circuit, and the 6.8K is close enough, and it sound loud enough for a local alert for me; the main security controller will driving the loud stuff.

The battery voltage of 4.5 (3x1.5)vdc is flowing from the ALARM's batteries, and is being switched via the transistor's base of 3.3vdc.

This ALARM can be used in any device with a small voltage to switch the transistor on and off, by making adjustments to the base resistor.  I've put one, with a much larger value resistor into a box, so I can use it as a beeper for simple circuit tests and continuity tests; the higher value resistor limits the sound!


Construction Pictures:

The device I bought for $1.00 at the local Dollar Store

The contents of the device: 3 1.5vdc batteries, a magnet, and the sensor/alarm/battery case.

Remove the battery cover, then remove the screw I'm pointing at in order to get into the back of the case.

After you've opened the case, this what it will look like.

Two board types in stock!  Both work the same for our purposes!  We are only using the red wire where it connects to the negative battery terminal post.

Newer Device Circuit Board - pointing at black blob.
While building the circuit, I realized there were two (2) versions of the device, both bought at the same time from the same Dollar Store.  This is the newer device, showing a 'black blob' where the square wave generator is located.

Older Device Circuit Board - pointing at discrete components.
This works the same as the newer board.

Unsolder the red wire from this junction - it is the negative battery post.  Leave the other end of the red wire still connected to the circuit board.  We will be inserting the transistor between this negative battery post and the red wire, so the transistor, in acting like a switch; allowing current to flow back to the negative battery post when transistor enabled, and no current when transistor disabled.

Connect a green wire to the negative batter post you just removed the red wire from above.  This will be connected to our circuit common.

Next we are going to connect a yellow wire to the red wire that was removed from the negative battery post previously.  So, solder it in already!  Our transistor will be going between this yellow wire and green wire.

This is how the circuit will function.  The green wire is connected to ground, the yellow wire is connected to the collector of the 2N3904 NPN transistor.  The emitter is connected to ground.  The base is connected to a 6.8K resistor, and then to the output pin 5 of the NodeMCU device, which will switch 0 - 3.3vdc.

There isn't anywhere in the ALARM case for the two new wires to pass, so I used my soldering iron to melt a small hole in the case, then put the wires in, and closed up the case.

Testing!  A simple test of just the wiring changes!
Before transistor and software are added to the circuit!

I've inserted the batteries (polarity as indicated in the battery compartment bottom), and made sure to slide the switch to 'On' position - it won't sound if you don't turn it on!

With everything on, and the two wires not connected, the ALARM should not be making an alarm sound.

With everything on, and shorting the yellow and green wires together, the ALARM should be making an alarm sound!

Circuit schematic.

Using the NodeMCU with software I created, testing.  High output from NodeMCU pin 5 (also showing on blue LED on NodeMCU) causes ALARM to sound alarm.

Using the NodeMCU with software I created, testing.  Low output from NodeMCU pin 5 (also showing no LED on NodeMCU) causes ALARM to not sound alarm.

I'll upload the software in a later, separate post.


No comments:

Post a Comment