qtitnz
Posts: 4
Joined: Wed Jun 27, 2018 10:28 pm

Bell System - School

Wed Jun 27, 2018 10:35 pm

Hi team,
I have RPi3 B+ with PiFace Digital 2 Interface
Alarm people at school has installed a 2 way wire to turn Amplifier on and off as well as stereo cable to plug to RPi, this amp controls alarms as well as bell system at school.

Wanting to achieve the following scenario:
- via relay, switch AMP on
- play wav file for 15 seconds to replace the current bell sound
- via relay, switch AMP off
- repeat during school brakes Monday to Friday (10am, 12pm, 3pm etc etc)

Can anyone maybe shed some light to achieve this ?

Thanks

W. H. Heydt
Posts: 10618
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Bell System - School

Thu Jun 28, 2018 5:15 am

1. Write a shell script that does what you want. Be sure to either include setting the PATH variable inside the script...or give everything ablsolute paths.
2. Use cron (edit using "crontab -e") to set the times and days of the week you want the script to run. Again, point to the script using an absolute path.

Note: The reason for using absolute paths is because the normal environment variables, such as PATH, are not set. You are not running in a login shell.

pcmanbob
Posts: 6450
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Bell System - School

Thu Jun 28, 2018 5:20 am

- via relay, switch AMP on
The piface I believe already has relays on board so you simply need to connect the 2 wires to the relay terminals , one you connect to common the other to the normally open contact, then when you activate the relay the amp will be turned on.
- play wav file for 15 seconds to replace the current bell sound
you can play a wav file with aplay which is installed on raspbian by default, at the command line like this "aplay somewavefile.wav" if you wave file is 15 seconds long then then it will play for 15 seconds

- via relay, switch AMP off
see switch on above
- repeat during school brakes Monday to Friday (10am, 12pm, 3pm etc etc)

you can run programs to a schedule using cron

so for example using crontabe -e

you would enter this line for the 10am playing.

Code: Select all

0 10 * * 1-5 aplay /home/pi/name.wav
you can do the same to call the program that will activate the piface relay you simply need to have a delay in the program between turning relay on and then off again, you would call this a minute before the play command so the amp has time to power up.

this web site will help you with creating the correct cron line entries https://crontab-generator.org/
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

DirkS
Posts: 9877
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Bell System - School

Thu Jun 28, 2018 6:03 am


texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Bell System - School

Thu Jun 28, 2018 6:39 am

DirkS wrote:
Thu Jun 28, 2018 6:03 am
Duplicate of viewtopic.php?f=37&t=216919&p=1333899#p1333899

And locking, as such.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “Beginners”