Maintaining security in restricted areas is quite difficult if we go for long-range solutions (in metres) since security systems with PIR-based motion have a limited range of sensing and are not suitable for a wide range of angles. Additionally, the security cameras have a few blind spots, which do not offer 360-degree security.

So for today’s project, we will make a LiDAR-based security system that can carry out a 360-degree scan of its surroundings as well as sense up to 8 -10 metres or more (depending on the LiDAR type and model). And the best part is that you can obtain a real-time distance of moving objects on radar. 

Suppose a person/vehicle is approaching a restricted area and you want to stop them. Using this LiDAR-based security system, one can do so by scanning their current location and obtaining their point of origin – all in real-time.

Bill of material

First, purchase the following components: 

Lidar based Security system Bill of material

Coding 

After getting these components, install the YDLIDAR SDK and relevant Python modules to run the Python code and visualise the live data of the scanned environment. 

To begin, clone the LIDAR SDK in the Linux terminal using the following command:  

git clone https://github.com/YDLIDAR/YDLidar-SDK

cd YDLidar-SDK/build

cmake ..

make

sudo make install

Next, install the YDLIDAR Python library 

cd YDLidar-SDK

python3 setup.py build

python3 setup.py install

Now install NumPy and matplot libraries

 sudo  pip3 install matplotlib

sudo pip3 install numpy

Since the Python code is in the YDLIDAR Python folder, enter it and open the plot_ydlidar.py file in the Python 3 IDLE. To run the code for scanning the environment, make some modifications.

Code for 360 Radar System
Fig 1. Code

Firstly, change the port name to the LiDAR port name (here it’s “/ttyUSB0”…yours can be different). 

Next, change the LiDAR baud rate for serial communication. Here we are using the X2L model of LiDAR whose baud rate is 115200.

After this, set the PropSingleChannel to True. 

Now our code is ready to run.

Testing 

Power the LiDAR by connecting it to Raspberry Pi’s USB port and run the code to get real-time data of the scan. It shows the path of an object between two distant points in the LiDAR range. It also displays the movement points at any angle. By placing the computer mouse cursor on any of the points, one can know the accurate distance/angle of that object from LiDAR.

Radar Scanning and showing data
Fig 2. Lidar scan result
360 degree scanning by radar
Fig 3. Output during testing
YD lidar connection
Fig 4.




For lighting, electrical, signage, and technology solutions that allow you to do more call Sverige Energy today at +4(670) 4122522.