FreePBX Open Source - EntryPi - Raspberry Pi and linphone based door entry phone

FreePBX Open Source - EntryPi - Raspberry Pi and linphone based door entry phone

Table of Contents

Specification

The unit should integrate with a FreePBX/ asterisk system.

The control box should be able to connect to the door unit via a 5 pair telco cable 20 meters away

When idle, the status LED on the door button will flicker off once every few seconds so you can tell the system is operational.

When active, the status LED on the door button will cycle on/off every second.

When the button is pressed, the application find an active proxy (preferred proxy first, then each of the configured proxies) and will dial extension 197 on that registered proxy.

When active and the button is held down for 5 seconds, it will hang up

When idle and the extension the door is registered as is called, it will auto-answer

If active, pressing 5 will open the door

Solution

A customised version of linphonec (command line Voip client that supports audio and video/audio calls).

The pictures show the door phone unit, and the control box (in my case this is 20 meters from the control box). The audio balun(4), opto isolators(2), PTC(6) that you can see were necessary due to this distance.
If you do not need to separate the pi from the door, then you just need pi (1), USB adaptor (3), video PSU (7), network in (8),  and a 5v pi PSU (instead of 9)

Doorphone

 

doorphone.jpg

Contains: 

  1. Speaker

  2. Adafruit electret amplifier and audio balun

  3. Video camera

Control box
control_unit.jpg

 

  1. Raspberry Pi

  2. Opto isolator breakouts (2) + NPN inverter for door open (not needed if control box is next to door)

  3. USB audio, plus screw terminal breakout - replace with video and audio encoder for integrated video and audio.

  4. I used an adafruit electret amplifier going through a pair of audio balun (DO NOT get the adafruit AGC version, get the 3 pin version. As the output level is too high, use a resistor to drop the input) 
     This step down is not necessary if you can connect a mic directly to the USB audio adaptor.

  5. 12volt step down power supply

  6. PTC for the 5 volt supply to the adafruit electret amplifier

  7. PTC for the 12 volt supply to the video camera

  8. Network in

  9. 12 volt power in

mic_input.jpg

Attachments

Source code and binary:

Step-by-step guide

  1. Get the linphone source, and build it http://www.linphone.org/technical-corner/linphone/downloads
    Note: I have attached a helpful web page in the download on how to find belle-sip

  2. Install linphone

  3. Install and configure USB audio device or USB video/audio device

  4. Use the command line linphonec to register and test proxy/ proxy registration

    Check you can call out e.g. call sip:197@x.x.x.x where x.x.x.x is the proxy address you configured
    auto-answer enable, and check system picks up when called
    Only when this is working, move on to the next step

  5. Use install script to install linphonedf, a modified version of linphonec

  6. Alternatives (as GPIO access needs extra rights)
    i) Run as root:
    copy .linphonerc from test users home to root's home (settings for linphone come from .linphonerc is users home)
    sudo linphonedf
    ii) Give permission for linphonedf to access GPIO /sys/class/gpio/export & /sys/class/gpio/gpio%d/value,direction,edge
    linphonedf

  7. Connect door open connection to GPIO 27 (active low), Feedback LED to GPIO17 (active high), SPNO ring button to GPIO4 (with pull up), pull down to ground to ring. I used opto isolators due to distance.

  8. Set up monitoring application to ensure that linphonedf is monitored and will start/ be auto-restarted.

Settings For Echo Cancellation/Limitation 

Please set these as appropriate for your system. The exact settings will depend on your mic/ speaker setup.

[rtp]
audio_jitt_comp=0
audio_adaptive_jitt_comp_enabled=0

 

[sound]
remote_ring=/usr/share/sounds/linphone/ringback.wav
playback_gain_db=0.500000
playback_dev_id=1
ringer_dev_id=1
capture_dev_id=1
mic_gain_db=0.000000
echocancellation=1
ec_delay=113
ec_framesize=0
echolimiter=1
el_sustain=250
el_force=1500
el_thres=0.01
el_transmit_thres=10

 

 

Error rendering macro 'contentbylabel'

parameters should not be empty