Skip to content

Create a baby-cam with a Raspberry Pi. Includes a webstream to the Grandparents.

Notifications You must be signed in to change notification settings

george-edwards/babycam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Baby camera with a webstream for the grandparents using a Raspberry Pi

Creates an MJPEG stream which can be served via a web domain using Motioneye for Python.
Contains the number of viewers via a text-overlay on the bottom-left.

screenshot of the babycam feed

Buy the hardware

Install Raspberry Pi OS (Buster)

Download the Rapsberry Pi OS 'Buster' 32-bit version and install it to an SD card. Why not 'Bullseye'? At the time of writing Bullseye changed to a different camera stack which didn't work with the infrared camera I had purchased. I suspect bugs will be ironed out eventually.

You can install it to an SD using the Official Raspberry Pi Imager

Configure the software

Boot up, log in, then update everything

sudo apt update && sudo apt upgrade -y

Using raspi-config, turn on the Camera module, expand the filesystem and increase the memory allocated to the GPU.

sudo raspi-config
  1. Interface > Camera
  2. Advanced > Expand Filesystem
  3. Performance > GPU > 256

Download this repo by cloning it with git

sudo apt install git -y
mkdir -p ~/babycam
git clone https://github.com/george-edwards-code/babycam.git ~/babycam/

Run the installer

~/babycam/install.sh

Setup cron jobs

crontab -e

Replace crontab with the following

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)

SHELL=/bin/bash

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

# turn the LED OFF at 8pm each night
  * 20  *  *  * sudo systemctl start babycam-led-disable.service

# turn the LED ON at 6am each day
  *  6  *  *  * sudo systemctl stop babycam-led-disable.service

# reboot the system at 2am each day
  *  2  *  *  * sudo reboot now

Reboot machine

sudo reboot now

Accessing the admin interface and the stream

Admin interface: Username: admin Password: password

http://<ip-address-of-pi>:8765

Stream: Username: stream Password: password

http://<ip-address-of-pi>:8071

I suggest setting a DHCP reservation so your raspberry pi's local IP address doesn't change.

Create a website to allow grandparents access

Register a domain from Google Domains.
Setup a Dynamic DNS 'A' record for your domain. Current instructions can be found here.
Google will issue a random username and password which will be used to update the DNS using client software.

Setup the DNS updating client software on the Raspberry Pi

sudo apt install ddclient -y
# installation comes with a config wizard. Satisfy the wizard with any settings you want, we will overwrite them later.

Configure the client appropriately.

sudo nano /etc/ddclient.conf

Delete everything in that file and replace it with the following, being sure to add your username and password(s) issued by Google

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

protocol=googledomains
use=web
server=domains.google.com
daemon=100

# yourdomain.com
login=
password=''
yourdomain.com

# www.yourdomain.com
login=
password=''
www.yourdomain.com

Now restart the service

sudo systemctl restart ddclient

And you can test your config using the following:

sudo ddclient -query

And finally, setup a port forward on your home router. Forward all incoming TCP traffic from port 80 to <ip-address-of-pi>:8071.

Infra-red camera fix

If you have an infra-red camera and the picture looks purple/pink, then cleanup the image with the following command and reboot:

sudo systemctl enable babycam-infrared-cleanup.service

About

Create a baby-cam with a Raspberry Pi. Includes a webstream to the Grandparents.

Topics

Resources

Stars

Watchers

Forks