Categories
Connected Farm

Farm CCTV Calving and Security Cameras with IOT intergration

I’ve been using a couple of cheap 8 channel Flouroen CCTV systems for monitoring calving and general security for the last few years. But I’ve decided to upgrade to Hikvision equipment. The Floureon system served its purpose but there are a few issues that I encountered, The most concerning was the app on my phone consumed too much power and continued to run in the background, so I had to force stop it every time that I used it, also there was no way to access the feeds from my PC except installing and android emulator like Bluestacks.

I’ve also decided to move the DVR location to make it more convenient to access, originally I had the DVR in a waterproof box bolted to a rafter, I had also removed the DVR circuit board from its cassis and mounted it to the back of the box to save space.

In my new setup, I’ve mounted the new Hikvision DVR somewhere more convenient, although it turns out that unlike the old Floureon the Hikvision can be completely configured using any web browser on the same network.

I used 2 8ch video baluns to send the video signal from the old DVR location where the existing camera cables and PSU’s are still located. It’s not exactly neat but it will keep all of the connections dry. For the moment I’m not upgrading the camera’s but over time I probably will, I might even install one PTZ camera also. The current cameras are OK but the wind as you can see in the top picture has on occasion moved them so domes may be a better option in the future.

I used 2 different video baluns one with male BNC connectors and one with female BNC connectors as this saved having to get extra BNC patch leads. Both baluns have 2 options for connecting the CAT 5 cable, either a crimped RJ45 plug or the provided screw terminals can be used. I’ve used both options here as one CAT 5 cable can carry 4 video feeds so I needed to run one extra cable and my original cable was already crimped.

There are a few options for connecting to the DVR, which are Web Browser (only Internet Explorer supports video feeds), Hilook Windows App or the HiLook Mobile App.

Not much configuration is required, I’ve statically set an IP address to make integrating with other software easier, But DHCP is set by default to automatically set the network settings.

There are a few options to setup remote connections for the DVR, Port forwarding can be set on the router. There are 4 ports as seen in the screen shot above that need to be forwarded. The exact steps to forward the ports will vary by router make and model this link may help https://portforward.com/router.htm

You could also try enabling UPNP under the NAT Tab, if your router supports this function then it will automatically forward the necessary ports.

The most popular and simplest option is in Advanced Settings menu under Platform Access tab. This method uses a P2P protocol that dose not require any special setup with the router. You just click enable and entre a verification code, basically just a password of your choosing. Then in the mobile Hikvision HiLook App you scan the QR code that is on the bottom of the DVR and entre the same verification code and that’s it. P2P requires very little setup, but it has issues including some security concerns, it also depends on a cloud service which you have no control over, if the cloud service has any technical issues or even worse is shutdown in future then you’ll be left with no access.

Home Assistant Integration

For Remote access I don’t use any of the above options, instead I use WireGaurd VPN running on my Home Assistant installation as it is secure and dose not require any cloud services or having to forward separate ports for every device on my network and I can access any device remotely like I’m on the home network. The Addon is available in the Home Assistant Addon store.

server:
  host: ThisIsObviouslyNotMyRealConfig.duckdns.org
  addresses:
    - 172.27.66.1
  dns: []
peers:
  - name: peer1
    addresses:
      - 172.27.66.2
    allowed_ips: []
    client_allowed_ips: []
  - name: Peer2
    addresses:
      - 172.27.66.3
    allowed_ips: []
    client_allowed_ips: []Code language: CSS (css)

The configuration is relatively straight forward, in this case there are 3 addresses configured one for the home network, one for the farm network and one for the mobile. Once you add the config and start the addon it automatically creates the configs for the other 2 peers. These configs can be found in Home Assistants shared folder SSL/WireGaurd/ and can be used to configure the other peers, there is even a QR code that can be used to configure the WireGaurd mobile app using your phones camera.

#Add Camera Streams to HA
camera:
  - platform: ffmpeg
    input: -rtsp_transport tcp -i rtsp://admin:password@192.168.1.19:554/Streaming/Channels/101/
    name: Front Gate
  - platform: ffmpeg
    input: -rtsp_transport tcp -i rtsp://admin:passwor@192.168.1.19:554/Streaming/Channels/301/
    name: Front Door

#Add Hikvision Alarm Output To HA
binary_sensor:
  - platform: hikvision
    host: 192.168.1.19
    username: admin
    password: passwordCode language: PHP (php)

The above is added to to the HA configuration file, each camera stream needs to be added individually. Alarm outputs from the DVR can also be added to use motion and object detection for various automations and Alarms, like a notification to your phone if movement is detected or a specific object like a vehicle or implement is moved.

Each Camera stream can be added to the Home Assistant UI and buttons can be integrated with each feed to control items specific to that feed, such as electric gates or lights, useful to turn on lights over a calving pen for example.

A Picture Glance Card is used to add each camera feeds to the UI and a switch for each required automation can be added under automations.

Alarm outputs from the DVR will show up in Home Assistant as Binary Sensors, there are several available for each camera feed and can be used with automations to for various tasks such as turning on lights on motion detection or sending alarm notifications to your phone. These alarms can be setup under Events in the DVR menu. There are also smart events which can detect people, vehicles and objects in the feed.

Links for the purchases used in this CCTV Upgrade.

DVR:

Balun for DVR:

Balun for Cameras:

Facebook Comments