Recommendations for door camera project

I used a raspberry pi plus free version of xeoma - gave a much faster framerate than motion.

Do I understand it correctly? If I want to have a live stream I need a kind of motion or Xeoma. But if I am pleased with static pictures I can go for a cheaper/simpler solution like an Arduino board.

My onl concerns about a RPi is my experience with very low stability of this one even if I bought a real power supply instead of just using a charger.

The problem is the camera module doesn’t talk on the network. Without out that there is no way to get the data captured by the camera to OH.

If you have a way to attach the camera to an Arduino and a way to attach the Arduino to the network and provide a way for your OH server to pull the data from the Arduino from over the network or have the Arduino push the data to the OH server then yes you can use an Arduino.

The answers to all of those ifs will not be found on this forum though. Maybe you can find something useful on Instructables or and Arduino forum.

Given that the most common platform upon which OH runs is an RPi and in my personal experience I have RPis running things like these that stay running for 6+ months at a time without a reboot, and even when it reboots it is because of a general loss of power to the house, not instability with the RPi, I can’t say that the RPi is generally unstable. Perhaps you have a bad RPi or particularly noisy power or something. And if that is the case, an Arduino might have problems too.

1 Like

I’ve also found raspberry pi’s extremely reliable provided that a decent quality power supply is used - the official pi ones work perfectly. When I’ve cheaped-out and used generic power supplies I’ve had constant reliability problems.

1 Like

It’s probably more cost effective to hack a Xiaomi Dafang

Even better to use this camera and have full opensource firmware that many people have running and cases already designed to 3d print…

Thanks for all your hints.

But to buy something is easy and at the door, combined with the door switch it is not really looking good.
My project is nearly at the end. I wanted to keep this threat a little updated with some pictures:
dry run and programming

Front panel custom made

nearly ready, and waiting for the inlay:

The only thing I am fighting with is a robust programming.

1 Like

Love to see it all working when its done. Be sure to come back with some more pics.

Thanks for the pictures!
Did you install a FULL Pi into the door, or just a simple panel (Zero / Aruino)?
Did you succeed?
Is it working?
Could you test it under very cold / rain / frost / etc?

I Installed an RPi 3
It is working like a charm.
I can show you the temperature curve which is quite stable


Temp drop is at night when shutting off video.

