Unusual projects of the Internet of things. Guard dog on Raspberry Pi and smart baby monitor

A smart home makes life more comfortable and safer. Security is never superfluous. One of the tasks of the Internet of Things is to protect a person and his home, so we install video surveillance cameras with motion sensors and notifications via the Internet. At any time, you can get the phone and check that the raccoons have not made their way into the house.

Guard dog on Raspberry Pi

Unfortunately, not all animals are afraid of video cameras. This is where a “virtual dog” with speakers comes to the rescue.

virtual dog Woof – it’s simple python scriptwhich plays an audio recording of dogs barking through speakers to scare away badgers, raccoons, or people if they get close to the house.

A couple of speakers are connected to a Raspberry Pi. One speaker is directed to the front door, and the second – to the back, where the threat can also come from. The volume of the bark dynamically changes between the speakers, like a dog running through the house from one door to another and bursting into barking.

Inventor Tanner Collin (Tanner Collin) installed in the house such a “dog” before leaving on vacation. Here is one of the columns:

Technically, the virtual dog works like this:

  1. Surveillance cameras broadcast an RTSP stream to the Blue Iris NVR program, which runs on a separate box under Windows.
  2. When Blue Iris detects an object in a certain area, it sends an MQTT message to the channel iot/cameras Mosquitto broker running on the media server.
  3. The Raspberry Pi is running a script that listens iot/cameras using the module asyncio-mqtt. It receives a JSON message like {"serial": "SE-N-ZoneB"} and decodes it. If the camera name matches the one specified in the script, then the corresponding audio file is launched for playback using Pygame.

Script code:

import os, sys
import logging
format="[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s",
level=logging.DEBUG if os.environ.get('DEBUG') else logging.INFO)

import time
import json

import asyncio
from asyncio_mqtt import Client
import pygame

import secrets

COOLDOWN = time.time()

'NE-W-ZoneB': {
'name': 'Front Door',
'sound': 'barkLR.ogg',
'SE-N-ZoneB': {
'name': 'Side Door',
'sound': 'barkRL.ogg',
'B-E-ZoneB': {
'name': 'Back Door',
'sound': 'barkLR.ogg',

async def play_sound(filename):

logging.info('Playing sound %s', filename)

while pygame.mixer.music.get_busy():
await asyncio.sleep(0.1)

async def barkbark(sound):
if time.time() - COOLDOWN < 15.0:
logging.info('Cooldown skipping.')
COOLDOWN = time.time()

await asyncio.sleep(0.1)

await play_sound(sound)

logging.info('Done barking.')

async def process_mqtt(message):
text = message.payload.decode()
topic = message.topic
logging.info('MQTT topic: %s, message: %s', topic, text)

if not topic.startswith('iot/cameras'):
logging.info('Invalid topic, returning')

data = json.loads(text)
except json.JSONDecodeError:
logging.info('Invalid json, returning')

serial = str(data.get('serial', ''))

if serial not in CAMERAS:
logging.info('Invalid serial, returning')

camera = CAMERAS[serial]

logging.info('Barking %s...', camera['name'])

await barkbark(camera['sound'])

async def fetch_mqtt():
await asyncio.sleep(3)
async with Client('') as client:
async with client.filtered_messages('iot/cameras') as messages:
await client.subscribe('#')
async for message in messages:
loop = asyncio.get_event_loop()

if __name__ == '__main__':
logging.info('Booting up...')


loop = asyncio.get_event_loop()

False alarms (by car headlights or small animals) are not too dangerous. Rather, on the contrary, they make the virtual dog more realistic, because real dogs experience the same “false positives”.

In the future, the author plans to add a physical trigger to the system on the steps in front of the house, so that the dog starts barking specifically at the person who came to the door. Possibility of installation inside the house is being considered radar sensor HFS-DC06that fires through the outer wall.

Knownthat barking dogs and CCTV cameras are major deterrents for burglars. Even a virtual dog from speakers is better than no dog. The author of this invention has already been visited by a potential robber who pulled the handle of the garage door. The door was closed, so he climbed into the neighbor’s garage.

Either way, extra security never hurts.

Smart baby monitor

Another interesting project of the Internet of things is a smart baby monitor

The Hungry Baby Alarm

with an artificial intelligence system. The machine vision program interprets the movements of the baby in the stroller, assessing the degree of his hunger (and the approach of crying).

That is, this baby monitor will give a signal that the child is hungry and crying, more before the occurrence of these events.

From the video you can understand how the system works. Unfortunately, developer Caleb Olson didn’t post the code, only

showed parts of it

and mentioned some of the modules it uses for real-time motion recognition (like

MediaPipe Face Mesh


The author has now applied for a patent. But no one bothers to write such a program and publish it in the public domain in order to use it with an arbitrary video camera. Really useful utility in the household.

Similar Posts

Leave a Reply