Skip to main content
Version: ACS CC

Laser Alarm System

Check out for intruders. Or your noisy kids. Or both.

info

Author: Ștefan Adrian Brai
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-StefanBrai

Description

This project implements a security system where a continuous laser beam is emitted toward a photo-sensor. If the beam is interrupted, the system sounds an alarm and pushes a notification to the user’s phone via the Pico W’s Wi-Fi module. A manual button allows arming and disarming the system. The most recent intrusions will be stored in a database with their timestamps

Motivation

The goal of the project is to develop an affordable and easy-to-implement security solution using low-cost components and the Raspberry Pi Pico W platform, which provides integrated Wi‑Fi connectivity for real-time notifications.

Architecture

The system is divided into four logical modules:

  1. Laser Module (emitter + sensor)
  2. Control Unit (Raspberry Pi Pico W firmware)
  3. User Interface (buzzer + push-button)
  4. Network Service (cloud notification endpoint)
+----------------+          +----------------+
| Laser | | Notification |
| emitter+sensor | | Service (Wi-Fi)|
+----------------+ +----------------+
^ ^
v |
+----------------+ |
| Raspberry Pi |-------------+
| Pico W |
+----------------+
| ^
v |
+--------+ +--------+
| Buzzer | | Button |
+--------+ +--------+

Diagram

Log

Week 5 - 11 May

I got started with the Pico setup and became accustomed to wiring the components to the board itself. I ran into difficulties connecting the debugger Pico, so I activated USB logging for my development needs.

I started writing the main logic of the program. I tested each component individually through code and then built a broader program that encapsulates the LDR reading and buzzer trigger.

Week 12 - 18 May

I assembled most of the pieces and further developed the logic for the laser–LDR calibration period. I also began developing the Wi-Fi setup and email-sending feature.

Week 19 - 25 May

The email functionality was more of a challenge than i anticipated , so i resumed myself to using a tcp connection on port 80 to send logs on a http html page. Also tried to add an I2C screen in my project, but it interfeered with something in the program and with the port 80 connection, so i unfortunately dropped the idea.Finished the Documentation and assembled the mockup gate.

Hardware

We use off-the-shelf components mounted on a breadboard and powered by a 5 V supply. The main utilities are the button, the passive buzzer which will be configured to emit a custom tune, the laser which will just be controlled by the button and the photoresistor which checks the laser output.

Pic1

Pic2

Pic3

Schematics

KiCAD-Schematic

Bill of Materials

DeviceUsagePrice (RON)
Raspberry Pi Pico WMicrocontroller with integrated Wi-Fi35
5 V Laser DiodeLaser beam emitter14
LDR / PhotoresistorLaser-beam interruption sensor1.90
Passive BuzzerAudible alarm output1
Push-ButtonManual arm/disarm control2
Breadboard & Jumper WiresPrototyping22
5 V /3.3 V Power SupplySystem power0(came with breadboard)

Software


This project is a laser-based intrusion detection system built on the Raspberry Pi Pico W using the async-capable Embassy framework in Rust. When enabled, it creates a Wi-Fi access point (Stefan_Pico) that hosts a local HTTP server. Users can access this server via a browser to receive real-time alerts. The system uses a laser and a photoresistor (LDR) to detect beam interruptions. When the beam is broken, it triggers a 3-phase beep via PWM and sends a timestamped alert to the connected HTTP client. A button toggles the system on/off, and a calibration phase establishes a light threshold baseline at startup.

Key features include USB logging, AP-mode networking, chunked HTTP responses, and embedded async task scheduling via embassy-executor. The implementation uses several crates such as embassy-rp for hardware abstraction, embassy-net for networking, and cyw43 for Wi-Fi control. The system is lightweight, efficient, and designed for real-time response.


LibraryDescriptionUsage
cyw43Wi-Fi driver for the CYW43 chipsetNetDriver, PowerManagementMode for network I/O and power modes
embassy-executorAsynchronous executor for EmbassySpawner, #[task] for spawning and running tasks
embassy-rpRP2040 peripheral abstractions and utilitiesADC: Adc, Channel, InterruptHandler (analog reads & IRQs)
GPIO: gpio::{Input, Output, Level, Pull}
PWM: pwm::Pwm, pwm::Config as PwmConfig
PIO: pio::Pio
Interrupts: bind_interrupts!, Handler trait
Peripherals: peripherals::{USB, DMA_CH2, PIO0}, usb module
embassy-timeTiming utilitiesDuration, Timer for delays and time-based scheduling
embassy-usb-loggerUSB‐based logging over the Embassy frameworkCapture and transmit debug logs over the USB interface
panic-probePanic handlerBacktraces and panic logs over SWD
logStandard Rust logging facadeinfo! macro for structured runtime logging
cyw43-pioPIO-based SPI front-end for CYW43 Wi-Fi modulePioSpi, RM2_CLOCK_DIVIDER for bit-banged SPI over PIO
static-cellZero-overhead static allocation utilityStaticCell for safe, statically allocated variables
embassy-netEmbedded-ready network stackConfig as NetConfig, Stack, StackResources for IP-stack setup and resource allocation
embedded-io-asyncAsync traits for I/O like Read and WriteUsed with sockets for non-blocking I/O
heaplessStack-allocated data structuresString, Vec used for HTTP responses and logging without heap
core#![no_std] system-level Rust APIUsed implicitly; provides types like Option, Result, Write, etc.

Functional Diagram for the Software

Software Functional Diagram