It's time to improve on the classic fire breathing pumpkin! ππ₯
After reviewing several projects, it looks like I can make two major modifications...
- improve the servo mount
- migrate the remote trigger to Blues Wireless cellular connectivity
Aerosol Neck
The first thing I noticed was that aerosol cans seem to have standardized on a 30mm neck. I observed this on several travel sized hairspray products as well as shaving cream, silly string and air horns.
Servo Motor
The other half of the mount has to do with the servo. Fortunately, there seems to be some level of industry standardization around small plastic servo motors as well. I'm not exactly sure why, but I assume this is driven by the R/C car market.
Mounting Bracket
With these two standards in mind, I loaded up https://tinkercad.com to model a mounting bracket that can be used to connect the servo directly to the aerosol can. After several iterations, I finally arrived at a reliable design...
The final iteration arranged the servo against the canister neck, so the standard servo arm would directly active the aerosol nozzle. It also included spikes, so the aerosol canister can be staked into the pumpkin upside down.
Adding LogicI've chosen the Swan microcontroller from Blues Wireless. It's based on the STM32 microcontroller, more specifically the STM32L4xx family. This family of microcontrollers is known for being power conscious, but also powerful. It can be programmed using the STMCubeIDE or the with the Arduino IDE. The Arduino board support package, BSP, further enables VSCode which allows you to use an Arduino environment with debugging capabilities. All this can be configured by following the Swan Quickstart Guide by Blues Wireless.
The programming for the pumpkin is simple, it uses the Arduino environment, along with the standard Servo.h
library. The most basic sketch reacts to the Swan's builtin button. Once pressed, it tells the servo to spray the aerosol canister for a fixed period of time.
Easy Cellular IoT
The element of surprise is lost if you have to be present to make to pumpkin breathe fire, and this is where the Blues Wireless comes in. Blues Wireless offers the Notecard and Notehub.io. These products are the two sides of the same data bridge that can transmit your data from device to cloud and vice versa. The way the products are positioned, the Blue Wireless offering is great for connecting IoT products as well as prototyping...
First, the Notecard's built-in, 10 year, 500MB prepaid SIM card eliminates the concern about having to activate a cellular account for a prototype or "gag project".
Second, the Notecard makes adding cellular connectivity to any project incredibly easy. There is no need for AT commands, or large libraries to manage the cellular modem state. The modem and connectivity is managed in the Notecard itself, and you are able to communicate with the Notecard exclusively through JSON commands. Even though no library is required to communicate with the Notecard, Blues Wireless offers a light-weight library that allows you to construct and parse JSON commands and responses for the Notecard.
Configuring the Notecard
The Notecard is configured to maintain a constant connection with Notehub. This allows the Notecard to be highly responsive to inbound messages. Now when a web request is sent to Notehub.io (or an outbound Note is manually generated on Notehub.io), the Notecard will trigger an interrupt to inform the MCU a Note has arrived. From there the MCU will interpret the interrupt as a button press and boom goes the dynamite ππ₯!!!
The configuration is super easy, it's just one JSON command:
// Configure the Notecard
// {"req":"hub.set", "product":productUID, "mode":"continuous", "sync":true}
if (J *req = notecard.newRequest("hub.set")) {
JAddStringToObject(req, "product", productUID);
JAddStringToObject(req, "mode", "continuous");
JAddBoolToObject(req, "sync", true);
if (!notecard.sendRequest(req)) {
notecard.logDebug("FATAL: Failed to configure Notecard!\n");
while(1);
}
}
Then one more JSON command to ready the interrupt:
// Arm ATTN Interrupt
// {"req":"card.attn", "mode":"arm,files", "files":["flame.qi"]}
if (J *req = NoteNewRequest("card.attn")) {
JAddStringToObject(req, "mode", "arm,files");
if (J *files = JAddArrayToObject(req, "files")) {
JAddItemToArray(files, JCreateString("flame.qi"));
if (!notecard.sendRequest(req)) {
notecard.logDebug("ERROR: Failed to arm ATTN interrupt!\n");
}
}
}
Each time the interrupt fires, I can enable the servo to produce the flame. All that's left is to delete the Note and reset the interrupt.
Finally, one JSON required to delete a note:
// Delete flame request
// {"req":"note.get", "file":"flame.qi", "delete":true}
if (J *req = NoteNewRequest("note.get")) {
JAddStringToObject(req, "file", "flame.qi");
JAddBoolToObject(req, "delete", true);
if (!notecard.sendRequest(req)) {
notecard.logDebug("ERROR: Failed to delete Note!\n");
}
}
NOTE: Get the full code in the linked repository!
Safety LastOkay, so it would be crazy not to acknowledge that children's Halloween costumes are made of the absolute cheapest - and typically highly flammable - textile goods on the planet, so just shooting fire willy-nilly is probably not the best idea. So in the interest of NOT having my children need to Trick-or-Treat at the county jail to see me; I decided to add an ultrasonic range sensor to make sure Halloween stays fun for everyone.
I choose the HC-SR04, partly because that's what I happened to have on hand and also because it's the right sensor for the job. It has a range of 2 - 400cm with a resolution of 3mm. It's time of flight based, so the lightning fast GPIO on the Blue Wireless Swan will provide the absolute best resolution possible from the sensor.
In case you're like me and "don't metric", 400cm is more than 13ft! In my experience, the flame can shoot up to 2ft, so we can make a protective bubble of ~4ft in front of the pumpkin to make sure we aren't setting any kids π§ (or pets π) on fire π.
Seriously, Be Super Careful...This should go without saying, but this project is dangerous. Even with safety measures in place, I still managed to burn the hair off my right arm. If you choose to recreate this project, please respect the danger inherent in this project. Anytime you start to introduce an open flame to this (or any other) project, be sure pull your hair back, use safety goggles, wear fire resistant gloves, and pay close attention.
Comments