Alexa-controlled Adam Savage Pumpkin

by hannahmakes in Circuits > Microcontrollers

1964 Views, 0 Favorites, 0 Comments

Alexa-controlled Adam Savage Pumpkin

alexapumpkinthumb.png

All the lights in my house are smart so I've got pretty used to yelling at them to switch on and off, but it ends up making me look dumb when I yell at a light that isn't. And I look especially dumb when yelling at candles.

Normally this isn't too much of a problem, but come Halloween I've always got a pumpkin carving or two illuminated by candle light. So I figured, why not swap out the inefficient fire-hazard of an analog light source and craft a high-tech pumpkin, powered by LED lights and controlled by Alexa.

What you'll need

  • Carved pumpkin
  • LEDs
  • Battery for LEDs
  • Transistor
  • Couple of resistors
  • Breadboard is handy
  • WiFi enabled micro-controller (I used Adafruit feather M0 WiFi, but other boards would work. It just needs to be able to connect to the internet)
  • Battery for board
  • Accounts on IFTTT and Adafruit IO

There are many ways to achieve the end result, but this is the one that seemed the simplest to me, so that's what I'll explain.

Carve the Pumpkin

Screenshot 2019-11-05 at 22.36.44.png
Screenshot 2019-11-05 at 21.00.35.png
Screenshot 2019-11-05 at 21.01.24.png
Screenshot 2019-11-05 at 21.02.21.png
Screenshot 2019-11-05 at 21.02.38.png
Screenshot 2019-11-05 at 21.03.38.png
Screenshot 2019-11-05 at 21.04.33.png
Screenshot 2019-11-05 at 21.05.43.png

So my idea was to buck the trend. Everyone's out there carving villainous pumpkins, why not a hero pumpkin? Since this was a tech project, it seemed appropriate to choose one of my making heroes. I decided to carve a likeness of Adam Savage.

I already made an Instructable explaining how to turn a photo into a pumpkin carving stencil, which you can find here: https://www.instructables.com/id/Carve-a-Vampire-Pumpkin-Selfie/

In fact, I have one showing you how to turn Donald Trump into a a stencil, and another demonstrating how to do the same with your own face. Wow. Thinking about it, I currently have 3 Instructables, all of which are about pumpkins. Niche much?

Anyway here's a few photos outlining the major stages in the process for this particular design. The idea in general is to reduce your image to three colours, black, white and grey. White areas are cut all the way through the pumpkin, black areas are left alone and in grey areas you just remove the skin of the pumpkin.

A thing to keep in mind, whether you make a design yourself or chose one from online, is to try to minimise areas where you cut right through the pumpkin. Since we're going to have some electronics inside, however inconspicuous we try and make them, they'll be a little bit visible through any holes. Seeing a battery case peeking through might disrupt your design, or at least ruin the illusion that you've taught your smart home devices to integrate with the elements and turn off a real candle!

Circuitry

stop motion gif.gif

For the circuitry, I wanted a few LEDs controlled by a single pin on my micro controller. This seemed like a simple and sensible way to replicate a candle, but admittedly there are other options.

I chose to go with a separate power source for the LEDs, and something to act as an electronics switch so that the pin on my board could be set high or low to make or break the circuit between the LEDs and their power source.

As for the power source, I am a firm believer in the old adage: "the best battery is the one you have". I'm overrun with 9Vs so that's what I ended up with, although it's admittedly not necessarily the optimal one for this purpose, it's what I had to hand and THAT'S FINE, OKAY?! Can we please end the battery wars now?

