After receiving our developer April Electric Imp board we quickly started to think of some small projects that we could build that may have a real world use. Given the Electric Imp’s ability to receive inputs via the web this allowed us to also easily build an “app” that could be used on the iPhone (or any other mobile device with an Internet connection. That’s when Matt had the idea to build an iPhone powered coffee pot using the Wireless enabled Electric Imp developer board.
Hardware wise we powered the Imp from the control board of the coffee maker. We wired the On/Off switch of the coffee maker to the April Electric Imp board via the 3.3v pin and the #8 pin. We powered the imp internally via a chopped up a USB cord that’s wired to a powered pin instead of soldering to the Aprils pads. We also did this because if the Imp is not on the physical on/off button on the coffee maker will not work. The fact that we don’t have to replace batteries on the Imp doesn’t hurt either.
Here is the coffee pot that we ended up using. We wanted something cheap and simple.
Developing for the Imp is quite unlike most embedded development. No SDK to install, no JTAG pods, no long download times… you develop your code in a browser-based IDE and can compile and run your code on the Imp – wherever it is in the world – in under a second. The Imp even sends logging back to your browser.
Software that runs on the Imp is written in Squirrel, a C-like language, with extensions to communicate with the hardware interfaces and the service. As the Squirrel code runs on top of our OS, you get many big system benefits like buffered I/O and crash recovery – plus you can push updates to devices in the field with a few clicks.
The application code for this project is fairly simple and straight forward. We basically defined two distinct input ports that would map to the data we would receive over HTTP. These input ports would be mapped to HTTP IN nodes to control turning the coffee pot on and off. We then configured pin 8 on the Electric Imp to be a digital output. Next we just had to tie it all together via the imp.configure method.
When we received an input value from either the on or off HTTP IN node, we would update the display in the planner via a server.show call, and then we would send a 1/0 (on/off) to pin 8.
Here’s how the code in the planner looks (you can download the full application code here).
Here’s the Imp in the planner with the HTTP IN nodes defined and wired up to our inputs defined above.
Here’s the Imp’s display updating once inputs were received via the HTTP IN nodes.
Lastly we needed to build a simple website to send data to the Electric Imp via the HTTP IN nodes we defined. This is a simple web page that has two separate form posts to the addresses defined by the Electric Imp Planner. Each form has a single button that sends a value to the appropriate input. Once received, the Electric Imp planner returns a status code of OK.
Here’s a video of the entire process showing activating the actual coffee pot from the web via an iPhone. While not something you would generally need, this was a fun exercise that allowed us to do something cool with the Electric Imp. It also was pretty fun to let co-workers brew their cup of coffee via their cell phones 🙂
Hardware: Matt Everts @matteverts