All you need to make an intercom with raspberry pi.
This software configured in server mode, run on a raspberry pi, with at least a button, a microphone and a speaker.
You can add a second raspberry pi in your house, with the software configured in client mode.
When someone push the button, it send a notification to the client software and to your phone using pushsafer.
You can speak with your guest and open him the door, either with the client raspberry pi, or from a web page with your phone.
- Raspbian 8.0 (Jessie) to 12.8 (Bookworm)
- Standard C++ librairies
- Boost
- Alsa
- websocketpp
- Jsoncpp
- ssl
- uuid
sudo apt install cmake libboost-system-dev libasound2-dev libwebsocketpp-dev libjsoncpp-dev libssl-dev uuid-dev libspeexdsp-dev
git clone https://github.com/PicoI2/raspberry-pi-intercom
cd raspberry-pi-intercom
cmake .
make
Copy and modify the config-server.cfg or config-client.cfg file to match your configuration.
If using port below 1024 dont forget to do : "sudo setcap 'cap_net_bind_service=+ep' rpi-intercom"
Then run
./rpi-intercom config-server.cfg
- mode (both) server (outside) or client (inside)
- local-udp-port (both) udp receive port for communicating with client/server
- client-ip (server)
- client-udp-port (server)
- http-port (both)
- pushsafer-key (server)
- pushsafer-device (server)
- input-ringbell (server) ringbell button input
- output-door-open (server) output to open door (connect it to a relay)
- output-audio-on (both) output to enable audio
- sound-card-play (both) aplay -l to list available cards
- sound-card-rec (both) arecord -l to list available cards, could be 'default', 'plughw:1'
- password (both) password to use web interface
- server-ip (client)
- server-udp-port (client)
- input-stop-ring (client)
- input-listen (client)
- input-speak (client)
- input-open-door (client)
- input-hangup (client)
- output-backlight-on (client) output to put screen backlight on
Input and ouput numbers availables can be listed with
cat /sys/kernel/debug/gpio
Uncomment "add_definitions(-DUSE_HTTPS)" in CMakeLists.txt
Add your certificate files ssl/privkey1.pem and ssl/cert1.pem
You can create your own SSL/TLS self-signed keys :
openssl req -x509 -newkey rsa:4096 -keyout ssl/privkey1.pem -out ssl/cert1.pem -days 365
But I recommand using a true certificate. You can buy domain name for 3,59 €/year on OVH.
As an example, this is a list of what I use :
- Raspberry Pi 3 B+ (~37€)
- Fisheye 5MP 1080P camera (~14€)
- USB 2.0 Microphone SF-555B (~8€)
- EU Plug 5V 3A converter micro USB (~7€)
- 2W 28mm speaker (~5€)
- LM386 Audio amplifier module 5-12V 10K (~3€)
- DC 5V Songle power relay (~1€)
- 3.5mm mono male plug jack adapter (~0.20€)
- 2N2222 transitor (~0.15€)
You could find in 3d-print directory files to print your own case.
These files can be view with OpenSCAD
In variables.scad, you can replace "DOORBELL" by your family name. Check that your name do not overlap the button hole.
Check or modifiy all diameter to suit your hardware.
If the intercom will be placed outdoor, I recommend to print it in PetG (less sensitive to humidity and UV, and easier to print than ABS).
To handle camera, use motion :
sudo apt install motion
Edit /etc/motion/motion.conf to change theses lines :
daemon on
stream_localhost off
To start motion at startup, edit the file /etc/default/motion
start_motion_daemon=yes
If you have an error message like cannot create log file /var/log/motion/motion.log:
, create the /var/log/motion
and give rights to motion user.
If you have an error message like :
[1:ml1] [ERR] [VID] v4l2_fps_set: Error setting fps. Return code -1
[1:ml1] [ERR] [VID] v4l2_mmap_set: Error starting stream. VIDIOC_STREAMON: Invalid argument
try to run motion with libcamerify :
sudo apt install libcamera-tools libcamera-v4l2
sudo libcamerify motion
If this fix motion, then edit the service file /lib/systemd/system/motion.service to replace motion with libcamerify motion.
https://www.pushsafer.com/
Pushsafer allow you to receive notification on your phone.
It's not free but cheap, with only 1$ you can receive 1000 notifications.
But I would like to find another solution because it's not always very fast.