How to Build a Motion-Sensored IoT ''Smart'' Pumpkin
How to Build a Motion-Sensored IoT ''Smart'' Pumpkin
In preparation for Halloween, or any holiday, learn how to connect a pumpkin to the Internet so you can give it commands—and scare your colleagues, friends, and family.
Join the DZone community and get the full member experience.Join For Free
Halloween has always been a fun time to experiment with creativity, and while it might be March, it's never too early to start your plans. We decorate, we carve pumpkins, we wear costumes; all for the spirit of Halloween. With technology like smartphones, smart office buildings, and smart houses — why not also have a smart pumpkin? There’s no better way to scare neighbors and/or coworkers than with a talking, motion-sensored pumpkin.
A Quick Overview
The goal was to get the pumpkin to detect when someone is present and then engage (read: scare) that individual with a witty pun or one-liner. In order for that interaction to happen, we needed to build a couple of integrations. We gave life to the pumpkin by adding internal lights. For full effect, we set it up to change color at random when it senses someone nearby with a sensor. Then we synced the light with a Bluetooth speaker – the voice of the pumpkin – which is triggered when the light changes. The light change prompted the pumpkin to say a preset phrase like, “Hey, I see you.” This works as intended to get people to pause and wonder what’s happening. Meanwhile, the pumpkin, connected to the cloud and in no specific order, pulls from a list of one-liners, jokes, or punchlines in a Google Spreadsheet.
As a test, we set the pumpkin up by a box of doughnuts in the office. The doughnuts, of course, were just bait to make sure people walked by since no one can resist doughnuts. Check out the results below:
Now, let’s talk about how to build something like this on your own.
The "Gut" Of The Project
Here is the list of things you will need for this project:
- A Pumpkin (real or fake)
- Philips Hue: A smart light that will change colors upon recognition of a person. Great for added oomph.
- Intel Edison: This is the brain of the operation. It is tiny computer that will power the text-to-speech (TTS) translation and audio playback through the Bluetooth speaker.
- Bluetooth Speaker: This will serve as the pumpkin’s voice.
- PIR Sensor: This is a motion sensor that we can plug into the Intel Edison directly.
- Losant: Losant makes it easy to collect and send data to and from devices.
- Built.io® Flow Enterprise™: Built.io helps integrate with the different APIs like Google Sheets and Philips Hue.
Constructing Your Frankenstein Smart Pumpkin
Choose a Victim
Here is the fun part. If you have a real pumpkin, you’ll need to carve it. After carving the pumpkin, you'll want to put a hole in the back (depending on the size of your light fixture) to place the light into the pumpkin. This makes hiding wires and other unsightly things much easier.
Sometimes it can get really messy with a real pumpkin, so fake ones are just as useful.
Build and Connect the Brain
Start with the lights. You will need an Internet connection to connect your Philips Hue bulbs to your Philips hub. Follow Philips Hue’s easy setup instructions to get started and note that you’ll also need to sign up as a developer on their site. By getting developer access, you’ll be able to give Built.io Flow Enterprise’s integration platform permission to remotely control the lights when people walk buy.
Next, move on to the Intel Edison. At its core, this tool is just a really small yet powerful computer. So, we will need to get all our project dependencies installed.
Here’s how to setup the Intel Edison:
- Set up the Bluetooth speaker and playback.
- Install Festival, the Text-To-Speech (TTS) software.
- Connect the PIR sensor to the Intel Edison.
- Grab smart pumpkin code from GitHub.
In this example, we simply used the default voice. It sounds a little robotic, but you can use a more human-friendly voice service like Watson or Alexa as well. Here is an example of how to get that set up. While using the festival TTS, the default voice was the most understandable in real-time.
Bring It to Life in the Cloud
Losant is an IoT platform that makes it easy for us to connect our devices to the cloud and take action on that data. Every 10 seconds, the Intel Edison will send the motion sensor reading to Losant. Losant has a drag-and-drop workflow engine to interact with the data. This workflow is triggered by the Intel Edison. When Losant receives motion sensor data from the device, it checks to see if it detects a “true;” if so, the system sends a message to Built.io Flow – which is triggered by a webhook – to run its workflow.
Built.io Flow Enterprise’s powerful integration platform-as-a-service (iPaaS) engine makes it easy to connect and integrate hundreds of APIs and turn everyday things into smart devices. Losant’s workflow in Built.io activates the Phillips Hue light and makes it change colors, and then it randomly pulls a one-liner or pun from our Google spreadsheet to deliver back to Losant. In doing so, Losant commands the speech through the Bluetooth speaker.
“Which ghost is the best dancer? ...The Boogie Man!”
The Possibilities Are Endless!
This pumpkin is cool, amusing, and very easy to put together – it took just a day to build. If given more time, we would’ve increased the creep factor in many ways. Here are some other ideas that came to mind:
- Attach a microphone to add two-way communication between the recipient and the pumpkin.
- Attach a camera to detect and engage in live conversations with individuals walking by.
We hope you enjoy building this connected pumpkin as much as we did.
For more inspiration, Losant has compiled a list of great tutorials and projects you can try your hands at. Also, check out Built.io Flow Enterprise’s integration library, which includes hundreds of integrations for work applications and other things that have APIs. So, the possibilities are endless!
How do mummies end a conversation?
"And that's a wrap, folks!"
Published at DZone with permission of Taron Foxworth , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.