If you are interested I have uploaded a little "how to" for make your raspberry pi as an IP Door bell.laptopu wrote:This is interesting work, thanks for posting your achievements. I am looking at incorporating a doorbell via the GPIO pins in an Asterisk PBX system. Using http://www.raspberry-asterisk.org I intend to set up an in-home PBX but when a doorbell is pressed it will ring the handsets for 10 seconds. What sort of script would I need to use for this, and is it just a simple case of connecting two pins via a doorbell push to trigger a script?
Yes. Actually if you only want to trigger calls to your phones you don't need the USB sound card and don't need to compile alsa or oss support in your asterisk. I attached it in order to simulate an IP Intercom like the single button from this company http://www.its-tel.com/index.php?Itemid ... item_id=11laptopu wrote: Would this setup work without a sound card, if the only thing I wanted to do was make all the Asterisk telephones ring?
No you don't need the LED. You just need to attach the Button to the GPIO.laptopu wrote: And what if I only wanted a bell push, no LED light, would I just need to ground one of the GPIO pins?

Code: Select all
#!/bin/bash
while true;
do
cmd=$(cat /sys/class/gpio/gpio17/value)
if [ $cmd = '0' ]; then
asterisk -rx 'originate local/s@fromdoor application Playback beep'
fi
sleep 1
done
Code: Select all
[fromdoor]
exten => s,1,SET(CALLERID(name)=From DOOR)
same => n,Dial(SIP/5001&SIP/5000,10)
same => n,hangup()
Which command should/can be used to create a "real" call?asterisk -rx 'originate local/s@fromdoor application Playback beep'
Hi, take a llok on my blog http://raspimods.blogspot.mx/2012/09/po ... ta-de.htmlchrisidc wrote:@navaismo:
Which command should/can be used to create a "real" call?asterisk -rx 'originate local/s@fromdoor application Playback beep'
I mean a call from the asterisk server to be able to talk with an other client?
I am currently also trying to create such door bell and the pi should be act as asterisk server + sip client.
I searched the whole day, but was not able to find a solution to use the asterisk server also as sip client.
If you want to add another LED you need to enable another OUTPUT. Choose your preferred PIN and set as output. I.E. Let use the PIN 22 to add the ledlaptopu wrote:Yes it is exciting stuff indeed. I am still keen on getting an LED to light for say 2 seconds when the button is pressed just to acknowledge to the caller they know the button works but I'm struggling to understand how to build this into a circuit and how to write a script.
I also read in a newspaper today lots of schools are looking to buy Pi's to develop children's skills, I think this is amazing and exactly what we need.
Code: Select all
echo "22" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio22/direction
Code: Select all
while true;
do
cmd=$(cat /sys/class/gpio/gpio17/value)
if [ $cmd = '0' ]; then
asterisk -rx 'originate local/s@fromdoor application Playback beep'
echo "1" > /sys/class/gpio/gpio22/value
sleep(2)
echo "0" > /sys/class/gpio/gpio22/value
fi
sleep 1
doneCode: Select all
#! /bin/sh
# /etc/init.d/door.sh
### BEGIN INIT INFO
# Provides: doorbell
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start:
# Default-Stop:
# Short-Description: Allows monitoring of GPIO for doorbell
# Description: Monitors GPIO 17 (physical pin 11) on Pi
# If shorted, will activate ring group.
### END INIT INFO
case "$1" in
start)
echo "Starting doorbell"
# run application you want to start
/etc/init.d/door.sh
;;
stop)
echo "Stopping doorbell"
# kill application you want to stop
kill /etc/init.d/door.sh
;;
*)
echo "Usage: /root/door.sh [start|stop]"
exit 1
;;
esac
echo "17" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio17/direction
while true;
do
cmd=$(cat /sys/class/gpio/gpio17/value)
if [ $cmd = '0' ]; then
echo "Dialing"
asterisk -rx 'originate local/s@fromdoor application Playback beep'
fi
sleep .5
done
exit 0Code: Select all
#!/bin/bash
# sensing door daemon
# chkconfig: 345 20 80
# description: check if the button on GPIO17 was pressed
# processname: ipdoor.sh
DAEMON_PATH="/root/"
DAEMON="./ipdoor.sh"
DAEMONOPTS="&"
NAME=door
DESC="Check If the Button on GPIO17 was pressed"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=`cat $PIDFILE`
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac
Code: Select all
# chkconfig --add door
#chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
door 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Code: Select all
# service door status
Checking door... Running
service door stop
Stopping door Ok
# service door status
Checking door... Service not running