Laser tripwire-based security systems use low-energy lasers and simple technology to trigger the alarm system. This alarm can be auditory, visual or mobile notification via IoT based system. These systems are completely legal in any country till the laser rays are not disturbing the public. On the other hand, a laser fence or laser wall uses a high energy laser (cutting laser) to injure bodies passing the laser beam. This can be illegal in most of the regulated countries when used by a civilian.
In this article, we are talking about the first type of device development which is completely legal and safe. Laser tripwire-based security systems can be developed using transistors or ICs. However, they are primitive and their upgradation to send a mobile notification is not possible. In this article, we are sharing the system which is basic i.e. just triggers a buzzer alarm. This is an easy system and can be built by the kids. The parts we need are:
- ESP32 or Arduino UNO Board
- Laser Diode Module KY-008
- Buzzer
- LDR
- Resistors (10k)
- Push Button Switch
- Bread Board
- Jumper wires
Working Principle of Laser Security System
The principle is the same as was in Turn On LED in Dark With LDR and Arduino. The LDR is sensitive to light, when the laser can not reach LDR, the voltage output changes, which eventually triggers the alarm. The project works on the principle of interruption. If the light is interrupted the buzzer will start. We are adding a push button to reset the system.
---
Code and Circuit Diagram
Initially, I wrote the code and later realized that the difficult part is drawing the circuit diagram and keeping it simple. After searching a bit, I found that Utsource Part already published the thing on maker.pro
which I wanted to show you.
Finally, I modified their code to support ESP32 with future WiFi support. This code is for Arduino UNO and can be used with ESP32 (when commented out). For ESP32, any of the ADC1 GPIO pins can be used. We can use GPIO 35 (ADC1 CH7).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | int laserPin = 3; // for ESP32 //int sensorPin = 35; // for Arduino UNO int sensorPin = A0; int buttonPin = 12; int buzzerPin = 11; //adjust the value int laserThreshold = 10; void setup() { pinMode(laserPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); Serial.begin(9600); } boolean alarmState = false; void loop() { if (! alarmState) { delay(1000); digitalWrite(laserPin, HIGH); delay(10); unsigned long startTime = millis(); while (millis() - startTime < 1000) { int sensorValue = analogRead(sensorPin); Serial.println(sensorValue); if (sensorValue > laserThreshold) { alarmState = true; break; } delay(10); } digitalWrite(laserPin, LOW); } else { tone(buzzerPin, 440); if (! digitalRead(buttonPin)) { alarmState = false; noTone(buzzerPin); } delay(10); } } |
My original thing’s circuit diagram was this one. Vcc of the laser module should be connected to the power source. This is not required for this project but I published it for self-reminder.