AI Security Camera Triggers Alarm Light via Wireless Relay

Viewtron IP camera NVRs are now integrated with Shelly wireless smart relays. This means that you can use any of the AI software alarms supported by Viewtron AI security cameras to open or close or an electrical relay on an IP network over WIFI. Viewtron IP cameras support human detection, car detection, face detection / facial recognition, and license plate detection / license plate recognition.

In this example, I configure the human detection / perimeter intrusion event to trigger (close) the relay port on a Shelly One over the WIFI at our office.

Here is an overview is how this works.

  1. The Viewtron AI camera is hard wired to one of the Viewtron NVR’s PoE ports using network cable (CAT5 or CAT6).
  2. The Viewtron NVR is hard wired to network router with network cable. The router has built-in WIFI.
  3. The Shelly smart relay is setup to connect to the wireless network. In this project we are using a Shelly Plus 1, which supports 12V DC.
  4. A 12V DC power supply is connected to the Shelly 1 to provide power to the Shelly.
  5. The 12V DC power supply is also wired in-line with the relay output port so that it will provide power to our alarm light when the relay circuit is closed.
  6. The normal state of the relay is open (NO).
  7. Human detection and an intrusion detection zone are setup on the Viewtron NVR for the AI camera.
  8. When intrusion detection by a human is detected, the NVR sends an alarm signal to the Shelly Plus 1 to close the relay.
  9. When the Shelly One closes the relay, the alarm light receives 12V DC power and turns on.
  10. After 20 seconds, the NVR sends a signal to the Shelly to open the relay and the alarm light turns off.

Shelly One 12V DC Alarm Light Wiring Diagram

Shelly Plus 1 12V DC wiring diagram

This is how a wired the Shelly Plus 1 to the power supply and alarm light.

  • Powering the Shelly – I use one of these PT-4 pigtail power leads to connect the 12V DC power supply to the Shelly. I connect the red wire from the PT-4 to the 12V+ terminal on the Shelly and the black wire from the PT-4 to the L terminal.
  • Relay / Load Side (dry contacts) – I use 20 gauge power cable to connect the O (output) to one power terminal on the alarm light. I connect the other power terminal on the alarm light to L (ground) on the Shelly. I use a short jumper wire to connect the | (common) on the relay to the 12V + terminal.

Connecting the Shelly Smart Relay to Wireless Network

One of the things I really love about Shelly relays is how simple they are to setup. When you first power a new Shelly One on, its built-in bluetooth is turned on. This allows you to connect directly to via the Shelly mobile app.

Add Shelly Device to Mobile App

After you power your Shelly device on, open the Shelly mobile app and tap on the Add Device + icon. That will bring you to the screen on the right where you can select to Add via Bluetooth. Once the app connects to the device via Bluetooth, you can configure the Shelly device to connect to your wireless network by entering your WIFI SSID and password.

Once your Shelly relay is connected via WIFI, you should setup a static IP address for it on your local area network. You can do this via DHCP reservation on your router. If you are not familiar with how to setup a static IP address on your router, please take a look at these static IP address setup instructions for our IP cameras. The concepts are the same.

You can find the IP address of your Shelly Plus 1 in the mobile app by 1) taping on the Shelly Plus 1 device in the Devices section, then 2) tapping on the gear icon. 3) You can see the IP address here.


Configure to Shelly Wireless Alarm Relay on Viewtron NVR

DVR NVR Settings

To connect the Viewtron IP camera NVR to the Shelly wireless relay, click on Settings from the main menu.

AI Event Settings IP Camera NVR

On the menu, click on the AI / Event link.

IP Camera NVR alarm relay add

  1. Click on the Relay link.
  2. Click on the Add button.

IP Camera NVR relay configuration

The add dialog box will open. Select Shelly http for the Protocol. Enter the IP address of your Shelly relay in the IPv4 field, 80 in the port field. You can leave the Username and Password empty unless you password protected your Shelly device.

Click the Add button when done.

Viewtron NVR Relay List

You will see the relay added to the device list, and the status should change to Online once the NVR confirms that the Shelly is online and reachable over the network. If you want to change the name of your relay, you can click on the Edit icon and rename your Shelly device.


Configure Human Detection / Intrusion Detection

Now that the Shelly wireless relay has been added to the Viewtron NVR’s list of relays, you may configure any of the alarm input that the NVR supports to trigger it. In this example, I am going to configure human detection / perimeter intrusion detection. Please note, it is just as easy to setup a line crossing detection alarm to trigger the Shelly relay.

AI Software human detection intrusion detection setup

To setup the human detection / perimeter intrusion detection on the NVR, do the following.

  1. Click on the AI / Event link.
  2. Click on the Perimeter Detection link.
  3. Choose the camera that you are configuring.
  4. Click on the Region Intrusion tab and check the Enable Detection by IPC checkbox.
  5. Draw the perimeter intrusion zone.
  6. Select People, Motor Vehicle, Non-motor Vehicle depending on the object type(s) that you want to detect.
  7. Choose a schedule for the detection.
  8. Click Apply.

AI software human detection alarm trigger setup

Next we will setup the Shelly smart relay to be triggered by the human detection alarm.

  1. Click on the Trigger Mode link.
  2. In the Alarm-out section, click on the Configure button.

IP camera alarm enable Shelly smart relay

The Trigger Alarm-out box will open.

  1. Select the Shelly smart relay(s) that you want the alarm to trigger by checking the boxes on the left.
  2. Click the right arrow.
  3. The Shelly smart relays that will be triggered by the alarm will appear on the right under “Trigger Alarm-out”. Click on the OK button.
  4. Click the Apply button.

Viewtron IP camera NVR Shelly relay alarm setup

Now you will see all of the Shelly smart relay(s) that are configured to be triggered in the Alarm-out section of the Trigger mode screen.

Click Apply in the lower right. Click the X button in the upper right to close the settings screen.

The Viewtron IP camera system is now setup to close the Shelly smart relay and turn the alarm light on whenever the human detection / perimeter intrusion detection alarms occur.


Products Used in this Project


Shelly Smart Relays work with High Voltage Devices

Shelly One Light Switch Wiring

In addition to the 12V DC alarm light, I also wired on of the light switches at CCTV Camera Pros office to a Shelly 1 PM Gen 4 smart switch. I setup the same human detection event on the VIewtron NVR to turn the lights on in our tech room.

The integration possibilities are endless being that Shelly makes smart relays that work with low voltage and high voltage devices.


Alarm Output Ports on Viewtron DVRs / NVRs

DVR Alarm Relay Output

Shelly smart relays are a great solution if you need to trigger a relay over an IP network because the device is too far to hard wire to the alarm relays that are built into your Viewtron DVR / NVR.  However, you can also follow these instructions to hard wire alarm devices to the alarm relays directly on the Viewtron DVR.


Have Questions / Need Help?

If you have any questions on how-to setup electrical relays with your VIewtron security camera system, please contact me at mike@viewtron.com.