Archive | May 2017

New campus bell system

So I’ve finally got around to dealing with the old bell system at my campus. The existing system was a single-board programmable timer system with 4 relays. It allowed for 4 different timetables, pulse or latching mode for the relays and had a daylight savings option (manual). This system was connected to a tone generator for the bells (the bells can also be operated manually and the TG also has emergency sounds) as well as to a CD player for music at various times of the day. One of the relay outputs (for the CD) runs via an Electronics Australia timer kit in a Jiffy box, extending the

Pros: Easy operation – switch on and it runs, couple of buttons and we’re on to the other timetable, one switch and it’s off

Clock is reasonably easy to update

Cons: Clock loses time reasonably quickly – this is a pain when all staff and students have laptops that sync to ntp

Programming new timetables (for special events) is a giant pain, particularly dealing with the different relay modes – we usually just get the office ladies to ring the bells manually all day (setting reminders in their iPhones for each new bell)

The CD trigger is hard-wired into the back of the CD player button circuit board and functions as Play/Stop meaning we get the first track of whatever CD is in there. EVERY. TIME. Until someone in the office changes track manually once it starts or changes CD.


We were quoted on a few replacement rack-mount USB/SD audio players with CD built in and logic inputs to accept the timer unit triggers. These were minimum AUD$800 and only solved the music problem. For the minor mental health benefit of hearing different music, it wasn’t worth the money or hassle.

The other option was to go for a computer-based replacement system. There are a few different Windows-based bell apps that I tried. TimeChimes was OK for a simple system that didn’t need many options but didn’t really address all our issues (free to try).

A few others offered similar functionality and still didn’t quite cover what I wanted (seeing as I’d be implementing it – another of my jobs that aren’t actually my job).

I just found Bell Commander whilst writing this article and it looks nice and functional but I haven’t tried it as I didn’t see it when searching months ago.

All of the software options above could have been implemented but would have required a Windows machine to operate – not a big issue when we turn over a third of our staff laptops each year but modifying anything would mean either using Remote Desktop in to the machine (hoping it didn’t break the software operation) or having the laptop accessible without it being easy to mess up.


Enter the Raspberry Pi that had been sitting in my desk drawer for a couple of years after I realised that I just was not going to use it in my Year 7 ICT. I looked for a few Linux bell apps then realised that all I really needed was a scheduler that could easily be updated. Crontab (the Linux task scheduler) reads text files and is reasonably easy to update. Apache provides a web front-end that allows the office and myself to run bash scripts to do the updating and to check current system info (time, current timetable, etc). It gets an IP address from the school admin network and time from the same ntp that all our computers use. I have remote access through ssh (using PuTTY on Windows). Music gets uploaded via SFTP (FileZilla but the protocol is slow) or FTP (Windows ftp mapping).

The crontab bell times run as the Pi user. Crontab keepsĀ a single day worth of bell times, programmed to run Monday-Friday. I have a folder of crontab data files as masters and each time a new timetable is needed, crontab is updated with one of the timetable masters, replacing whatever is currently running. I have master files for Normal Day, Early Leave (once a fortnight and for Parent/Teacher Interview evenings) and a Special file which gets modified and backed up for each new day we need. The Web interface has a button for each Timetable Type, which runs a bash script through /cgi-bin to update crontab.

Throughout the day, it runs aplay to play a wav file recorded from the tone generator as teachers were complaining about my test sounds :(. There is also a script that randomly chooses an mp3 file from the music folder and plays it before homeroom, after recess and at the end of lunch. This random music has earned me big brownie points with the office ladies! Timing was excellent, getting this going just before Eurovision 2017 – have spent the last week listening to the album – 15 random songs out of 25 on the album (though had 2 repeats). Music can be changed simply be deleting the files from the mapped folder and adding new ones (can’t wait for Maths week and the Times Tables songs…)

Bonus Features:

Another issue that’s been raised after evac drills is that if anything was to happen at the office (fire, crazed gunman, etc) the whole system would be rendered useless as there are no tie-in points around. The head of campus has already scripted a few emergency announcements that I’ll record with him when I get a spare few minutes (senior timetable is due…) and these will be placed on a separate page potentially with some basic access restrictions, although noone else knows where to find the controls anyway… The only downside to this is that currently the Pi sits on our admin wired network which is only accessible to school-provided devices (wired or wireless) and not our phones. Any non-school devices (like our mobiles when we’re on the oval) get a 192.168 IP which has no access to the Pi. I’m waiting on a pack of $3 USB wifi-N dongles so if I can get this to work alongside the wired interface, then it’s a bonus, although need to run this through IT as it potentially creates a bridge across the VLAN security.

Future Improvements:

I need to add a web button to ring the bell manually so that if it’s turned off (there’s a button for this) and a bell should have rung before the system is turned back on, a bell can be rung without having to get up and go to the tone-gen (I could have rung it from my classroom when we forgot last week).

AA the IT manager suggested it’d be nice to have a calendar to automatically change the bells. This is not a major operation but will take a bit of time to set up. Crontab can operate independently per user, so the Pi user controls the bells/music and the Root user controls which Pi crontab is running. Our timetable is normally stable – 9 days out of 10 are the same and day 6 is always the same (but different to the other 9). All I’ll need to do is set up a root crontab file with the dates of the Early Leave days – 2 entries per day. The first entry at 6am (before I get to work) updates the Pi user to Early Leave. The second entry updates it back to Normal. At any stage, we can manually override this if there is a change. Linux has a function that allows users to have password-free access to run commands as another user, although it has to be pre-allocated using visudo to edit the /etc/sudoers file. This means that cgi-bin scripts can run as root in certain cases.



So far, the school has not provided any money for this (most of Exec don’t even know it’s happened…).

Pi: some money spent on it a couple of years ago and have just purchased a couple of Orange Pi Zeros to test.

SD Card: 4 Gb I had unused from a random Android device.

Power: USB charger and cable I had lying around.

Ethernet cable: nicked from IT

Audio cable (3.5mm trs – RCA pair), from Pi to 100V PA: borrowed from Music office.

Programming/testing time: about a week of late nights and some work hours debugging. It ran in my office for a day prior to being commissioned.

To be rolled out elsewhere, I doubt there’d be more than a few minutes required to modify things such as hostname. Maybe I could create more relevant/secure users too…


I’ll post some examples later.