$USD
  • EUR€
  • £GBP
  • $USD
PROJECTS Laser Radar

TF03 Home Security Alarm Device

DFRobot Feb 25 2020 79

With the development of society, people pay more attention to security. Traditional security, which is carried out by constant patrols by security personnel, is not suitable for the public due to high prices. 

While, I recently came into contact with a laser ranging sensor - TF03, which has already reached to the industrial level. And its detect range is 180m. It can work normally with strong light and in rain or frog. Its production level is IP67 and uses UART port. Let's make a TF03 home security alarm device!


Designing Idea

Select arduino uno as the main control to communicate with TF03, which monitor the distance. Put the distance monitor to the boundary of the target area, the probe should be parallel to the boundary. Once any object cross the boundary, the value of distance will change. Then we can find out the position of cross-border by analyzing the abnormal distance value, and show the distance from a cross-border point to sensor. Then we can alert the intruder by trumpet and LED light and call a guard.
Moreover, the device is designed with a master button. And the alarm can only be released by the master button. 

It can be put many areas, yard walls, safety warning line, supermarket anti-theft.


Materials in Need


1. TF03 (ToF) Laser Range Sensor(100m) x1

2. DFRduino UNO R3 x1

3. IO Expansion Shield for arduino x1

4. Speaker Module x1

5. Lithium Battery (7.4V) x1

6. LED module x2

7. Push Button x1

8. LCD1602 Display Module x1

9. Jumper Wires

10. Thin Conductors


Making Procedure

1. 3D printing housings


2. Hardware Connection


3. Install parts to the housings

(1) Install the main control board - DFRduino UNO R3, plug-in the IO expansion shield and fix the battery.

(2) Install the display to the other housing, which has more space.

(3) Install 2 LEDs

(4) Install the push button and the speaker.

4. Wiring

(1) Connect the LCD display to IIC interface of the IO expansion shield.

(2) Connect 2 LEDs via A0 and A3.

(3) Connect the push button to D13.

(4) Connect the speaker to D8.

(5) For the TF03 laser range sensor, please connect the Red wire to D3, and the Blue wire to D4, and collect power supply wires. 


5. Arrange all wires, put 2 housings together, and screw the housing screws.


Software Programming

#include <DFRobot_RGBLCD.h>
#include <DFRobot_TFmini.h>
SoftwareSerial mySerial(3, 4); // RX, TX
DFRobot_TFmini  TFmini;
DFRobot_RGBLCD lcd(16,2);
uint16_t distance,strength,distance1;
int c=0,k=1;
void setup()
{
    Serial.begin(9600);
    TFmini.begin(mySerial);
    pinMode(14,OUTPUT);
    pinMode(8,OUTPUT);
    pinMode(17,OUTPUT);
    pinMode(13,INPUT);
    lcd.init();
    lcd.setRGB(255,255,255);
    lcd.setCursor(0,0);
    lcd.print("No abnormality");
}
 
void loop()
{
  while(1)
  {
    if(TFmini.measure()>0)
    {
       distance = TFmini.getDistance();
       if(distance<strength-5)
       {
         for(int i;i<50; )
         {
          if(TFmini.measure()>0)
          {
            distance1 = TFmini.getDistance();
            if(distance>distance1)
            {
              distance=distance1;
            }
            i++;
          }
         }
         c=1;
         Serial.print("Distance = ");
         Serial.print(distance);
         Serial.println("cm");
         lcd.setCursor(0,0);
         lcd.print("Distance=");
         lcd.print(distance);
         lcd.print("cm    ");
       }
       fengmingqi();
    }
  }  
}
 
void fengmingqi()
{
  unsigned long a=millis();
  while(c)
  {
    if(millis()-a>300)
    {
      digitalWrite(14, 0);
      digitalWrite(17, 0);
      digitalWrite(8, 1);
      delayMicroseconds(500);
      digitalWrite(8, 0);
      delayMicroseconds(500);
    }
    else
    {
      digitalWrite(14, 1);
      digitalWrite(17, 1);
      delay(1);
    }
    if(millis()-a>600)
    {
      a=millis();
    }
    if(TFmini.measure()>0)
    {
       distance = TFmini.getDistance();
    } 
    if (digitalRead(13) == 1) 
    {
      delay(20);
      if (digitalRead(13) == 1) 
      {
        k=1;
        c=0;
        digitalWrite(14, 0);
        digitalWrite(17, 0);
        lcd.setCursor(0,0);
        lcd.print("No abnormality");
        while(k)
        {
          if(TFmini.measure()>0)
          {
            strength= TFmini.getDistance();
            k=0;
          }
        }
        while(digitalRead(13) == 1);
      }  
    } 
  }
}


Click here to Download 3D Printing Document for TF03 Home Security Alarm Device.stp


Well done! 
I made a test with this device. From the video we can see that when someone passes through the sensor detection range, the device raises an alarm and displays the distance from the human to the sensor on the display.

REVIEW