Welcome to our first Labs post on Raspberry Pi.
Our idea was to create something that could alert us to a high priority case in Salesforce, allowing us to assist clients more quickly in the case of an emergency. We considered a number of methods and decided upon Raspberry Pi. If you haven’t heard of it before, Raspberry Pi is a low cost, credit- card sized computer.
Lab #001 - Raspberry Pi Remote
- To be notified about a high priority case by a visual /audible alert in the office
- To remotely control the power of devices in the office
Whilst considering different methods, we came across a brilliant web service called 'IFTTT' (If This Then That) which allows you to create a 'recipe' consisting of a trigger and an action. By creating a recipe with an email as the trigger and a Belkin WeMo as the action, IFTTT would do the rest in the background. However, we decided against this method, as it relied on too many variables; What if IFTTT goes down, or becomes a paid service? What if the WeMo loses Wi-Fi signal?
We then looked at Web Server Power Sockets but found these were expensive and had limited information online, such as what the Web Server ran on and how you controlled the individual sockets. They also required connections to be within a close physical location, plugged into the same power strip. Finally, we looked at a Raspberry Pi. Although we had one in the office, it had been collecting dust at the bottom of a drawer and had never been coded before. We undertook some research and found a USB device called a TellStick. The TellStick is a small radio transmitter that can be controlled by a Linux/Mac/Windows OS. We purchased the TellStick and some RF Plugs and after various tests, managed to pair the two devices together, hearing the sweet sound of a faint click as the plug powered on remotely! Things became a bit more challenging after this.
We needed a way to control the TellStick from a script and found a Python Wrapper that would allow us to do this. With limited experience of creating Python scripts, we brushed up on our Python skills via codecademy.com and started coding! Eventually we managed to make a script that could receive POSTs with variables, including power=on/off, device=(id), time(seconds to stay on for), password=(password). We also created a web interface to make the power controls more user friendly. This worked well, but still wasn't capable of doing what we needed it to do.
It works! The Pi can now control the power via the web interface and via JSON commands. We are currently configuring Salesforce to send the JSON with a trigger and allow the Pi through the firewall to be publicly accessible (with authentication). Once this happens, the project will be complete. Here is one of the devices we have remotely powered using the Pi.
Another big advantage of using the Raspberry Pi and JSON is that it can be easily adapted to work with other programs. We are planning to add an audible device too!
Stay tuned for more Raspberry Pi projects in the future.