Raspberry Pi Project Ideas: How I Built Call Mom Button
Coming back from PyCon 2013, I was looking for interesting Raspberry Pi project ideas that would attract the attention of both non-programming students and those with more experience. I was averaging one Raspberry Python class each month at my hackerspace, MakerBar.
I decided that the project should relate to Mother’s day and have something my students could take home or perhaps even give to their Mom as a nifty gift. I had a few new services in my mind including some cloud APIs like Stormcloud and Plivo which I ended up using for my Raspberry Pi project.
So I decided to teach my students how to access a web API and settled on the Call Mom button—a Raspberry Pi board with a set of four buttons connected via Plivo, which gives you not only the titular Call Mom button, but also a Call Dad button—just to be fair with Dads—a “Text Mom I love her” button, and a spare button which students could use however they want.
With this Raspberry Pi project, I had won Twitter contest sponsored by Plivo at PyCon and my students had a great time building their own buttons in class. Now let me share how I built Call Mom using Raspberry Pi and Plivo.
What is Raspberry Pi and Plivo?
I'm not sure that the Raspberry Pi needs any introduction, but I will leave some notes here for those who are not so familiar with what a Raspberry Pi is.
What is Raspberry Pi?
I generally refer to Raspberry Pi as an equivalent to a desktop computer from about 2003.
The key specs of Rapsberry Pi (a.k.a RasPi) are:
- Linux based operating system
- 700 MHz ARM11 CPU
- 256MB (or 512MB) RAM
- SD Card Storage
- 2 USB ports
- Composite and HDMI Video out
- Stereo audio out
- 8 GPIO pins
- Wired Ethernet
It's less protected than say an Arduino, but it’s still pretty sturdy. To learn more check out the official website of Raspberry Pi.
What is Plivo?
Plivo offers APIs that give you ability to make and receive calls or text messages on your apps. If you're familiar with the HTTP logic, making calls using its APIs and XMLs is very easy. It was an interesting challenge for this class as Plivo assumes you'll use a web app to communicate with it.
How did I end up using Plivo? Basically it was because of their weird-looking bottle opener that I first saw at PyCon. I was checking out different booths at that time, but honestly they had a peculiar bottle opener that caught my eye as I passed by:
How My Raspberry Pi Project Works
1. RasPi Circuit Diagram and inputs flow via GPIO.
The inputs are very simple since they were meant to be only a small portion of the class. I hooked up a four button keypad to four of the Raspberry Pi GPIO pins as inputs and then run a continuous loop to check if the buttons have been pushed.
2. Call flow via Plivo Voice API
Plivo normally expects that you’ll be using it for a web app so I had to fake that somewhat. Rather than building a full web app, I just had each student create a single page that had at least the minimum viable xml to dial a specified number in response to the call being answered. We also played with having a little more in that xml file. But basically we told Plivo that it was a web service and Plivo was ok with that. We used Python Anywhere for this mostly so the students would walk out with an account there.
Then you will execute a script that will make a HTTP GET request for “answerThenCallMom.xml" which could be as simple as this:
This was the barest of barebone examples. The Plivo docs have a lot more examples, usually based around changing the answer xml. For example, in the class we experimented with having Plivo voice synthesize a “connecting you to your loving son…” message and Plivo actually has a lot of other options there, but many of them require a web application for a two-way conversation.
3. You can check the code for my Raspberry Pi project on Github
More Thoughts on RasPi
I'll teach this same class again at The MakerBar in Hoboken on November 10th and I am continuing to work on other Raspberry Pi projects for the series. A lot of students have requested motor controls or serial interfaces, so that's a definite future class.
1. Cooler Raspberry Pi Idea: feedback-enabled Button
While preparing this post I decided to try a little bit of the same on an Arduino. Since that's even less powerful I've started building a sort of a proxy server to set up a menu using Flask and Python. If I had that same feature on the Call Mom button project I could provide feedback to the device, probably a light reminding you when it’s time to call your Mom.
Another fun possibility would be to have a feature where the button finds out if Mom is at home by checking whether it goes to voicemail or not and lets you call only to leave messages--not to start a conversation.
2. Another Raspberry Pi Project idea: Done Done Button
The next cool Raspberry Pi and Plivo integration I am thinking to build is a 'Done Done' Button for The MakerBar. Members finish projects at all different times and I think there should be a certain amount of recognition for a project completed.
The Done Done button would be a big big button I originally bought for this project connected to a Raspberry Pi and a RFID reader. Whenever the members or guests finish a project, big or small they’ll scan in and slam the big button. When someone pushes the button it will send a text message to a few other members with the member completing the project identified by RFID.
3. Suggestion for Plivo
(Hear me out, Plivo team) The biggest thing for these kind of Raspberry Pi project ideas would be an interface not based on callbacks. I could open an ssh channel or use a comet paradigm to check in, but having to stand up a server is an unnecessary complication and really does keep the Call Mom button from being practical. Removing the https is probably a pipe dream, but would be even better--opening this up to Arduino applications.
Andy Fundinger is a professional Python developer and trainer. He's been programming for almost 28 years and in Python for 8 years. His passion lies on hacking hardware and teaching people technology at MakerBar, the only hackerspace in Northern New Jersey. Cross world web services and interconnected objects aka the internet of things is a particular interest of his. For questions, drop him a line at firstname.lastname@example.org.