Introduction: Manage a Wireless 120 DB Alarm Siren Using an Arduino Pro Mini 3.3V and NRF24L01+

This is a fairly low-cost wireless siren control module, managed by an Arduino Pro-Mini 3.3V. It accepts wireless commands to activate or deactivate the alarm via a wireless communications board, the nRF24L01+.

This siren is a 120db variety with a 3.5mm plug. It is VERY loud and has been tested at between 6 and 12V+, the loudness varies with the power to the siren. In the video, the first adapter is a 5.9V, 375mA version. That is then replaced with a 12V 9 Amp battery.

The control can be placed anywhere within the NRF's communications range. It can be hidden in a hard to reach place and although it could be powered via an AC adapter, it would most likely be battery driven. Who needs an alarm system that doesn't work when the AC power is cut?

This is a low power implementation of the Pro-Mini microcontroller, the LEDs are disabled, which will run close to 3 years on the battery chosen (3.7V LiPo, 5000 mAh).

It sleeps 96% of the time using only 52-55 uA of power during the sleep cycle, the nRF24L01 is also powered down during this time. The active cycle lasts less than a second and uses ~2mA during this period.

To achieve this low energy usage, there is a worst case delay equal to the Pro-Mini sleep cycle between an alarm trigger and the siren being activated or deactivated. The average delay would be half the sleep cycle. If the sleep cycle is 23 seconds, as is the test case here, the average delay would be in the 12 second range.

This delay is a tradeoff between battery utilization (battery life between recharges) and the level of responsiveness needed. Running a member of the NRF24L01+ family of boards in interrupt mode requires constant power and would empty the batteries in a matter of days.

If this board is to be active for short periods only, the sleep cycle can be adjusted to a very short duration and the trigger delay reduced accordingly.

The battery life calculation numbers for the 24 second sleep-cycle configuration:

(using 70% guideline and 5000mAh capacity rechargeable batteries

----- 55uA * 23 = 1,265 uA (23 second sleep cycle)

----- 2000uA * 1 = 2000 uA (1 second active cycle)

----- 3,265 uA divided by 24 seconds = 136 uA (power usage per second

----- (5000 * .7) mAh / 136 uA = 25,736 hours on LiPo

----- 25,736 / 24 hrs. = 1,072 days = ~2.90 years battery life

Lengthening the sleep cycle or using more powerful batteries means longer battery life.

Notes on Power Savings:

The Arduino Pro-Mini has two LEDs which I usually disable as they burn milliamps for no good reason. I use a sharp metal point to disable them both.

Notes onTesting:

Using a lower voltage source for the siren and wearing ear (hearing) protection is HIGHLY RECOMMENDED during testing.

Step 1: Parts List

Alarm Control Board & Siren

  • Arduino Pro Mini 3.3V/8 Mhz Board
  • MCP1703 250 mA, 16V Regulator
  1. 1 uF Cap
  2. 10uF Cap
  3. SOT223-3 Platine
  • NTD4906N Power MOSFET 30 V, 54 A, Single N−Channel or similar Low Gate Voltage Mosfet
  • 1N5818 Schottky Diode

----- 1K Ohm 1/4W Resistor

  • NRF24l01+ Wireless Transceiver

----- 4.7Uf Cap

  • DC Power Jacks Barrel Connectors (2)
  • 3.5 mm Audio Jack
  • Platine 80 mm x 52 mm 35 µm (2.54 mm)
  • 88 x 58 x 30 Case
  • 120 dB Siren
  • Header Female 8PS (For NRF24 plugin to PCB)

Programming Support

  • FT232RL FTDI USB to TTL Serial Converter Adapter
  • USB to mini USB Cable
  • 6 * 10 or 20cm Female to Female Dupont Jumper Cables

Batteries

  • 3.7V LiPo (I use a 5000 mAh)
  • ~12V ( For a LOUD Siren, I used a 9Amp 12v Sealed here)
  • 6, 9, or 12V AC-DC Adapter for testing

Step 2: The Schematic:

There are two barrel power connectors.

The first is the power for the microcontroller board itself; this drives the MCP1703 which provides regulated (3.3V) power to both the Arduino Pro-Mini and the nRF24L01+. The built-in power regulator on the Pro-mini is not used as the 1703 regulated output is provided to the VCC pin instead.

The second barrel connector provides the power to drive the Siren that is plugged into the 3.5 mm Jack.

This is no overvoltage protection on either of the input jacks. Both the MCP1703 and the Siren are rated at 16V or less, so switching up the connectors should not cause a major problem. The siren used here will not work with less than 6V and the MCP1703 will get hot at higher (9V+) voltages.

Connecting with over 16V on either barrel connector could result in smoke so if this is a real possibility in your configuration, some type of overvoltage protection should be added.

The main power input for the first barrel jack should be 3.35V or higher (above I show it with a 3.7 LiPo) as there is some voltage drop by the MCP1703.3302. The NRF24 wireless boards can be unreliable if they are underpowered. Depending on the model, the NRFs can draw up to 145 mA (the LNA version), hence the 250 mA low-drop, low quiescent 1703 regulator used here.

The siren is controlled via a logic level “Power Mosfet”, here the NTD4906N, with a 3.3V or 0V signal on the Gate from one of the Arduino digital pins (here D4). The D4 pin is pulled to ground via a 1K Ohm resistor for when the port is set to low, i.e. the Mosfet is "turned off". The 3.3V signal when set to HIGH is more than enough to drive the Mosfet into saturation. ~2.2 V is required for full saturation of the Mosfet.

When the D4 pin goes HIGH, the Mosfet "turns-on", GND is connected to the 3.5 Jack and the Siren is activated. When the pin goes LOW, GND is disconnected and the Siren is deactivated.

The 3.5 mm Audio Jack is enveloped by a 1N5818 diode to protect against any voltage spikes on the inductive load switching (siren on/off).

Step 3: The Siren Control

Other sensors such as sonar (distance/motion), sound, temperature/humidity, PIR, magnetic, Gas, light or dark detectors, etc. can either directly communicate with the siren control via the NRF24 board and direct message addressing or a central gateway could be used.

There could be multiple sirens in different locations with reception distance from gateway or sensors controlled by the variation of the NRF24L01+ board used and transmission blockages (thick walls, etc.) that may or may not exist in the system layout. (More on this is discussed later in the sections that follow). Remember to change the ID for each siren controller.

I have tested at 100 meters using a low-power implementation of the PA+LNA version of the NRF24L01+ without problem, and this was going through an environment with walls and other direct-sight blockages.

Obstructions between the transmitting antenna (Sensor, Central Station) and the receiving antenna (Siren Control) will tend to block the signal at longer distances.

Step 4: Pro Mini Programming Set Up

To program the Pro Mini, I use an FT232RL FTDI USB to TTL Serial Converter Adapter, some Female to Female Dupont Jumper cables and a USB to mini USB cable.

I normally solder straight pins (as pictured above) to the Pro-mini programming header to make it easier to program or re-program the Arduino after it has been bread boarded or installed on a PCB.

The FTDI board is connected to the Pro Mini using the Female to Female Jumper cables, and then the FTDI is connected to my laptop via the USB to mini-USB cable.

The connections to make between the FTDI FT232RL and the Pro Mini are:

  • GND --> GND
  • CTS --> GND
  • VCC --> VCC
  • TXD --> RXD
  • RXD --> TXD
  • DTR --> DTR

I usually use one of the longer USB to mini-USB cables, rather than the really short ones you often see advertised on the online sites. The longer cables simply give more room to work and the short ones can sometimes be frustrating to use.

Step 5: Siren Manager Code Overview & Download

Libraries Used

Low Power Library

Supports all sleeping mode of ATmega328P and has selectable sleep duration:

  • 15 ms, 30 ms, 60 ms, 120 ms, 250 ms, 500 ms, 1 s, 2 s, 4 s, 8 s
  • Idle
  • ADC reduction mode
  • Power save
  • Power down
  • Standby
  • Extended standby

nRF24L01+ Library and Docs

This is an Arduino NRF24 library. It provides an object-oriented interface for sending and receiving data messages with Nordic nRF24L01 based radio modules.

Guide on how to install Arduino libraries can be found here.

Arduino sketch..

Step 6: Globals (Code Section Explained)

Code Explanation

  • #include "SPI.h"
  • #include "nRF24L01.h"
  • #include "RF24.h"
  • #include "LowPower.h"

These are libraries used in the sketch. The links to these libraries are in the preceding section. Instructions on how to install these libraries can be found here.

int loops = 3;

The Arduino spends most its time sleeping. It powers down for an 8 second period, this is the maximum time slice the "Low Power" library supports. The Loops variable is the number of times we will use that time slice before checking on any incoming messages and reacting to whatever command we receive. (3 loops = 24 seconds)

int myID = 3;

When we receive a message from the NRF, we verify that the command we read is actually for this device.

int MosfetGate = 4;

This is the digital port of the Arduino the Mosfet is connected to. The Mosfet controls the siren.

bool AlarmState= false;

A boolean variable to store the current state of the siren.

int measures[3];

This is a simple message buffer. The first integer is the message address; the next two are for control variables or data.

#define CE_PIN 9

#define CSN_PIN 10

Here we are defining the CSN (chip select pin) and the CE (chip enable) pins to be used by the NRF24L01+ library. If you used other pins, here is where you set them.

const uint64_t pipes[2] = { 0xE8E8F0F0E1LL, 0xE8E8F0F0E5LL };

Define the pipe addresses used in communications, here pipe[0] is set up to be the address of a central gateway. If you are not using one, you can ignore this. The Second address is this controller. This is the pipe that will be read when calling "radio.read".

Step 7: Setup() (Code Section Explained)

Code Explanation

The setup() function is run when the Arduino starts up or is reset.

pinMode(MosfetGate, OUTPUT);

digitalWrite(MosfetGate, LOW);

Define the Mosfet control pin as Output only and initialize it to OFF so that the siren does activate on start up.

radio.begin();

Start the radio, the NRF24.

radio.setDataRate(RF24_250KBPS);

Here I am setting the data rate to the lowest setting for the maximum distance.

radio.setPayloadSize(8);

This library uses a pre-established fixed payload size for all transmissions. If this method is never called, the driver will always transmit the maximum payload size (32 bytes), no matter how much was sent to write(). This improves performance and reliability.

radio.openWritingPipe(pipes[0]);

I use this to write status to a central gateway. If you are not using one, this can be commented out.

radio.openReadingPipe(1, pipes[1]);

Open the reading pipe.

radio.startListening();

Start listening for messages.

radio.powerDown();

Power down the radio. This is to save battery power as the radio will eat milliamps while powered up.

checkMessages();

Check to see if we have received any messages and then process. This is done here so that we do not go through the sleep in the main loop before we check for messages the first time.

Step 8: Loop() (Code Section Explained)

Code Explanation

Once the setup() function has run and initialized all as required, the loop is entered. The code within the loop is endlessly repeated.

if(AlarmState)

{

digitalWrite(MosfetGate, HIGH);

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

digitalWrite(MosfetGate, LOW);

In the beginning of the loop we check the current state of the siren with the global variable AlarmState. If AlarmState is True, we turn on the siren and enter the "Low Power" state for 8 seconds. After the 8 seconds, or when AlarmStateis False, we reset the MosfetGate to LOW.

for (int i = 0; i < loops; ++i)

{

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

After setting or resetting the Siren, we drop into the Low Power loop. Here we will sleep for the defined time slice for the defined number of loops. Here 8 seconds is the time slice and with the loops variable defined as 3, we basically enter a 24 second "Low Power" state where the Arduino will use minimum power or close to that.

checkMessages();

Once we come out of the "Low Power" loop, we check to see if we have received any commands and handle them.

Step 9: CheckMessages (Code Section Explained)

Code Explanation

CheckMessages is responsible for checking for any incoming messages, reading them, and changing the AlarmState variable and/or the amount of time spent in Low Power mode.

radio.powerUp();

The first thing to do is to power up the NRF board. A short delay gives it time to initialize.

// Begin - Broadcast Status to gateway

radio.stopListening();
delay(10);

measures[0] = myId;
measures[1] = (int)((loops * 8) * 100);

int state = AlarmState ? 1 : 0;

measures[2] = state * 100;

radio.write( measures, sizeof(measures) );
delay(5);

// End - Broadcast Status to gateway

This section of the routine broadcasts the current state of the Siren Control to any listeners, normally a central gateway or a controller. If there is not such Gateway in your layout, this section can be commented out or deleted. Before you can "write" a message out on the NRF, you must tell it to stop listening for incoming messages. After initializing the message, the message is written to the pipe defined in the setup() routine.


radio.startListening();

unsigned long started_waiting_at = millis();

bool timeout = false;

while ( ! radio.available() && ! timeout )

if (millis() - started_waiting_at > 850 ) // Wait 850 Milliseconds before timeout

timeout = true;

After writing the current status to the write pipe, reset the radio to listening so that we can check for any incoming commands. The radio is checked to see if there is anything to read with a timeout of 850 milliseconds. If there is a message, timeout is false, it there is no message present, the timeout variable if set to true.

if (!timeout)
{

radio.read(&measures, sizeof(measures));

int id = measures[0];

int timeout = measures[1];

int newSet = measures[2];

radio.startListening();

AlarmState = (newSet == 1) ? true : false;

}

If there is no timeout, then we have a message so go ahead and read in into the messages array. Read the values and load them into local variables. Reset the AlarmState variable according to the command received.

radio.powerDown();

Finally, power down the radio and exit the routine.

Step 10: References

Comments

About This Instructable

1,809views

23favorites

License:

Bio: Retired tinkerer, programmer ...
More by GSink:An nRF24L01+ and FTDI Ready Atmega 328P-PU (3.3V, 500 mA) Microcontroller with Dual Power Capability, Undervoltage, Hysteresis, and Thyristor-Crowbar Overvoltage ProtectionVoltage Clamp for Arduino using Zener Diode, PTC, and an NPN TransistorManage a Wireless 120 dB Alarm Siren using an Arduino Pro Mini 3.3V and nRF24L01+
Add instructable to: