Case Study: Building a Smart Security System With Arduino (And Why You Might Want a Pro

by Chanchaldada in Circuits > Arduino

27 Views, 0 Favorites, 0 Comments

Case Study: Building a Smart Security System With Arduino (And Why You Might Want a Pro

2d1d7a28-caf2-4442-ad2a-0895416fca72 (1).jpg

Look, we love Arduino. It’s the gateway drug of embedded systems. You can prototype a smart lock, a motion detector, or a temperature logger in an afternoon with a few jumper wires and a cup of coffee.


But there’s a gap between “it works on my desk” and “it works reliably in someone’s home for three years straight.”


A client came to us last year with exactly this problem. They had a working Arduino-based security system prototype. It detected motion, sent alerts, and locked a door. But it crashed every 48 hours, drained batteries in two days, and the Wi-Fi kept dropping. They needed an arduino programmer for hire who could take their breadboard concept and turn it into a shippable product.

Supplies

Arduino Nano

Reed switch

PIR sensor

Piezo buzzer

LED (red/green)

LiPo battery

TP4056 charger module

Keypad

Relay module

PCB (2-layer, HASL)

Passive components | Resistors, caps, diodes


Auditing the Prototype

2d1d7a28-caf2-4442-ad2a-0895416fca72 (1).jpg

The client’s original build used an Arduino Uno, an HC-SR501 PIR motion sensor, a cheap relay module, and an ESP8266 for Wi-Fi. All powered by a 9V battery.

Problems we spotted immediately:

- The Uno draws 50mA even when idle. With a 500mAh 9V, that’s ~10 hours of life.

- The ESP8266 peaks at 300mA during Wi-Fi transmission. The Uno’s voltage regulator couldn’t handle it cleanly.

- The PIR sensor had a 3-second re-trigger delay — someone could walk past and the system would miss them.

We didn’t throw away the Arduino ecosystem. We just swapped the hardware for something that wouldn’t die.


Choosing the Right Brain

6405629_25689 (1).jpg

We replaced the Uno with an Arduino Nano 33 BLE Sense. Why?

- It has a built-in nRF52840 chip — ARM Cortex-M4 with BLE 5.0, low power sleep modes (2.5µA), and enough GPIO for our sensors.

- It runs on 3.3V logic, which matches the PIR sensor and relay perfectly.

- We could ditch the ESP8266 entirely — the Nano has onboard BLE, so alerts go straight to a paired phone.

For the client, this meant one less module to fail, one less power draw, and a smaller PCB footprint.


Motion Detection That Actually Works

The HC-SR501 is fine for a garage light. It’s not fine for a security system. Its analog output triggers on any IR change — pets, sunlight through a window, a heating vent turning on.

We switched to the Panasonic EKMB series (EKMB1107111). This is a pyroelectric sensor specifically designed for security. It has a digital output with adjustable hold time (1–30 seconds) and a noise immunity filter. False triggers dropped from ~5 per day to zero over our two-week test.

We also added a BH1750 ambient light sensor (I2C). If the room is bright enough, the system assumes someone is home and disables motion alerts. Simple logic, huge battery savings.


Power Management — the Hard Part

arduino monotoring (1).jpg

This is where most hobbyist builds fail. We designed a two-tier power strategy:

- Active mode: The system runs at 16MHz, BLE is connected, and the sensor is polled every 100ms. Current: ~15mA.

- Sleep mode: Nano enters deep sleep, BLE disconnects, PIR sensor goes into standby. Current: ~6µA.

We used a TP4056 charging module with a 2000mAh LiPo battery. The TP4056 handles over-discharge protection (cuts power at 3.0V to save the battery). We also added a MOSFET switch (IRLZ44N) to physically disconnect the relay coil when not in use — the relay itself draws 70mA, which is unacceptable in sleep.

Result: 3–4 weeks of battery life with daily motion events. The client was thrilled.


Firmware That Doesn’t Crash

The original prototype had a bug in the main loop: it checked Wi-Fi status, sent an HTTP request, waited for a response, then checked the sensor. If Wi-Fi disconnected mid-request, the code hung.

We rewrote the firmware using FreeRTOS tasks (the Nano 33 BLE supports it via the Arduino core):

- Task 1: Poll PIR sensor every 50ms. If triggered, set a flag.

- Task 2: Check flag. If set, send BLE notification to phone. Non-blocking.

- Task 3: Every 60 seconds, read battery voltage via ADC. If below 3.4V, send low battery alert.

We also added a watchdog timer (WDT) — if any task hangs for more than 8 seconds, the chip resets automatically. No more 48-hour crashes.


Enclosure and Assembly

A security system needs to look like it belongs in a home, not a lab. We designed a 3D-printed enclosure in Fusion 360 with:

- A Fresnel lens window for the PIR sensor (improves detection angle to 110°)

- A magnetic backplate for wall mounting

- A small LED window for status (blue = armed, red = alarm, green = charging)

We used PLA filament because it’s cheap and easy to iterate. For production, we’d switch to ABS or polycarbonate.

The PCB was designed in KiCad — single-sided, 2-layer board with all components soldered by hand for the prototype run. We shipped 10 units to the client for beta testing.


What We Learned

Don’t trust breadboard connections. A loose jumper wire caused a false alarm during testing. We switched to screw terminals for all power connections.

- Test the battery curve. LiPo voltage drops fast below 3.6V. Our low battery alert at 3.4V gave users about 8 hours of warning — not enough. We moved it to 3.6V.

- BLE range matters. The Nano 33 BLE’s internal antenna works fine at 10 meters. Through two walls, it drops to 3 meters. We added an external 2.4GHz antenna (u.FL connector) for the final design.