Thank you for the graph! :slight_smile:
Sorry for the more questions, but you just made me more interested than before…

  1. Little strange the CPU is using 10% mostly… Are you maybe recording video non-stop? (That kills an SD card within max 1 year…)
  2. That’s why the Disk montoring, or just to see if there’s something wrong?
  3. How do you speak to the person? (I don’t see any speaker or mic. on those pictures.)
  4. What software solution did you choose finally?
  5. (And sorry for this question I should learn about this myself, but easier to ask: :wink:
  • How did you forward the video+audio stream + temp from that RPi to your main/central-RPi?
  1. video stream is running allways but no recording
  2. just to see if I am running low on SD Card space
  3. no need to speak, no speakers
  4. a python script written with lots of blood and sweat
  5. this was the easiest way. Once you have 3 picture files just send them with Telegram to your mobile

def send_message(chatroomids, message=None, photo=None):
files = {}
for id in chatroomids:
params = {“chat_id”: id}
if message:
params[“text”] = message
cmd = “sendMessage”
if photo:
files = {“photo”: photo}
cmd = “sendPhoto”
url = “{}{}/{}”.format(TELEGRAM_URL, BOT_TOKEN, cmd)
r = requests.get(url, params=params, files=files)
result = r.json()
print(result)

1 Like

I wanted to give you a little update.
Due to big issues with my RPi I decided to replace SD-Card (was broken) the RPi (is still OK) and the PoE Splitter (not sure about this) with a PoE Module. Some new pictures for you.
Nachher:


Vorher:

2 Likes

Sorry to hear your SD card got broken so quickly. :frowning:
Did you make a FULL-backup from it before, so you were able to simply replace + restore?

Many thanks for the pictures! Very informative.

Would you like to share that with us too? :wink:

I am hardly dare to share because my coding skilles are low …

It’s an opportunity to learn and let others help improve the script.

OK, I hope it will not to hard for me :slight_smile:

#!/usr/bin/env python
#coding: utf8

import time
import RPi.GPIO as GPIO
import os
import subprocess
import requests

#GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)

# PIN festlegen an dem das Signal kommt 
optokoppler = 18
relais = 11

#Telegram konfiguration
telegramurl ='"https://api.telegram.org/bot"'
bottoken = "70000000:SOMECHARACTERS"
kate = "711111111"
homer = "7222222222"
chatroomid = kate

# DEV Mode um Verkabelung zu sparen
developermode = 0

# Konfigurationsvariablen
video_start_kommando = 'mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -n -r 1024x768 -f 24 –q 80" -o "/usr/local/lib/output_http.so -n -w /usr/local/www -p 9000" -o "/usr/local/lib/output_file.so -f /home/pi/cam -d 12000"'

video_stopp_kommando = 'sudo killall mjpg_streamer'

video_aufnahme_kommando = 'ffmpeg -i "http://192.168.100.72:9000/?action=stream" -vcodec copy -an -t 30 -bufsize 2048k -y "/home/pi/cam/Klingel-$(date +"%y_%m_%d_%H_%M_%S").mp4"'

mail_versand_empfaenger = 'mail@yahoo.com mail@gmail.com'
mail_versand_kommando = ''
mail_versand_kommando_1 = 'mpack -s "Es hat geklingelt" /home/pi/cam/'
mail_versand_kommando_3 = ' '

# Pin optokopller als Eingang, relais als Ausgang festlegen
GPIO.setup(optokoppler, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(relais, GPIO.OUT)


# Klingelrelais generell anschalten
GPIO.output(relais, GPIO.HIGH) 


# Klingelzähler
i = 0

# Endlosschleife
while 1:
    # Eingang lesen
    if (GPIO.input(optokoppler) == GPIO.LOW) or (developermode == 1):
        
        # Videoaufzeichnung starten
        i = i + 1
        print("Videoaufzeichnung gestartet")
        subprocess.Popen(video_start_kommando, shell=True)
        subprocess.Popen(video_aufnahme_kommando, shell=True)
        time.sleep(31)
        os.system(video_stopp_kommando)
        print("Aufzeichnung beendet")
        
        #Telgram Nachricht versenden
        # Send a photo to a chat room (chat room ID retrieved from getUpdates)
        mymessage = "Es hat gerade das " + str(i) + ". mal geklingelt." 
        url = telegramurl + bottoken + "/sendMessage"
        params = { "chat_id": chatroomid, "text": mymessage }
        r = requests.get(url, params = params)
        result = r.json()
        
        while x < 3:
            x = x + 1
            photofile = os.listdir("/home/pi/cam")[x]
            url = telegramurl + bottoken + "/sendPhoto"
            params = { "chat_id": chatroomid }
            files = { "photo" : open(photofile, "rb") }
            r = requests.get(url, params = params, files = files)
            result = r.json()
            time.sleep(1)
        x = 0
        os.system('sudo rm /home/pi/cam/*.jpg')
3 Likes

Looks like it’s pretty straight forward. The only recommendation I would make is to add a sleep to the end of your while 1 for loop so the script doesn’t consume all the CPU resources when your if statement resolves to False.

That’s sometimes called a busy wait loop because it sits there running as fast as it can but doesn’t do any useful work. The sleep will cause the script to release the CPU so other programs can use it. Even a sleep of .1 (100 msecs) will greatly lower the heating and power consumption of the hardware with minimal noticeable impact to the responsiveness of the script.

Of course you need to experiment with the best sleep value to still get good responsiveness.

There are of course some things you can do to “clean up” the code (there always is) but you should be proud of this script. It’s simple and does what it’s supposed to. It’s easy to understand.

1 Like

[OFF]

I agree! Thanks for sharing :slight_smile:

Thanks for your kind words.
My coding skills are from C64 Basic and a little Fortran77 so it was quite challenging for me.

I will try to find where you suggest a sleep and come back with an answer.

The really only thing I was not able to manage is the ffmpeg part.

Original idea was to save a record of the stream and grab 3 pictures from sec 1 / 15 / 30.
It is doing something similar but do not ask me why :slight_smile:
The video is also quite strange, it seams that I am recording with different framerate as it is streamed or visversa ???