Firstly a very Merry Christmas and best wishes for a successful 2013. I’ve not written many blog posts in 2012 – just been too busy and plan to rectify that in 2013. Anyway, a little fun project to keep the brain cells working over the festive period …
For this project you need a Raspberry Pi (http://www.raspberrypi.org/) The Raspberry Pi allows peripherals and expansion boards to access the CPU by exposing the inputs and outputs. The Raspberry Pi board has a 26-pin expansion header, marked as P1, arranged in a 2×13 strip. Amongst other things this provides 8 GPIO pins.
We need to build a circuit to drive the relay from one of the Raspberry Pi General Purpose Input/Output (GPIO) pins (http://elinux.org/RPi_Low-level_peripherals) as shown below:
The parts required are:
6V 10A PCB Relay
1K2 Metal Film 0.6W Resistor
This circuit is needed as the Pi’s GPIO pins are 3.3V and the maximum current is 16mA which is not enough to drive a 5v relay directly but is enough to switch a transistor on and off. Essentially, to activate the relay, all the circuit does is send a few milliamps at 3.3V from the GPIO pin, through a 1K resistor. This current is enough to saturate the transistor, causing current to flow on the 5V rail through the transistor, and therefore also through the relay’s coil.
The relay circuit wired to GPIO 17 via the 26-pin expansion header:
To control the GPIO pins we install Apache and PHP5 on the Pi and use a PHP library from here: http://www.huubknops.com/rpi-gpio. The following Linux commands do most of the work:
sudo apt-get update
sudo apt-get install apache2
sudo apt-get install php5 php-xml-serializer php5-gd
sudo wget http://www.huubknops.com/rpi-gpio/gpio.tar.gz
sudo tar zxvf gpio.tar.gz
sudo bash -c “echo www-data ALL=\(ALL\) NOPASSWD: ALL >> /etc/sudoers”
All we need to do now is to call the relevant PHP scripts from Web Service blocks within a Genesys IRD based routing strategy:
I can’t think of many real world applications at the moment. If you can then please drop me an email. For now I am using it to turn on a blue flashing light!
Look out for some more posts soon – details of CLiDE (Craig’s Little Development Environment) including SBC, core IN, Voxeo, Sangoma and Genesys integration as well as my own GSM mobile test network using OpenBTS (http://en.wikipedia.org/wiki/OpenBTS) as the base transceiver station (BTS)!