I needed an outdoor intrusion sensor for my driveway with a longer range than PIR and free from false alarms. The range needed was 40 feet and most PIR sensors only do about 30 feet with a tendancy to generate false alarms. I have a home security system but there were no reliable sensors that could cover my entire driveway. The power source would be a 5 vdc USB transformer plugged into an AC outlet but I also wanted to experiment with battery power since there are no nearby outside AC outlets near the entrance to my driveway.
I started out with the Arduino Uno and experimented with a variety of sensors including PIR, thermal camera, ultrasonic PING and X-band radar. None of them had the range that I needed. I tried several different PIR sensors and found them to be prone to false alarms. Next I tried a Garmin LIDARLite v3HP sensor. This worked well for beam interruptions and was unaffected by outside weather or light changes. Unlike a garage door photoelectric beam, the LIDAR sensor needs no reflector and has a much greater range. At first I used the Pulse Width Modulation (PWM) interface, which worked fairly well but generated a few false alarms due to instability in the distance readings.
Next I needed to connect it to my home wifi network so I added a WINC1500 wifi shield and DS1307 Real Time Clock (RTC) breakout module on an Uno prototype shield. The RTC was needed to provide accurate timestamps when intrusions were detected. The Uno didn't have enough memory for the WIFI sketches and the form factor with two shields was too large and drew too much current to run on a LiPo battery for any length of time.
At this point I realized that this was a perfect use case for an IoT (Internet of Things) board so I switched to the Arduino MKR WIFI 1010. The MKR 1010 has 256KB of flash memory and 32KB of SRAM compared to the Uno's 32KB of flash memory and 2KB of SRAM. The MKR 1010 is also smaller, lower current and has an on-board real time clock, WIFI and Bluetooth.
The MKR 1010 easily connected to my wifi network and had more than enough memory for my sketch and all the libraries that it needed. The RTC worked very well. The next problem to solve was how to send push notifications to my iPhone XS. Internet searches identified three candidate Web services: Blynk, Amazon Web Services (AWS) and Pushsafer. Sending a push notification to an iOS or Android device requires you to install a listener app. None of them are completely free but offer a varying number of initial event reports and subscription plans after that. AWS was the most complex and I eliminated it because of that. Blynk and Pushsafer were similar in price but Pushsafer was slightly simpler to implement so I selected it.
I was dissatisfied with the LIDARLite v3HP PWM interface because of the instability of the distance readings which caused occasional false alarms. I attempted to rewire it for Inter-Integrated Circuit (I2C) serial communications using the LIDARLite_v3HP library's most current version (3.0.5) and the example sketch v3HP_I2C. It would not compile for the MKR 1010 board without errors. I posted an issue on GitHub and after several exchanges in which I attached verbose compiler errors, Brad Wiseman updated the LIDARLite library to version 3.0.6 and provided me with detailed instructions on how to compile successfully for the MKR 1010. I used code snippets from the LIDARLite_v3HP v3HP_I2C example sketch to build my own sketch. The resulting performance of the v3HP I2C interface was more accurate and much more stable than the PWM interface.
I decided to experiment with mounting the LIDAR Lite v3HP sensor on a servo and have it sweep the driveway in a 90 - 180 degree arc. After spending a great deal of time experimenting with different servos, servo positioning methods and time delays, I concluded that moving the LIDAR sensor even slowly with a servo was generating too many false alarms. The internal circuitry in the LIDAR sensor needs a stable environment to correct for false alarms and does quite well when the sensor is in a fixed position. There are several possible causes of unstable distance readings such as the reflectivity of an object's surface and the angle at which the infrared laser beam hits the target. Adding a moving servo vastly complicates the situation so I reverted to a fixed mounting for the LIDAR sensor on the project box.
LIDAR is frequently used for 3D mapping and obstacle detection so the problem of false alarms with a moving LIDAR sensor can be solved with the right algorithms. I was more interested in using LIDAR to sense beam interruptions but at some point I may revisit mounting the sensor on a servo to cover a larger area. That will increase battery drain and I may need a larger battery.
For hardware connections I used the standard I2C wiring schematic from the LIDARLite_v3HP data sheet.
Since this project was published, I've resumed experimenting with a limited form of LIDAR mapping using a servo mounted LIDAR-Lite v3HP sensor. The goal is to minimize false alarms while maximizing true intrusions. By panning the sensor over a 180 degree arc which most servos can handle, a 180-point distance map is built as a reference with no intrusions. Then the servo-mounted LIDAR sensor is swept back and forth over the same area continuously and compared with the reference map. A threshold is established to identify true intrusions and when the difference between the reference map and distance readings exceeds the threshold, an alarm is generated. The key to achieving the goal is in the algorithm used to compare the reference map with the distance readings. Simply subtracting the two at each degree point is not sufficient to minimize false alarms. Machine learning may be a possible technique to solve this problem. I am in the process of investigating how it could be implemented in this project. Once a viable technique is discovered, I plan to introduce a tilt servo and scan the target area 180 degrees horizontally and 20 degrees vertically. At 20 degrees of tilt and 40 feet of distance, the LIDAR beam will cover a height of about 4 feet. That should be sufficient to tell the difference between an animal and a human or vehicle.
I've discovered that the type of servo and delay between servo movements are key factors in minimizing false alarms. Many small servos can be inaccurate by as much as 1.3 degrees due to imperfections in the mechanical parts. Nylon gear servos are smoother and create less vibration that affects the distance reading. Servos that remain in position without continuous position pulses have less vibration as well. A 100 millisecond delay between servo positioning movements helps reduce the vibration but makes the 180 degree sweep last 18 seconds. I considered using a slip-ring motor and rotating the LIDAR sensor continuously to eliminate servo vibration, reduce mechanical inaccuracy and speed up distance readings. Adafruit's SRC022A-6 slip-ring motor has a rotation speed of 0 - 300 RPM but I would still need a tilt servo and current drain might increase to the point where battery operation is not feasible. I've been investigating direct drive, digital servos to overcome some of these limitations.
Comments