Introduction: Internet of Toots (IoT): a Social Whoopee Cushion
Step 1: Materials and Skills
The hardware side of this project involves buying a sound-effects machine and adding wifi capability to it. You'll need basic soldering skills (mine are pretty bad but got the job done) and basic familiarity with Arduino.
- Fart machine. I used this one:
- ESP 8266. I use this breakout board from Adafruit: https://www.adafruit.com/products/2471, $10
- Battery. I used a 500 mAh LiPo: https://www.adafruit.com/products/1578, $8
- A small switch like this: https://www.adafruit.com/products/805, $1
- soldering equipment, wire
- access to a 3d printer
- screws - I used long M3 machine screws to put together the newly-enlarged case.
- washers - I used a few small washers to space the screws because they were a bit too long.
- glue - for attaching the switch to the case
- LiPo battery charger to charge the battery, such as
FTDI cable to program the ESP8266, such as https://www.adafruit.com/products/284 ($15)
Total bill of materials is about $30plus
Screws: I would have liked to use M2.5 screws but I couldn’t find any that were long enough at my hardware store. As a result I used M3 machine screws (larger diameter) and had to drill out the holes a bit to keep the plastic case from cracking with these screws.
Washers: my screws were a little too long. You could cut them off if you have a grinder. Instead I just added a few small washers as a spacer to set off the screws from the case.
Step 2: Dissecting the Fart Machine
Open up your fart machine. Start removing screws to get inside and to free the breadboard. You'll see that this model had a nice breadboard that has a round test pad for each button. This makes it super-easy to add onto. They should really be marketing this as "the hacker's favorite fart machine". I don't know why their marketing department hasn't hired me yet.
I previously purchased a different noise maker that had a remote control and it was much harder to hack without using the remote because it didn't have these nice test pads. So I recommend this one. I did the research for you to save you this mistake.
Once you have the fart machine all opened up, you can remove the rubber piece that has the buttons - we won't need this anymore. We'll also remove the batteries and the metal contacts under them so that we can cut out the bottom of the battery compartment. This will become the access door for reprogramming and recharging the battery.
Use a dremel to cut out as much of this batter compartment as you can while still allowing the battery door to attach securely.
The use the dremel to remove the small plastic rails on the inside of the front cover between the buttons (see pics). This will make space for the battery here.
Use the dremel to cut a hole in the case for the switch.
Step 3: Enlarging the Case
The original case is not large enough to squeeze in the ESP8266 board and the larger battery. I addressed this by 3D printing an “extension” of the sides of the case to make it taller and using longer screws to sandwich the extension between the original top and bottom of the case. In fact it looks like an ice cream sandwich. A tooting ice cream sandwich.
The file I used for 3d printing the sides is attached. I also designed a new one-piece back of the case that you could print, to keep the case two pieces instead of three. I’ve attached the file, although I did not actually print and use this version. If you do, I’d love to hear how it works for you and if it fits the original battery door like I hoped.
Because I couldn't find long screws of the same diameter as the originals, I had to drill out the hole in the new 3d printed sides as well as the original case. If you get matching screws you can skip this.
Step 4: Wiring
Here's where it gets real.
The wiring schematic is shown above. I suggest the following approach:
- Remove the existing power and ground wires that connect the sound machine PCB to the original batter compartment and solder new power lines to the PCB + and – pads.
- Charge up the battery. Wire the battery, switch, and JST connector, soldering as shown. The switch gives the IoT device two modes: ON and OFF/CHARGING. When the IOT device is in the OFF position, the battery can be charged through the JST connector. You can use a small LiPo charger such as [insert link to LiPo charger].
- On the ESP8266, solder a wire connecting GPIO pin 16 to RST. Then solder short (2-3cm) wire leads to each of the pins needed for programming the ESP8266. You might want to skip ahead to the programming now and program the ESP8266 before you attach everything else and put it in the case.
- Select which three sounds you like best out of the nine available, and solder wires to the test pads for those three sounds on the PCB. See note below about using more than 3 sounds.
- Connect the power lines from the switch (positive) and ground (battery) to the ESP8266. Connect the wires you soldered onto the PCB in step 4 above to the GPIO pins on the ESP8266 shown in the schematic. Connect the PCB power lines from step 1 above to the GND and 3V out pins of the ESP8266 as shown. Solder all of these connections to the ESP8266 once they are in place.
As you are wiring the parts together, keep checking the layout in your case to make sure you have adequate wire lengths for the way the parts will be fit into the case. You’ll flip over the PCB from its original orientation, and orient the ESP8266 to make the leads for programming the ESP8266 (and the reset and GPIO0 buttons) point toward the battery access door so that they can be reached for programming when the door is open. Position the switch in the case and glue it into place. See photos for details.
Note on number of sounds: In early prototyping, I originally thought I could use more than three sounds by using additional GPIO pins on the ESP8266. However, because the ESP8266 pulls several of these pins high during startup, every time the ESP8266 wakes from sleep mode (i.e. every few seconds) it would unintentionally activate a sound attached to those pins. It may be possible to change this but I didn’t find a way during my testing and prototyping.
Step 5: Online Setup
You’ll set up and connect three different services to make this work: Twitter, IFTTT (If This Then That), and Adafruit.io. You’ll use these to create a basic workflow so that every time a tweet mentions your Internet of Toots account, IFTTT sends a data point to Adafruit.io and then your IoT device can check Adafruit.io every few seconds to see if there are any new data points and respond to a new data point by tooting.
First, set up a twitter account for your IoT device. You’ll create the account you want – mine here is called “InternetOfToots” – you can call yours whatever you want.
Second, set up an adafruit.io account if you don’t already
have one. Create a feed called “IoToots” in your adafruit.io account. Create a dashboard that you can use for testing that contains this “IoToots” feed. I set mine up with a slider that that can be switched to values between 0 and 4 to help testing, but you won’t need this if everything works perfectly the first time (does that ever happen?). Adafrut.io is in beta but is a nice, easy-to-use IoT service so far. More in-depth instructions for setting up an Adafruit.io account, feed, and dashboard are here: https://learn.adafruit.com/adafruit-io-basics-feeds
Third, set up an IFTTT account if you don’t already have one. Then create an IFTTT “recipe” as shown in the graphic shown above: If a tweet mentions @[your IoToots twitter account] then send data to Adafruit.io. Set up IFTTT so that the data sent is “4”. The IoToots device is programmed to select a random sound when it sees a data point “4”. When you’re setting up this recipe, it will require you to connect your Adafruit.io account and your Twitter account to IFTTT. Do this.
Now when you log into your Adafruit.io account and view your IoToots dashboard, when a tweet from any account mentions @[your IoToots twitter account] you should see a new data point with a value of “4” show up on your IoToots Adafruit.io stream. This means your three online accounts are working together as intended.
I found that total toot latency in the system (time from sending the tweet to hearing the toot) varied from <5 seconds to ~4 minutes. I’m not sure what causes this difference. I also tried two different IFTTT recipes: one that was a search for @InternetofToots and one that triggered on “mentions of you”. The “mentions of you“ trigger seemed significantly faster than the “search for” trigger. So I recommend using the “mentions of you” trigger.
Step 6: Programming the IoT
Let's program your IoT device!
The ESP8266 can be programmed in a couple different languages/environments. Thanks to the hard work of many people, it can be programmed easily via the Arduino IDE, so if you’re familiar with Arduino, this will be easy.
First, set up your Arduino IDE to program the ESP8266. For information on how to do that, look here https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon.
Install a few required libraries via the Arduino library manager:
- “ESP8266 WiFi”
- “ESP8266 Web Server”
- “Wifi Manager”
In the attached Arduino program (sketch), change the following line
#define AIO_KEY "YourAIOkeyGoesHere"
To put your own adafruit IO key in the quotes.
You don’t need to store your wifi username and password. Thanks to the excellent “Wifi Manager” library, you’ll be able to type this in by connecting to the IoT device from your computer, phone, or tablet.
Using the Arduino IDE, upload the attached program (sketch) to the ESP8266.
To see if it’s working properly, open up your Adafruit.io dashboard. When a tweet from any account mentions @[your IoToots twitter account] you should see a new data point with a value of “4” show up on your IoToots Adafruit.io stream. After a few seconds, you should see the IoT device connect to adafruit.io and send a 0 (zero) back to adafruit.io. This is how the IoT device “resets” the stream to zero until the next 4 is received from IFTTT when a new tweet mentions your IoToots twitter account.
You can change how long the IoT device sleeps between waking up and checking Adafruit.io for new tweets. If you set the program for longer sleep, it will improve battery life, but result in a longer delay between sending a tweet and hearing a toot. You can do this by changing this line in the code:
#define SLEEP_LENGTH 5
Step 7: Assembly and Completion!
Now that you have built and programmed your IoT device, you should be ready to get up and running with the Internet of Toots (IoT). Your smart whoopee cushion is ready to go.
Drill out the screw holes to make them slightly larger if (like me) you have to use larger diameter screws than the original. You don’t want the case cracking after all this work. Screw together the three pieces of the case adding the washers as spacers on the screws as shown in the photo.
You can connect the IoToots device to any Wifi network without needing to reprogram the IoT device. Simply turn it on. If it can’t find the last wifi network it was connected to, it will fire up an access point with a new wifi network called “InternetOfToots”. Connect to this wifi access point from your phone or desktop browser, enter the network name and password that you want the IoToots to connect to. The IoToots will then reset and connect to the wifi network that you entered and use this to connect to the internet.
Fire up your own fart machine 2.0, hide it under your target’s chair, and turn it on. The battery should last a few hours. Now you can give the name of your IoToots twitter account to your friends/family/coworkers and anyone in the world can cause your smart whoopee cushion to toot at any time! Voila, you have a social whoopee cushion as your first IoT (Internet of Toots) device and you’re the envy/bane of everyone around you. Happy tooting!