How to Build an Interactive Surveillance System Using Raspberry Pi and a QNAP NAS

by tombadil24 in Workshop > Tools

2076 Views, 5 Favorites, 0 Comments

How to Build an Interactive Surveillance System Using Raspberry Pi and a QNAP NAS

1.png

Two typical scenarios with this system would be:

Scenario 1:

  • Motion is detected by the IP Camera
  • IP Camera, that is already connected to QVR Pro, triggers an event in QVR Pro
  • QVR Pro sends an HTTP message to QIoT Suite
  • QIoT Suite modifies and sends an MQTT message to the Raspberry Pi's Piezo Vibrator and LED Light
  • The user can flick the Rocket Switch to stop Piezo Vibrations and turn off the LED Light

Scenario 2:

  • The user pushes the Push Button on the Raspberry Pi
  • Raspberry Pi sends an MQTT message to QIoT Suite
  • QIoT Suite sends an HTTP message to trigger an event in QVR Pro, which already has an IP Camera connected
  • IP Camera begins to record

Supplies

  • QNAP NAS:
    • QTS Applications:
      • QVR Pro
      • QIoT Suite
  • PoE Ethernet Switch
  • IP Camera (capable of motion detection)
  • Raspberry Pi
  • GPIO Extensions:
    • Piezo Vibration
    • SPDT Switch
    • LED Light
    • Push Button

Connect the Parts

2.png
3.png
  • Connect the NAS, Raspberry Pi and IP Camera to the PoE Switch
  • Connect the GPIO Extensions to the Raspberry Pi (it is recommended to use a breadboard)

Configure QIoT Suite

Things:

  • Name: QVRPro
    Category: Custom
  • Name: RPi
    Category: QIoT Supported
    Type: Raspberry Pi

Resources:

  • QVRPro:
    • Name: motion
    • ID: motion
    • Type: Custom Sensor (Boolean)
      Note: Click Connect a device > HTTP > next > download json. This information will be used to connect to QVR Pro in Step 5.
  • RPi:
    • Scenario 1:
      • Name: vibration
      • ID: vibration
      • Type: Piezo Vibration
        Note: Click Connect a device > MQTT> next > download json. This information will be used to connect to Raspberry Pi in Step 6.
      • Name: rSwitch
      • ID: rSwitch
      • Type: Piezo Vibration
    • Scenario 2:
      • Name: button
      • ID: button
      • Type: button

Configure QIoT Suite (Flow for Scenario 1)

4.png

Nodes:

  • [QBroker In] QVRPro:
    • Thing: QVRPro
    • Resource: motion
    • Note: This node will receive {"value": "detected"} when QVR Pro detects motion
  • [QBroker In] rocket switch:
    • Thing: RPi
    • Resource: rSwitch
  • [Function] true:
    • msg.payload = true;
      return msg;
  • [Function] false:
    • msg.payload = false;
      return msg;
  • [QBroker Out] RPi:
    • Thing: RPi
    • Resource: vibration

Configure QIoT Suite (Flow for Scenario 2)

5.png

Nodes:

  • [QBroker In] button:
    • Thing: RPi
    • Resource: button
  • [http request] http request:
    • HTTP address from QVR Pro

Configure QVR Pro's Event Management

Event for Scenario 1:

  • Name: motionDetect
  • if: Motion Detection
  • then:
    • Type: Action URL
    • Target: : /resources/
      Note: these values are found in the resource.json file from Step 2
    • HTTP Body: {"value" : "detected"}

Event for Scenario 2:

  • Name: button
  • if: Action URL
    Note: Paste this HTTP URL into QIoT Suite in the previous step
  • then: Camera Record

Configure Node-RED on Raspberry Pi (Flow for Scenario 1)

7.png

Nodes:

  • [MQTT In] qiot/things/admin/RPi/vibration:
    Note: Topic can be found from QIoT in Step 2.

  • [Switch] switch:
    • Receives either true or false
    • true directs to int 50
      • redirects to int 1 for LED Light
    • false directs to int 0
  • [RPi-GPIO Out] piezo:
    • PIN: 17
    • Vibrates at a frequency between 0 to 100, in this case it will vibrate at 50
  • [RPi-GPIO Out] led:
    • PIN: 18
    • Receives 1 for on, 0 for off
  • [RPi-GPIO In] rSwitch:
    • PIN: 24
    • Triggers when the switch is flickered
  • [MQTT Out] qiot/things/admin/RPi/rSwitch
    Note: Topic can be found from QIoT in Step 2.

Configure Node-RED on Raspberry Pi (Flow for Scenario 2)

7.png

Nodes:

  • [RPi-GPIO] button:
    • PIN: 21
    • Triggered whenever the button is pressed
  • [MQTT Out] qiot/things/admin/RPi/button:
    Note: Topic can be found from QIoT in Step 2.