Next I calculated the resistance I needed between my LEDs and their power source. There are calculators online for this (http://www.ohmslawcalculator.com/led-resistor-calculator), and it basically depends on the voltage of the battery, the number of LEDs and their specification. I used 3 red LEDs because I eyeballed that as being approximately the same brightness as the kind of tea light I'd stick in a pumpkin.

Bonus points if you buy the flickering LEDs that look like candles. Because I didn't.

For my electronic switch, I used a 2n7000 transistor/N-channel MOSFET. I use them for most of my switching needs since I inexplicably have a whole bunch of them. Just power the gate at around 3v to switch it on, making them fine for our purposes – the output from the pin on the micro controller I used was sufficient to turn the transistor on and off, and the transistor can handle the voltage of the battery I powered the LEDs with. (It can handle more, in fact).

I keep reading online that when using MOSFET transistors, you should use a gate resistor (a resistor between the gate and ground), "to be sure the MOSFET will be off if the thing driving it is letting the output float". Basically, I stuck one in for good measure.

Concept

Screenshot 2019-11-05 at 22.45.37.png
Screenshot 2019-11-05 at 22.45.51.png
Screenshot 2019-11-05 at 22.46.09.png
Screenshot 2019-11-05 at 22.46.25.png
Screenshot 2019-11-05 at 22.46.35.png
Screenshot 2019-11-05 at 22.46.57.png
Screenshot 2019-11-05 at 22.47.17.png
Screenshot 2019-11-05 at 22.48.22.png
Screenshot 2019-11-05 at 22.48.44.png
Screenshot 2019-11-05 at 22.49.12.png

To try and make things easy for myself, I used a few free online services to handle part of the process of getting Alexa to talk to my pumpkin.

The first: If This Then That. If you don't already know, IFTTT lets you connect other accounts and services you use then create recipes consisting of a trigger and an action. Once the trigger is detected, the action happens. In our case, we'll use Alexa as a trigger, so IFTTT can connect to Alexa and make something else happen when we say a specific phrase to her.

As for the action, I used Adafruit IO. By making an account on Adafruit IO, you can have a bunch of data feeds you can access through their website, or through their APIs. This means your micro controller can read and/or update these data feeds. I got IFTT to save a 1 or a 0 to a feed to represent a request to turn the pumpkin on or off.

So if you're following along, go make an account with IFTTT and Adafruit IO. Set up a feed in Adafruit IO called "pumpkin", then create two IFTTT applets – one that saves a 1 to the pumpkin feed if you say something like "pumpkin on", and one that saves a 0 to the pumpkin feed if you say something like "pumpkin off".

Code

It's genuinely my first time sharing code publicly, and even though it's basically an example sketch from the Adafruit website with a couple of lines tweaked, I'm still nervous (https://learn.adafruit.com/mqtt-adafruit-io-and-you/arduino-plus-library-setup). Be nice?

(You'll obviously have to swap out the placeholders for your real WiFi credentials etc.)

Adafruit IO has a HTTP API so it'd be possible to get your board to make and process HTTP requests to read yours feeds, if that's something you know how to do or are more comfortable with.

I just happened to use a sketch example that made use of the MQTT API instead, which is just a different, lightweight protocol, designed for small sensors and IoT type devices. The sketch is pretty self-explanatory. All it does is check the feed on Adafruit IO and set a single pin on the micro controller high or low depending on whether it sees a 1 or a 0 on the feed. This high\low pin will switch the transistor on and off, turning on or off the LEDs.

Put It Together

Screenshot 2019-11-12 at 00.25.38.png
alexacontrolledpumpkinthumb.png
MVI_7189 shorter.2019-11-05 22_15_30.gif

Lastly, you need soemthing to protect the electronics from the pumpkin guts. Lithium batteries don't like being wet. Not a lot of batteries do... or electronics... heck, unless I'm on holiday somewhere tropical I'm not especially a fan of it so I can't say I blame them.

My improvised solution was a paper plate covered in a few layers of plastic wrap. I'd advise using something better than this. Do as I say, not as I do. Go for some Tupperware or something, to protect from pumpkin on all sides, including drippy pumpkin guts. I can think of a range of solutions, from enclosing the electronics to plasticising your pumpkin, but really, the main thing is don't leave it unattended. No method is totally safe and you don't want any accidents....

I also made a video on the whole process if you fancy watching rather than reading.

https://youtu.be/NrzRmXAaJOc