Homemade Security System Using Sensor Fusion

Introduction: Homemade Security System Using Sensor Fusion

About: Currently a BME student at Georgia Tech but also very interested in Computer Science who likes to build cool things. Love to learn new things by doing!

The idea behind this project is to create a cheap and easy to make security sensor that can be used to alert you when someone has crossed it. The original goal was to create something that could notify me when someone walked up the stairs but I also use it as a security sensor for the front door. The provided software in this instructable is compatible with macOS. Slight changes will have to be made for it to work with Windows. For the full source code for any of these scripts, refer to this GitHub repo.

Supplies

Step 1: Circuit Set Up

Follow the circuit schematic as shown above. When you upload the Arduino sketch to the nano, make sure to disconnect the wires from the RX and TX pins on the nano. It has been found that uploading to the Arduino can lead to errors if these pins are connected to the bluetooth module. Upload the sketch first and then connect those pins to the bluetooth module.

Main Components

  1. Arduino Nano - Microcontroller
  2. HC-SR04 - Ultrasonic Sensor
  3. HC-05 Module - Bluetooth Module
  4. OMRON Switch - Button Used to Switch Sensor On/Off

Step 2: Software Set Up: Arduino

  1. Download Software Serial to your Arduino Library
  2. Make sure to select the port and board that matches your Arduino
  3. Download the provided info file and upload the sketch once you make sure that the RX/TX pins on the Arduino are disconnected from the bluetooth module.

Step 3: Software Set Up: Python

To successfully alert you on your laptop, you will need to run a python script. For help downloading python and the needed libraries please refer to this helpful Instructable by TalalKhalil.

The provided readingValuesV2.py script reads in values sent by the bluetooth module, determines if it signifies that someone has crossed the sensor and creates an alert on your laptop. It also creates and stores a folder within that directory with all the measurements it read since the script started with a time stamp.

To Do:

  1. Download Python and all dependencies. (I used pip install)
  2. Make sure to turn on bluetooth on your laptop and connect to a device named HC-06. You should find it listed under the other devices list in the bluetooth part of your system settings. The passcode for the module is '1234'.
  3. The variable named distance_wall is the one that determines when the sensor goes off. So depending on sensor location, make sure to change this value which is represented in cms to your environment.
  4. Connect the RX/TX pin on the bluetooth module and now run the readingValuesV2 script. It will ask you for a the recording number so it can properly name the file it generates.

It is likely that you may have to do a lot of debugging so refer to the last section in this Instructable for further help.

Step 4: Likely Debugging Issues

Arduino

1) avrdude: stk500_getsync(): not in sync: resp=0x0: This often happens with when trying to upload a sketch to an Arduino.

  • Ensure that the right COM port and board is chosen
  • If you are currently using the 'ATmega328P' try the 'ATmega328P (Old Bootloader)'
  • Make sure that the RX/TX pin on the Arduino is disconnected

2) Busy Comport Error

  • Ensure that the right COM port is chosen. Since you are trying to upload the sketch to the Arduino, make sure that the python script is not running.

Python

1) [Errno 16] Resource busy: '/dev/tty.HC-06-DevB': This happens when you haven't connected your laptop to the bluetooth module

  • To solve this you need to ensure that you have properly connected the HC module to your laptop. You also have to ensure that this module remains connected, it will become disconnected after you are done running the script.

2) ValueError: The bluetooth module is not connected

  • This is a manually thrown error if the Serial Port Connection with the bluetooth module is not connected properly.

3) Python Packages Dependencies Error

  • I used pip install to download the needed packages for python. Refer to stack overflow for any errors that pop up on that end

4) Errors Due to OS

  • I expect that some errors will pop up if the os being used is Windows. Some areas that may be troublesome is the logging of data recording and notification system on your laptop.

5) serial.serialutil.SerialException: device reports readiness to read but returned no data

  • This sometimes happens if the power supply is turned off. This occurred to me when I toggled the device off using the switch.

Hardware

1) Ensure that the switch is properly paced between the line divider on the breadboard so that the connections don't get mixed.

Step 5: Demoing the Completed Device

Please feel free to check out the video to see the device in action using the embedded link or this YouTube link: https://youtu.be/Ab1wKr2ORbM. Overall, this is something that I use regularly now and have found that it does not drain the power supply too quickly or stress out my old laptop in terms of processing power. If you have any issues, feel free to create an issue post on the associated GitHub repo for this project!

Battery Powered Contest

Participated in the
Battery Powered Contest

Be the First to Share

    Recommendations

    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Rice & Grains Challenge

      Rice & Grains Challenge
    • Puzzles Challenge

      Puzzles Challenge

    Comments

    0
    josh.paradise.mc
    josh.paradise.mc

    1 year ago

    This was pretty cool but installing the python libraries was rather complex and difficult. Eventually got it working though.