The choice of gadgets available to interface with the Internet of Things, the web of interconnected devices that allows developers to write code to interact with sensors, seems to grow every day.
If you have any magpie tendencies, an impulse purchase of a Raspberry Pi can quickly turn into a large collection of tiny machines, including Arduinos and all the cables, breadboards, resistors, diodes, buzzers, buttons and LED lights to make them perform their tricks.
Soon you are creating fascinating projects straight out of MAKE magazine such as the Raspberry Pi-powered weather balloon carrying a toy bear into the stratosphere or the Arduino-powered smart-phone enabled garage door opener.
Simple projects are a great way to teach kids how to program in Python (using a Raspberry Pi to blink LEDS in patterns, for example) or wire circuitry to create useful real-life life hacks using small machines like the Arduino. In this article, I’m going to introduce a relative newcomer to the IoT scene: the Spark Core, a “tiny wi-fi development kit” originally a successful Kickstarter project. To paraphrase Spark’s marketing blurb, “when the internet spills over into the real world, exciting things happen”.
The Spark Core, a wifi-enabled Arduino that comes packaged with its own breadboard, is all about connectivity and ease of use. Instead of writing code locally to power your Arduino or Pi, you can use the Cloud code solution offered by Spark to update the Sparks stashed around your house or office as long as they are connected to your wifi.
For example, you might have several Sparks connected to your house in a hacked-together ‘Nest-like’ system. From the web tools provided at Spark.io or from your local command line, you can ‘flash’ content to the Spark to make all the parts play together seamlessly.
Even with just one Spark Core, you can undertake a lot of fun projects. Using the breadboard on which the Spark is housed, a few connecting cables, a resistor, and a pushbutton, you can make a tool that many parents could use right away: a “kid-summoner”. I’m going to demonstrate how to wire up your Spark to make it interface with the Pushingbox service to send a Tweet to your kids when you want them to come downstairs, perhaps for lunch. It beats yelling up the stairs or wishing you had an intercom!
- A Twitter account via which you can reach the third party person whom you want to summon
- A Pushingbox account (pushingbox.com) — an easy way to create notification ‘scenarios’ for your IoT-enabled devices
Login to Pushingbox and ensure that your Spark Core’s Twitter account authorizes Pushingbox to send tweets on its behalf. Pushingbox has a lot of great services integrated; you can enable voice notification, emails, browser and mobile push notifications. For our purposes, we simply need Twitter enabled.
Next, create a Pushingbox “Scenario” called “Send a Tweet”. Write a message that you want your Spark Core to send, referencing your child’s Twitter account.
“@thing_one @thing_two Soup’s on, please come to the kitchen!.”
Test your Scenario by clicking test on the Scenarios screen. Your dashboard will log all instances where the Scenario is called:
Following the instructions on Spark.io, ensure that your Spark is enabled on your local wifi. Using Spark’s mobile app helps with the ‘claiming’ process so you can associate your Spark Core with your wifi. I found that my sometimes shaky home wifi caused a few issues, but with a little patience the Spark Core will run reliably. Install the command-line tool belt for fine-grained control of your cores: docs.spark.io/cli/. You can ‘claim’ or reclaim your Core via the CLI. Full instructions on installation and troubleshooting can be found at docs.spark.io.
Now, you need to get your circuitry configured. Using the diagram below, use the Spark Core’s breadboard, a push-button, six male-to-male cables, and a 10K ohm resistor to produce a switch with which your Spark can interact.
To test whether your circuitry works, open your terminal and while the Core is still connected to your computer, and after ensuring that the CLI tool belt is installed on your computer, type:
spark cloud login
to send your credentials to Spark.io. Once you are logged in, verify that your Core is available:
Now, navigate to the web-based build tool. Here, you will write code in the cloud that can be flashed to your Core.
In the Web IDE or Build area of the Spark.io website (spark.io/build), login and create a new app. I called this one “kid-summoner”. If you are familiar with Arduino, you will be at home here as the language used for these devices is the same. Since our app is simple, we only need one
Save and ‘verify’ your code in the IDE. Add the ‘DEVID’ from the Pusherbox scenario you created earlier on.
Make sure your Core is live, connected to wifi, and ‘breathing’ cyan (the central light on the Core has several color states; when it is ‘breathing’ cyan color everything is fine). When ready, click the ‘lightning’ icon on the IDE. Your Core should start flashing in a series of color changes. When it is ‘breathing’ again you can start testing your installation.
Go ahead and push the button! You should send a tweet to your child’s account. To troubleshoot, check Pushingbox – the tweet should show up in its dashboard. In addition, you can set up debugging code and monitor its execution in the terminal:
spark serial monitor
Any debug code will be visible as printed lines. You can untether your Core once everything is working and install it in your house somewhere. I put mine in my kitchen so that when I am ready to serve a meal, I can push the button and the kids will receive a tweet. Since the device is on wifi, you can make any edits to your code and flash it again to refresh your Core. It is pretty magical. Here’s a video showing it working:
Pushing a button to send a Tweet, of course, is a simple, beginner-level project.
Options to extend the project could include:
- Passing variables to customize the messages
- Adding location coordinates to invite people to different areas of your house
- Create an array of buttons that would summon different third parties or send different types of messages
- Add motion sensors to enable other kinds of gestures
The Spark Core allows you to create all kinds of sensor-enabled applications — my next project may be a motion-sensor to allow my clothes dryer to email me when the dryer cycle is complete. That would be useful, right?
To create beautiful circuit diagrams, I recommend Fritzing, which has a great app: fritzing.org/home/.
Make Magazine (makezine.com/) is a great resource for inspiring projects.
You can buy parts for your devices at Adafruit: adafruit.com/.
Jen Looper is a Boston-based web and mobile developer, specializing in cross-platform educational and fitness apps for iOS, Android, Nook, Kindle and Windows phone. View her portfolio at www.ladeezfirstmedia.com.