Enchanted Rose 2.0 with Falling Petals

Revisiting the Enchanted Rose project four years later, this time with an open-source build based on Raspberry Pi.

Four years ago, my daughter was in a school production of Beauty and the Beast, and I volunteered to build a stage prop “Enchanted Rose,” which could drop these petals on cue. The initial project was fun, and the play was a total success. They did about ten productions in the spring of 2019.

I documented the build in a two-part blog series.

Those articles and their accompanying YouTube video made their way around the search engines. And in the years since, I’ve gotten emails from more than a dozen stage managers around the world (Colorado, Texas, California, London, NY, Florida, Hawaii, Scotland and more.) Stage crews, parents and students are looking to build the working prop.

Some even inquire about rental. Well, rental of the version 1.0 prop is out of the question. Not only was the original design based on servo motors and springs and fishing line, far too delicate to ship, the version 1.0 isn’t even in my possession anymore. I gifted it to the director. She’s also the school’s computer teacher, and she really wanted the prop.

As people trying to re-make it have let me know, the original instructions are now fairly out of date in at least two major ways. First, the Bluetooth board that the prop relied upon has since been discontinued. And second, the controller was a native iOS app written in Swift 3.0. Apple has updated the Swift language app so much that the old native app no longer compiles. Though I could get the app working again, Apple has made it fairly difficult to distribute apps ad-hoc, and I have no interest in publishing the app in the App Store as it is far too specialized.

But with every new inquiry from a hopeful production manager, I’ve felt it would be a nice thing to do to rebuild the prop, to better explain how to build one.

And so, here it is. Enchanted Rose 2.0 is a web-based one with a Raspberry Pi and an open-source approach. The basic mechanics are now working:

Enchanted Rose 2.0

Features

  • Control via private wifi network and mobile web browser, not native app
  • Total cost no more than $200
  • Durable enough to ship
  • Do NOT require that it connect to a local internet
  • Easy to use interface that an elementary school stage crew could use
  • Easy on-site setup. Ideally, just turn it on and it works.
  • Battery operated — most productions like to keep the illusion (and stage safety) by eschewing cords.

The main functions of the prop are to remotely:

  • Turn stem light on and off
  • Turn accent light on and off, and set colors and pattern
  • Drop 4 rose petals, one by one, on cue

Basic Approach

Lighting: The lighting circuitry is the same as in v1.0 design. That is, for the “stem lights”, a Raspberry Pi uses its GPIO port to send a signal to a resistor’s “base,” to allow a 4.5V circuit to complete.

For the Accent Lights, there are Neopixels; I found the 60-LED strand to be the right size. There’s a very good article on Adafruit telling you how to use a Raspberry Pi and Circuit Python to power Neopixels. Just as they recommend, I used a level converter chip (the 74AHCT125) to convert the Pi’s 3.3V output up to 5V without limiting the power drawn by the NeoPixels.

Both of the lights are powered by 4.5V, delivered by 3 AA batteries in a battery pack.

Drop Mechanism: For the drop mechanism, I made major changes from v1.0 to v2.0. Version 1.0’s use of magnet-spring-fishing-line servo-motor works for local productions just fine, and has some advantages (reliability once calibrated.) But it is far too delicate to ship. I experimented with electric solenoids pulling on magnets, but the smallest ones were too weak, and would require an enormous “bulb” to house.

I hit upon the idea of using pneumatic pressure! That is, pumps create puffs of air in tubes, which jettison the petal.

Software: Control of the prop is via a Python-based API, which has a front-end control app (link to repo below.) That is, the prop itself hosts a web server on the Raspberry Pi, and presents its own private “ad-hoc” network. The stage manager connects the prop’s ad-hoc network, and accesses the controller software. This general pattern can be used to build “remote control” devices.

There are three main components to this stage prop:

  1. The front-end control software, written in React/Next.js. You’ll find that code in the enchantedrose repository. From a technical standpoint, all this repo does is present a nice front-end layer onto the API.
  2. This hardware API, in this repo: Enchanted Rose Python API. This repo is the essential python-based API software. This controls the GPIO pins on the Raspberry Pi and presents an API on port 5000 to the world. The role of this software library is to provide an API for turning on/off lights, dropping petals, etc.
  3. The prop hardware itself.

Software

The two key pieces of software, other than the Raspbian Operating System itself, can be found here:

You’ll also need to install the NeoPixel driver libraries, which are well documented over at the Adafruit website.

Hardware

Each pump motor needs a circuit like the below. Since RPi cannot output 9V, we’ll make use of a transistor to switch a supplied 9V current on and off. (Note that in production, I ended up boosting the power supply to 8 AA batteries, or 12V. The motors can handle this higher voltage for short duration, even though they’re rated for 6-9V.)

Since these motors generate current spikes when they are powering down and powering up, it’s very important to protect your RPi with a diode, as follows (the directionality matters! pay attention to the line on the diode and the positive lead from the motor):

Wiring diagram for pump motors

There are four such circuits, with the power source and RPi being shared between them.

Accent Lights

The circuit and software to control Neopixels is well documented at Adafruit’s website.

Configuring Raspberry Pi for “Ad Hoc Network”

I was excited to hit upon the idea of having the prop create its own “Ad Hoc Network” (i.e., it’s own Wifi SSID that you can join.) Not only did this eliminate the need to have the stage manager at each playhouse somehow find a way to connect the prop into their own local network, but it removed any requirement for a display or keyboard to ship with the device for configuration purposes.

All they have to do is plug in the device, wait for boot-up, and it presents its own Wifi Network (“EnchantRose”.) They then simply enter the password, bring up a web browser on their phone, and visit a pre-determined IP address which I’ve configured: http://192.168.11.1. It took a while to figure out how to configure Raspberry Pi to do this, since the instructions have changed seemingly with every release of Raspbian, the RPi operating system. But I figured it out by adopting existing instructions, and blogged it here.

What’s most exciting about this is that it’s a pattern that can has many applications in the world of “Internet of Things” — run Apache2 on your Raspberry Pi to host a website, and render that website visible via the Rpi’s own password-secured wifi network.

Current Status

The new version 2.0 prop is fully functional. I’m now in the “arts and crafts” stage of making it look much more realistic. There’s more work to be done there, as well as documenting a setup guide for stagehands.

I’ve gotten four more inquiries since November 2022, and will be selling this prop to one of them. I had considered renting it out, but it’s a bit of a logistical hassle to ship and receive. If you’ve got specific questions on assembly or the software, drop me a note. On with the show!

Turn a Raspberry Pi into a Web Server with Its Own Wifi Network (Tech Note)

The Raspberry Pi microcomputer is great for building “Internet of Things” devices. This technical post describes the steps to get your Raspberry Pi to broadcast its own local network and bridge to an Ethernet network if available. There are other guides showing how to do this on the Internet, but they are often woefully out of date, leading people down real rabbit holes.

The Raspberry Pi (RPi) microcomputer is great for building cheap “Internet of Things” devices. In this tech note, I outline how to set up a Raspberry Pi device so that it broadcasts its own local wifi network, so you can join it from a mobile phone. From there, you could launch a web browser and point it at the RPi’s website, which in turn controls the board’s I/O devices. This means you could use a mobile phone, say, and a Raspberry Pi device, and control it without any larger Internet connection.

The steps below also essentially turn the RPi into a “wifi access point,” which basically can take a hardline Internet network (LAN) and present a wifi front-end (WLAN.)

Turn your RPi into a wifi access point, or also its own ad-hoc network

So how do you get a Raspberry Pi to create its own wifi network? There are several “How To’s” on the web, but nearly all of them I followed are out of date. You need to install a few services, set up some configuration to define your network, and then reboot the Pi once everything is all set.

One great use-case is to build a standalone device which can be controlled via a web interface from, say, a mobile device. RPi’s can easily run web servers like Apache, so once you set up an RPi to broadcast its own private wifi network, you can easily interact with the Raspberry Pi’s devices and sensors via your website.

You’ve probably seen this kind of behavior if you’ve set up a wifi printer, or smart switch, or wifi security camera. These devices often have modes where they broadcast their own local wifi network, then you use a browser or a configuration app to “join” it, you do some setup process, and then it in turn uses what you’ve input to restart and join your home network with those configuration details thus supplied.

Enchanted Rose Prop 2.0

I had a use-case for this “ad hoc networking” with a stage prop I’m building.

A few years ago, I built an Enchanted Rose prop for my daughter’s school production of “Beauty and the Beast.” It let the stage manager drop petals and turn on lights on queue. It was based on Arduino and Bluetooth. I blogged the instructions in a two-part series. As a result thanks to Google, every couple of months or so, I get an inquiry from a production manager from somewhere in the world who wants to know more about how to build such a prop. Invariably, they follow these instructions and then hit a dead-end (which I’ve now noted in the posts.) The problem is, the version 1.0 device that I built is based upon an Arduino microcomputer (fine) with a Bluetooth add-on board which is now discontinued (not fine.) Worse, its controller was a proprietary Swift app which I wrote in a many-years-out-of-date dialect of Swift, which had to be installed straight from XCode onto a machine, as I opted not to publish it in the App Store. Apple has made many changes to Swift since then. The app as originally written no longer compiles, and Apple itself make it very difficult to distribute “one off” apps to people. (You can’t just post the app download somewhere, or email them a link — Apple requires that the developer add the person to an ad-hoc distribution list.)

So I began to think about how to rebuild it in a more open-source way.

Motivation for Ad-Hoc Network

At the heart of the version 2.0 of this prop is a Raspberry Pi Zero 2W, which runs its own little Apache web server to control lights and the falling petals. Ideally, a stage manager would simply need a mobile phone or iPad or some kind of web browser on a device equipped with wifi to communicate with the prop.

I’ve heard interest in this prop from stage managers in the UK, California, Colorado, Texas and more, and I wanted to re-build this prop in a more robust, even shippable way. So on the mechanical front, instead of using delicate springs and fishing line, it now uses pumps and air to push the petals off the rose. I’ve got the motors and circuits all working fine. Before moving on to the final aesthetics, I’m now working through matters related to the deployment setting(s) this prop will run in.

There’s a high school in California putting on this play in March. I don’t know what network environment is at that school, nor should I particularly care. I certainly don’t want to request and configure wifi passwords for the prop to “join” before shipping the device out. Rather than equip the prop with some kind of user interface to allow it to “join” the local WAN (needlessly wasteful screen and keyboard and instructions), it’s far better for it to broadcast its own tiny network, and be controlled from backstage just on its own. You’ve probably seen this type of “ad hoc” network when setting up, say, a printer or security camera, smart speaker, or smart switch.

But wow, getting ad-hoc networking up and going in Raspberry Pi is complicated!

THAR BE DRAGONS. It has taken a full day to get this up and running. Not only is Linux itself pretty arcane, but a much bigger problem is that so many of the instructions on ad-hoc networking for Raspberry Pi’s are wildly out of date. The Raspberry Pi Foundation changes these methods seemingly with every release of the OS.

So, to save my future self (and anyone Googling who lands here) many headaches… After much tinkering, the following instructions successfully configured a Raspberry Pi Zero 2W device to create and broadcast its own wifi network with a password. It allows clients (such as mobile browsers) to join it, and visit its control webpage hosted by the device on its Apache server. In short, the below just plain worked for me. Many, many other “how-to’s” on the web did not. A day wasted; I don’t want to do that again.

After you complete the below, you should be able to use a wifi device and “join” the network that the Raspberry Pi broadcasts. I successfully did so from both a Mac desktop and an iPhone. I could also then visit the apache page hosted on the Pi from these devices. This opens up a world of possibilities for “build and deploy anywhere” devices.

The notes which follow are adapted from: documentation/access-point-bridged.adoc at develop · raspberrypi/documentation (github.com)

There are a lot of steps here, but once you’re finished configuring your RPi, it should have its own private wifi network, and yet still be connectable via Ethernet. This is called an “Access Point” configuration.

Prerequisite: Use Raspbian “Buster,” a prior version of Raspbian OS

Make sure you use Raspbian “Buster” for the instructions. “Buster” is not, in fact, the most current version of the OS.

For the instructions below to work, you must use the older “Buster” version of Raspbian. Let me repeat, because some of you will be very tempted to use the latest version of Raspbian OS, and then will wonder why the network isn’t showing up. The Ad-hoc networking steps described below have only been tested to work on the “Buster” version. In fact, I tried and failed to get them to work on the latest (“Bullet”) version of Raspbian OS. Perhaps I did something wrong; perhaps by now it’s all resolved. But I tried twice, and only “Buster” worked perfectly.

The Raspberry Pi Foundation is great, but it’s pretty frustrating that they’re constantly tweaking the network setup code and drivers. There. are so many web pages which refer to old versions and drivers. (One clue you’re looking at an outdated how-to: if you see mention of “/etc/network” or the “interfaces” file. This method is discontinued and you’ll see no mention of it below.)

If you are dedicating your Raspberry Pi to its own ad-hoc network, I highly recommend you start over with it, back up whatever files you have on the SD card, and then use the Raspbian OS imager to create a bootable card with a fresh copy of Raspbian OS “Buster” on it. So, grab an archived copy of Buster. Unzip it. Then, launch the Raspberry Pi Imager, and click the GEAR icon to:

  1. ENABLE SSH with a password, and
  2. Set it up with your home wifi’s network name (SSID) and password.

After your card is written, you should be able to pop it out and put it in your RPi, and turn on the device. After a few moments, you should be able to ssh into it (Mac) or use PuTTY (Windows) to connect. To find the device’s IP address, go into your wifi’s router and look for a recently joined Raspberry Pi device. (Generally, the IP address will be the same from session to session.)

For Mac OSX, this looks something like:

ssh pi@192.168.x.y

where x and y are numbers. Every Internet device connected to your wifi is assigned a different address; this will vary from device to device. The default password for “pi” is “raspberry”.

Later in these setup instructions, we’re going to have it create its own wifi network with its own subnet, and connect on the backend with Ethernet. This is called a “Wide Area Network Access Point” or “Wifi Access Point” configuration, in which the RPi will basically have two IP addresses: one over the wire, and the other wireless.

1. Set up “root” user

Instead of the default user “pi”, for some operations you may need root access. For instance, NeoPixel libraries need Raspberry Pi “root” permission to run. So it’s best to set up a root user password first thing:

Then, log out of ssh and log back in with ssh root@<ip address>

From here on, you’ll want to sign in as root.

Enable remote login for the “root” user

  1. sudo nano /etc/ssh/sshd_config
  2. Find this line: PermitRootLogin without-password
  3. Change to: PermitRootLogin yes
  4. Close and save file.
  5. reboot or restart sshd service using: /etc/init

2. Get web server running

Install Apache2 Web Server with one line of code:

sudo apt install apache2 -y

This will create a folder in /var/www/html which the Apache web server will run. The install will also ensure that it starts at boot time.

3. Set up Ad Hoc Networking

OK this is the crucial part. HAVE PATIENCE, and follow this closely. (Full notes are at this Github location.)

Setting up a Routed Wireless Access Point

We will want to configure our Raspberry Pi as a Wireless Access Point, so that it broadcasts a wifi ssid, and so mobile devices can connect to it. Ideally, the RPi would also remain connectable to an Ethernet network for development purposes, to install new libraries, etc.

So a “Routed Wireless Access Point” is perfect for our needs.

AGAIN, BE SURE YOU ARE WORKING ON RASPBIAN “BULLET”, NOT “BULLSEYE” OR LATER.

You can find out what OS version you’re running with the following command:

A Raspberry Pi within an Ethernet network can be used as a wireless access point, creating a secondary network. The resulting new wireless network (called “Enchanted Rose” in my case) is entirely managed by the Raspberry Pi.

A routed wireless access point can be created using the inbuilt wireless features of the Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero W, or by using a suitable USB wireless dongle that supports access point mode. It is possible that some USB dongles may need slight changes to their settings. If you are having trouble with a USB wireless dongle, please check the forums.

This documentation was tested on a Raspberry Pi Zero W2 running a fresh installation of Raspberry Pi OS Buster.

Before you Begin

  1. Ensure you have root access to your Raspberry Pi. The network setup will be modified as part of the installation: local access, with screen and keyboard connected to your Raspberry Pi, is recommended.
  2. Connect your Raspberry Pi to the Ethernet network and boot the Raspberry Pi OS.
  3. Ensure the Raspberry Pi OS on your Raspberry Pi is up-to-date and reboot if packages were installed in the process.
  4. Take note of the IP configuration of the Ethernet network the Raspberry Pi is connected to:
    • In this document, we assume IP network 192.164.4.0/24 is configured for the Ethernet LAN, and the Raspberry Pi is going to manage IP network 192.168.11.0/24 for wireless clients.
    • Please select another IP network for wireless, e.g. 192.168.10.0/24, if IP network 192.168.11.0/24 is already in use by your Ethernet LAN.
  5. Have a wireless client (laptop, smartphone, …) ready to test your new access point.

Install Access Point and Management Software

In order to work as an access point, the Raspberry Pi needs to have the hostapd access point software package installed:

Enable the wireless access point service and set it to start when your Raspberry Pi boots:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd

In order to provide network management services (DNS, DHCP) to wireless clients, the Raspberry Pi needs to have the dnsmasq software package installed:

Finally, install netfilter-persistent and its plugin iptables-persistent. This utility helps by saving firewall rules and restoring them when the Raspberry Pi boots:

sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

Software installation is complete. We will configure the software packages later on.

Set up the Network Router

The Raspberry Pi will run and manage a standalone wireless network. It will also route between the wireless and Ethernet networks, providing internet access to wireless clients. If you prefer, you can choose to skip the routing by skipping the section “Enable routing and IP masquerading” below, and run the wireless network in complete isolation.

Define the Wireless Interface IP Configuration

The Raspberry Pi runs a DHCP server for the wireless network; this requires static IP configuration for the wireless interface (wlan0) in the Raspberry Pi. The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: 192.168.11.1.

To configure the static IP address, edit the configuration file for dhcpcd with:

sudo nano /etc/dhcpcd.conf

Go to the end of the file and add the following:

interface wlan0
    static ip_address=192.168.11.1/24
    nohook wpa_supplicant

Enable Routing and IP Masquerading

This section configures the Raspberry Pi to let wireless clients access computers on the main (Ethernet) network, and from there the internet.

NOTEIf you wish to block wireless clients from accessing the Ethernet network and the internet, skip this section.

To enable routing, i.e. to allow traffic to flow from one network to the other in the Raspberry Pi, create a file using the following command, with the contents below:

sudo nano /etc/sysctl.d/routed-ap.conf

File contents:

# Enable IPv4 routing
net.ipv4.ip_forward=1

Enabling routing will allow hosts from network 192.168.11.0/24 to reach the LAN and the main router towards the internet. In order to allow traffic between clients on this foreign wireless network and the internet without changing the configuration of the main router, the Raspberry Pi can substitute the IP address of wireless clients with its own IP address on the LAN using a “masquerade” firewall rule.

  • The main router will see all outgoing traffic from wireless clients as coming from the Raspberry Pi, allowing communication with the internet.
  • The Raspberry Pi will receive all incoming traffic, substitute the IP addresses back, and forward traffic to the original wireless client.

This process is configured by adding a single firewall rule in the Raspberry Pi:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Now save the current firewall rules for IPv4 (including the rule above) and IPv6 to be loaded at boot by the netfilter-persistent service:

sudo netfilter-persistent save

Filtering rules are saved to the directory /etc/iptables/. If in the future you change the configuration of your firewall, make sure to save the configuration before rebooting.

Configure the DHCP and DNS services for the wireless network

The DHCP and DNS services are provided by dnsmasq. The default configuration file serves as a template for all possible configuration options, whereas we only need a few. It is easier to start from an empty file.

Rename the default configuration file and edit a new one:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf

Add the following to the file and save it:

interface=wlan0 # Listening interface
dhcp-range=192.168.11.2,192.168.11.20,255.255.255.0,24h
                # Pool of IP addresses served via DHCP
domain=wlan     # Local wireless DNS domain
address=/gw.wlan/192.168.11.1
                # Alias for this router

The Raspberry Pi will deliver IP addresses between 192.168.4.2 and 192.168.4.20, with a lease time of 24 hours, to wireless DHCP clients. You should be able to reach the Raspberry Pi under the name gw.wlan from wireless clients.

NOTEThere are three IP address blocks set aside for private networks. There is a Class A block from 10.0.0.0 to 10.255.255.255, a Class B block from 172.16.0.0 to 172.31.255.255, and probably the most frequently used, a Class C block from 192.168.0.0 to 192.168.255.255.

There are many more options for dnsmasq; see the default configuration file (/etc/dnsmasq.conf) or the online documentation for details.

Ensure Wireless Operation

Note, I successfully skipped this subsection

Countries around the world regulate the use of telecommunication radio frequency bands to ensure interference-free operation. The Linux OS helps users comply with these rules by allowing applications to be configured with a two-letter “WiFi country code”, e.g. US for a computer used in the United States.

In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process (see wireless configuration pages in this section for details.)

To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command:

This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next.

Configure the AP Software

Create the hostapd configuration file, located at /etc/hostapd/hostapd.conf, to add the various parameters for your new wireless network.

sudo nano /etc/hostapd/hostapd.conf

Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of EnchantedRose, and a password AardvarkBadgerHedgehog. Note that the name and password should not have quotes around them, and the passphrase should be between 8 and 64 characters in length, or else “hostapd” will fail to start.

country_code=US
interface=wlan0
ssid=EnchantedRose
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Note the line country_code=US: it configures the computer to use the correct wireless frequencies in the United States. Adapt this line and specify the two-letter ISO code of your country. See Wikipedia for a list of two-letter ISO 3166-1 country codes.

To use the 5 GHz band, you can change the operations mode from hw_mode=g to hw_mode=a. Possible values for hw_mode are:

  • a = IEEE 802.11a (5 GHz) (Raspberry Pi 3B+ onwards)
  • b = IEEE 802.11b (2.4 GHz)
  • g = IEEE 802.11g (2.4 GHz)

Note that when changing the hw_mode, you may need to also change the channel – see Wikipedia for a list of allowed combinations.

Troubleshooting hostapd: If for some reason your access point is not coming up, try running hostapd manually from the command line: sudo hostapd /etc/hostapd/hostapd.conf

You’ll likely get some kind of error message back.

Running the new Wireless AP

Now restart your Raspberry Pi and verify that the wireless access point becomes automatically available.

Once your Raspberry Pi has restarted, search for wireless networks with your wireless client. The network SSID you specified in file /etc/hostapd/hostapd.conf should now be present, and it should be accessible with the specified password.

If SSH is enabled on the Raspberry Pi, it should be possible to connect to it from your wireless client as follows, assuming the pi account is present: ssh pi@192.168.11.1.

If your wireless client has access to your Raspberry Pi (and the internet, if you set up routing), congratulations on setting up your new access point!

If you encounter difficulties, contact the forums for assistance. Please refer to this page in your message.

Once this is done, the network should be “EnchantedRose”, and the main web address should be 192.168.11.1.

Internet of Things: How to Remotely Monitor Propane Tank Level via Raspberry Pi

For less than $100, a little coding and a small circuit, you can remotely monitor a propane tank from anywhere.

One great use-case for the Internet of Things is to remotely monitor gauges and levels. In addition to spot-checks, wiring them up also allows you to auto-log values over time, so you can get a nice graph of usage, economize where you can, and project future usage.

If your property is served by liquid propane gas (LPG), there might be occasions where you want to be able to check the tank’s propane level from your phone. Ideally, you might even want it to notify you when the tank is, say, at 25% or lower, so you can schedule a refill. And wouldn’t it be useful to see which seasons, use-cases or appliances tend to consume the most propane?

There are commercial vendors for remote propane monitoring, but they’re usually tied to some kind of subscription service, some of them come bundled with a mandatory cellphone plan, and often tied to the fuel vendor themselves. I wasn’t interested in paying, say, $5 per month just to be able to check a value.

This made a perfect use-case for a simple microcontroller project.

WARNING: Fiddling with electricity, even very low 1-3V such as what we’re talking about here, around combustible material is a very bad idea. Only do this if you know what you are doing. Be sure all your connections are fully sealed and weatherproofed. Maker assumes all risk.

Ready to accept that risk? OK, here’s how I built it:

First, Some Background: How do Propane Gauges work?

At first, I thought that these gauges somehow have a physical pass-through into the tank, but they’re much more clever than that. They make use of magnets to keep the integrity of the tank fully sealed.

There’s a very good video here from DPS Telecom (a vendor of remote monitoring solutions for businesses and homes) which explains how such fuel gauges work:

So to proceed, you’ll need a gauge for your tank which is “Remote Ready.” This has been standardized in America, and you’ll want what’s called an “R3D compatible” gauge. They can be had for about $9-15.

This simply means that the gauge both reads and conveys a magnetic value. As the needle moves, a magnet also moves, which can be read by a Hall Effect Sensor placed just over the needle (under the black plastic.) Luckily, this standardization means that these gauges will almost certainly work on your existing tank, simply by removing two screws, removing the existing gauge, and screwing the new one in. Or, if your existing gauge says it’s “remote ready,” as many do, you’re already set.

But in looking for a pre-made “reader” cable, not only are they hard to find and rarely sold separately, I was shocked to see several vendors asking $150+ for them! You don’t need a commercial reader cable — you can make your own, with a Hall Effect sensor chip which you can find for about $1.

Building Our Remote Gauge

OK, now that we know how these gauges work, how can we get the Raspberry Pi to “read” it? We need to translate that magnetic signal into some kind of voltage. Once that’s done, since RPi doesn’t have a native analog to digital converter built in (as the Arduino does), you’ll also need some kind of Analog to Digital Converter (ADC) chip, so that RPi can make use of the signal in digital form. I chose the MCP 3008 for this project, which you can find on Amazon for about $9.

Parts List

  • Raspberry Pi (I used an RPi4)
  • Analog to Digital Converter MCP 3008 Chip
  • 49E Hall Effect Sensor Chip
  • Half-size breadboard
  • 1 10KOhm resistor
  • An RD3 Compatible Propane Gauge
  • Wires for connecting breadboard
  • 3-wire outdoor shielded cable
  • Small magnet for testing and setting values in the gauge during prototyping
  • Glue/epoxy to set the Hall Effect sensor in place
  • Outdoor Enclosure plus cable glands

The key piece of circuitry is the Hall Sensor. I chose the 49E, which are super cheap and accurate enough for the purpose:

Hall-sensor-49e

Here’s a demonstration of what I’ve built:

Yes, that’s Scotch tape on the prototype gauge. I’ll likely be epoxying it into place after tests are complete.

Experienced makers will no doubt notice that the Raspberry Pi 4, a full-fledged Linux computer, is extreme overkill for this application. But I’ll be using that same Pi to handle several other home automation tasks; this is just one of them.

Among the things to notice is that this MCP3008 chip can convert up to 8 analog voltage inputs. This project uses one of the 8. I’ll likely be using this same setup to remotely monitor things like humidity, temperature, soil moisture, etc. over time.

Wiring Diagram

Figure 1. Wiring Diagram

Steps

  1. Get Raspberry Pi configured with Raspbian
  2. Configure it for headless development via SSH. I used Visual Studio Code and its ssh remote development feature.
  3. Install prerequisites: CircuitPython and MCP3008 library
  4. Install pip and flask.
  5. Get sample code from Github. I’ve put simple Flask code (python) here: stevemurch/whidbey-raspberry-pi (github.com)
  6. Make circuit: Use the MCP3008 to take an analog input and convert it into a digital signal. See wiring diagram above. [Addendum from diagram: I put a 10k Ohm “pull down” resistor connecting the analog input data pin (MCP3008 channel 0) with ground. This is optional, but it tended to steady the values a bit more.]
  7. Solder Hall Effect Sensor 49E chip to 3 wires. Check the 49E datasheet and connect a wire for VCC, Ground and Voltage Out.
  8. Crucial step: Position the Hall Effect Sensor Chip exactly in the small channel, with the smaller side of the trapezoid facing DOWN (i.e., toward the gauge). With my 49E chip, this means the wires, from top to bottom, are VCC, GROUND and SIGNAL.
  9. Using the Raspberry Pi, take measurements at key values. This will vary considerably based upon how long your wires are, and where precisely you have the Hall Effect Sensor placed. My own values are shown in Table 1 below.
  10. Install the apache2 server and pretty NextJS/React app to show the gauge.
  11. Make sure the simple flask application (which is the API that the NextJS front-end calls) starts at RPi boot time. I’ve used gunicorn for this. I’ve set a value in the /etc/rc.local file for it to run at startup.
Table 1. The values I got, once I secured the Hall Effect Sensor (49E) in place

Code

I’m putting some finishing touches on this code and will provide a link to the GitHub repository shortly. There are three main parts:

gauges.py: A library to spot-read a voltage and spit back out the gauge value

server.py: the flask API

frontend: a simple NextJS app which reads the API and presents a nice looking gauge to the user

Learnings

  • The trickiest part is actually affixing the Hall Sensor to the gauge. Good results are extremely sensitive to precisely where this chip is mounted, and there’s no easy way to lock it in place. I chose a hot glue gun method, but I might revise that to some kind of epoxy.
  • The 49E Hall Sensor has a very narrow sensitivity range — highest values it ever reported were around 2.08v and lowest value around 1.3v. But that’s enough fidelity to translate it into a percent-full between 100 and 0. Here, it’s good to remember not to let the perfect be the enemy of the good. I don’t actually need single-digit precision; in this use-case, accuracy to within about 5% is more than adequate.
  • I’m still determining whether or not the RPi is going to live outside. My preference is that it not live outside, and that only the 3-wire strand goes out to the gauge from the RPi. If it does have to live outside, it will be powered by Power Over Ethernet (POE) to keep cables to a minimum. I’ve purchased a POE splitter which will live in the external enclosure if so. This approach will allow just one cable to serve both power and data (ethernet.) But for weather-proofing reasons, I’d rather have the RPi mounted inside (in, say, a garage), and have a long-ish low voltage wire going out to the gauge. I’ve experimented with cable lengths and thus far can confirm that about 15 feet still works very well, even at the low voltages we are talking about. I don’t know if the voltage drop will be too significant beyond that length.

Conclusion

I’ll be adding in a simple email notification system when the value gets below a certain value, and I’ll likely connect the sensor values to something like Azure IoT services to log the levels over time. This will provide nice usage graphs, and even help show if there’s a leak somewhere that needs to be addressed. Hope this technote is a useful starting point for your next RPi project!

DIY Photo Booth 2.0: Now Controls an iPhone or iPad

Looking for a fun make-it-yourself project? Why not build a photo booth for your next party? I share a few updates on a #Maker post I made a couple years ago.

I’ve previously written up a Do-It-Yourself Photo Booth project I built using a Raspberry Pi, an old LCD monitor, a mirrorless camera and an inexpensive LED Ring Light. I’ve recently updated this project to use the iPhone camera, and wanted to explain how I built it.

Motivation

Photo Booths can be a fun addition to a party or gathering, but they can be extremely expensive to rent. One place I called was quoting more than $1,000 just for one night! But if you’re handy with Swift and Python, and have an extra monitor lying around, you can build one that has much better resolution and features for less than $150.

Parts

Please see the original Photo Booth post for a basic implementation of the Raspberry Pi controller.

Controlling an iPhone Automatically

The big change I made for this iteration was to remove the dependency on a dedicated camera. By substituting in an iPhone, I was able to make the project much more portable and compact, and frankly much better adapted to low-light photography. The latest iPhone and iPad cameras are really terrific, and there’s really little advantage to having a tethered professional camera set up all night, unattended, which might be accidentally knocked over or otherwise damaged.

How to control it?

The Raspberry Pi built into the Photo Booth case can speak Bluetooth and Wifi and even USB.

Rather than futz with Bluetooth, I decided that it was acceptable to assume there will always a wifi signal where the photo booth would be set up. That way, I could establish a simple web server on my iPhone, have it “listen” for the right trigger call from the Raspberry Pi, snap the photo, upload it to a central server, and as a nice backup feature, keep the photo on the Camera Roll for later sharing.

I used the Swift web server library Embassy for the iOS app. My custom Photo app on the iPhone simply spins up an Embassy instance, listens for a simple GET call from the Raspberry Pi, and then calls some AVFoundation code to snap the photo. It then posts the image to the back-end server.

Meanwhile, the RPi server waits about 10 seconds after telling the camera to snap the photo, then it polls the backend API for a new image, and displays it on the monitor.

These changes to the version 1.0 Photo Booth project make it far easier to set up, much more portable, more reliable in low light conditions, and overall just much more “plug and play.”

Build a Photo Booth for Your Next Party

Photo booths are expensive to rent. But if you have a camera and an old monitor lying around, you can make a much more versatile photo booth for less than $100!

Update, August 2021: I’ve refactored some of this code to instead control a mounted iPhone. See some of the changes I’ve made to Photo Booth 2.0.

Photo booths are expensive to rent. But if you have a camera and an old monitor lying around, you can make a much more versatile photo booth for less than $150!

Background

I recently hosted a big milestone birthday party for my wife. I thought it’d be fun to have a photo booth at the party, so I called a couple of rental places a few months ago. I was surprised to learn that here in Seattle, photo booths can cost anywhere from $800 to $1,500 per night for a full setup!

And even with that expense, the quality of the photos you’ll get is generally worse than that delivered by a standard webcam. The technology built into these photo booths is often cheap and dated. And as for output, they might print out a throwaway strip, but I’ve never seen one where you could get the photos where most people want them: on their phones.

Finally, the resolution, bokeh, etc. of these rented booths is quite inferior to what my own mirrorless camera is able to take. I already own a good-quality camera (Fuji X-T2 — I love it!)

So why not make a photo booth?

Added Features: SMS Sharing, Big Screen Slideshow

Rather than generating printed leave-behinds, I wanted people to be able to walk away with the “originals” on their own cellphones, maybe even easily share them to Instagram or social media.

This seemed pretty easy to enable if I could build a photo booth that connected to the Internet. I figured a QR code could send users to the “live album”, where they could see the photos and download them onto their devices.

Slideshow

The venue also happened to have a big-screen projector in the bar area. I wanted to be able to put some of the best photos up on the big screen during the evening. So what I really wanted was an automated photo booth PLUS a back-end internet service which stored photos and let people see them quickly, and also let an “administrator” favorite the best ones for featuring in the slideshow.

So, back in May, I set out to build my own photo booth using a Raspberry Pi, my mirrorless Fuji X-T2 camera, and a custom web app hosted on Azure.

Perhaps the biggest difficulty was that this was a surprise — so all this assembly and testing work had to be done out of sight. So, fair warning: some of what you’ll see here is kind of slapdash. But it all came together pretty well — and it all worked beautifully unattended!

Three Options

There are three basic options for Raspberry Pi controlled image capture:

  • OPTION A: Use a DSLR or mirrorless camera, and make use of gphoto2 to drive it
  • OPTION B: Connect a Webcam to the USB input of the Raspberry Pi and capture images with fswebcam. I tried both the Logitech 9200 and the Logitech BRIO, and both worked fine with fswebcam and ffmpeg, but I still felt the image quality of my mirrorless camera was far superior, particularly in low lighting.
  • OPTION C: Use the official Raspberry Pi Camera (now in version 2), and capture images with fswebcam

I chose Option A because it’s by far the best image quality in low lighting, it allows for an auto-focus camera, and it allowed me to use the lenses and equipment I already own.

But before I go on, let me say that Options B and C have major benefits too, and there were a few times that I seriously considered abandoning the mirrorless camera altogether. A webcam-based photo booth is far easier and much more reliable: In my own tests with a high resolution Logitech BRIO, fswebcam appears to capture pictures and transfers data quite reliably, has perfectly adequate photos, and doesn’t have any of the fussy driver error/connections that I encountered, nor does it have the power management problems inherent in a separate camera. (With Option A, you need to ensure your camera either has enough battery life for the evening, or is connected to a power source and won’t go into “sleep” mode.) Option B also works well to capture short video segments if you prefer that approach — for instance, if you want to capture a short video, you can issue the command:

ffmpeg -t 120 -f v4l2 -framerate 25 -video_size 640x80 -i /dev/video0 output.mkv

… assuming your webcam is on /dev/video0.

OK, back to Option A: using gphoto2 to control a digital camera.

Parts List

  • A digital camera controllable via a USB cable — be sure to choose one compliant with gphoto2. There’s a long list.
  • Empty SD card(s) for your camera: WARNING — the code in the Github repository below DELETES all the images on your camera’s SD card when starting up, by design. This is to allow faster file transfer and error recovery.
  • Display Monitor — I used an old HD LCD monitor with DVI input, and an HDMI to DVI cable.
  • Raspberry Pi 3B+ and power supply
  • Extension cord
  • Illuminated Arcade Button
  • Power strip (to mount inside the enclosure)
  • AC power for your camera (you’ll want to have your camera powered on throughout the evening)
  • USB cable (to connect the Raspberry Pi to your camera)
  • A wood enclosure (Thanks to friend Tim and his workshop for this!), paint, finishing hardware and carrying handle
  • Camera tripod or mounting bracket
  • Speaker tripod (to hold the monitor — I found a cheap one for about $40 at a local music supply center.)
  • Speaker mount
  • Extension cord
  • Props for Photo Booth – hats, signs, etc.

Assembly

Don’t expect this post to be fully comprehensive; I just want to provide enough detail to give you a basic feel of how to build one of these things. Anyone with basic working understanding of Raspberry Pi and Python should be able to take this code and some of the ideas here and build a fully functional system.

The back-end service is optional; you can always recover the photos at the end of the evening. If you plan to do so, I’d advise commenting out the “delete all photos” code is in the photo booth’s startup routine.

I’d love to hear your ideas and comments, so drop them in the comments section below.

The brains of the Photo Booth is a Raspberry Pi 3B+.

Install gphoto2 to your Raspberry Pi:

sudo apt-get install gphoto2 -s

But there’s a fair amount of steps to get gphoto2 to work. Follow the instructions at this detailed post to get gphoto2 working, and verify it manually works before continuing.

A wifi connection is used to upload the photos to an Internet service which I created (popsee.com.) At present, I’m not making popsee.com available to the public — it’s part of a larger project which lets people request and submit videos — but I might consider some kind of simple public access as time goes on.

But you can easily take the code written here and POST the images to your own destination from the Raspberry Pi, like Dropbox or Google Photos.

Customize the file postimage.py to intercept the posting of images and the messages to display to remote users.

The basic responsibilities of the back-end popsee app are:

  1. Receive images to be POSTed
  2. Provide a real-time messaging to the user or administrator (done via SignalR — e.g., users using the app will see “photo uploading”, etc. status messages, and also see the new photos.) I built a POST endpoint into the app which lets the Raspberry Pi broadcast messages to the outside world about its status.
  3. Let administrator favorite or delete photos for the slideshow
  4. Display a slideshow of “favorited” photos in an “album”, which updates in real-time as new favorited photos are added
  5. Let users review photos and send the ones they want to their cellphone (done via Twilio)

Operation

Once the photo built is assembled (below), set up the photo booth and accompanying props in a high visibility area. Put a backdrop up (I didn’t have much time for this step.) It’s best to choose an area where it’s unlikely to get bumped or jostled. You’ll also want to orient the LED ring light away from the main crowd, as it can be distracting during the evening, turning on and off all the time. So an alcove of some kind is perfect. Station props nearby.

A guest walks up and presses the flashing blue button. The guests are told to “GET READY”, and they get three photo countdowns. The first is five seconds, and the second and third round are 3 seconds each.

With each countdown, the Photo Booth CPU turns on lighting (the LED ring light in this case), snaps the photo, loads it from the camera to the Raspberry Pi, presents it on-screen, uploads it in the background to the web. It repeats this process two more times. After finishing, it returns to kiosk mode.

I set this up at a party with about 150 people, and, though it was really dark and the backdrop could have been improved, the photos turned out pretty well:

Let’s Get Started

I strongly recommend you begin by trying to get the Raspberry Pi to “talk” to your digital camera via a Terminal and gphoto2 commands. The connection of buttons to trigger the countdown and the customization of the python scripts are pretty straightforward once you cross that item off your list.

Set up Raspberry Pi

Begin by getting your Raspberry Pi hooked up to a keyboard and mouse with Raspbian and on the Internet. (One gotcha I encountered: if you are using a MicroSD card that’s bigger than 32Gb, be sure to format it as FAT, not ExFAT, or else your Raspberry Pi won’t boot.)

Get your Raspberry Pi set to 1440×960 resolution via:

You’ll find screen resolution under the advanced options > Screen Resolution menu.

Next, Get “gphoto2” Working on Raspberry Pi

Before going further, the most crucial step is to ensure that your Raspberry Pi can communicate with your camera to take photos, download images, delete images, and reset the USB (which in my case sometimes became necessary due to gphoto2 not being fully bug-free when communicating with my Fuji X-T2.)

gphoto2 is an essential library which allows your Raspberry Pi to speak to a digital camera. Many digital cameras today have USB inputs which let you control the camera (take photos, download the images, etc.) The Picture Transfer Protocol (PTP) interface has become a widely used standard on many makes and models.

gphoto2 is a wrapper for libgphoto2 which allows many computers to talk to cameras. Raspberry Pi can run Python natively with the standard Raspbian NOOBS install.

The entire Photo Booth controller is written in Python, and makes use of the gphoto2 library to control it.

gphoto2

First, get your Raspberry Pi set up with the Raspbian operating system. I strongly recommend you use a keyboard and monitor to connect to it rather than using a headless browser. I purchased the dedicated cheap Raspberry Pi keyboard and mouse for this purpose and am keeping it with the photo booth enclosure.

Double-check that Python runs on it by opening up a terminal and typing “python”. You should see the python prompt. Type quit() to exit out of it.

Next, let’s get gphoto2 set up, so your Raspberry Pi can communicate with your camera. It takes several steps, involving cloning the library from Github and compiling them for your specific Raspberry Pi. Let’s start by ensuring your Pi is up to date:

sudo apt-get update
sudo apt-get upgrade

Now that we have everything up to date we will need to download the packages that we need for compiling the gphoto2 software that we will be utilizing.

Run the following command to install all the packages that we will be needing:

sudo apt-get install git make autoconf libltdl-dev libusb-dev libexif-dev libpopt-dev libxml2-dev libjpeg-dev libgd-dev gettext autopoint 

Once all the packages have finished installing, get the  libgphoto2 source code and compile it. Get the latest available version straight off the libgphoto2 Github by running the following command to clone it:

git clone https://github.com/gphoto/libgphoto2.git 

cd ~/libgphoto2
autoreconf --install --symlink 
./configure
make
sudo make install 

Now you need to compile the gphoto2 wrapper library:

cd ~ 
git clone https://github.com/gphoto/gphoto2.git 

cd ~/gphoto2
autoreconf --install --symlink 
./configure 
make 
sudo make install 

With the gphoto2 software now compiled we need to ensure that it can find the library that we compiled in the previous steps.

To start , we will first ensure that the configuration file referencing the “/usr/local/lib” folder exists.

Open up the file by running the following command on your Raspberry Pi:

sudo nano /etc/ld.so.conf.d/libc.conf 

Inside this file, you should find the following text, if it does not exist already then enter it:

# libc default configuration 
/usr/local/lib 

Now that we have ensured that the “/usr/local/lib” directory is being included we need to refresh the config cache so that the directory will be searched by the operating system when linking libraries.

To do this, we need to run the ldconfig tool by running the command below.

In the next few steps, we have to generate the udev rules for the cameras that you might be connecting. Without this, the gphoto2 application may not be able to talk with your camera.

Let’s generate the required udev list by running the following command. We will pipe the command directly into a rules file that the udev service will automatically read.

/usr/local/lib/libgphoto2/print-camera-list udev-rules version 201 group plugdev mode 0660 | sudo tee /etc/udev/rules.d/90-libgphoto2.rules

Finally, we need to generate the hardware database file for udev.

We can do this by running the following command. This command will automatically create the file in the correct location.

/usr/local/lib/libgphoto2/print-camera-list hwdb | sudo tee /etc/udev/hwdb.d/20-gphoto.hwdb

Now run the following command to test that gphoto2 is setup correctly:

Shortcut to Installing the full Gphoto2 Per Above

There’s a very nice script that user gonzalo has created, which will install the latest version of gphoto2:

https://github.com/gonzalo/gphoto2-updater

The code also depends upon “usbreset”, which can be found here: https://raspberrypi.stackexchange.com/questions/9264/how-do-i-reset-a-usb-device-using-a-script

Ensure that the gphoto2 volume monitor doesn’t get run at every startup, because  this interferes with the claiming of USB.

Remove execute privileges, for this photo monitor — run this at a terminal:  

sudo chmod 644 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor 

Get the “photobooth.py” software from Github as a starter, and Customize

The code I wrote is up on Github, and should be a good starting point for your code:

https://github.com/stevemurch/photobooth

cd ~
git clone https://github.com/stevemurch/photobooth

The main entrypoint is “photobooth.py“. You’ll want to rig your Raspberry Pi to run that program on startup.

UPDATE: Because I wanted to be able to use this same booth at different parties with different startup screens, the code now reaches out to the popsee server to get the configuration data at startup. You can disable this code by commenting out the call to get_current_config().

Install Other Dependencies

I wanted some sound with my photo booth, so photobooth.py requires mpg321, a sound player. Install it as follows:

sudo apt-get install mpg321

Photo Booth Setup

If you’ve got a Raspberry Pi communicating with your camera, ensure your USB cable is connected, and try running these statements at the command line:

gphoto2 --capture-image-and-download
gphoto2 --capture-image
gphoto2 --reset
gphoto2 --list-files 

If these run, congratulations! You’ve got the brains of the Photo Booth already working. It’s all downhill from here.

What I wanted my photo booth to do was to start in Kiosk Mode, flash the physical GO button on the enclosure and then, when the button was pushed, do this three times: (a) tell the audience to get ready, (b) turn on the LED ring light, (c) count down, (d) snap the photo, (e) turn off the LED ring light, (f) fetch the image from the camera and present it to the user, and (g) upload it to my back-end web service (popsee.com.)

Thus, for hardware inputs and outputs, there’s an input arcade-style button with a flashing LED light, a monitor (with sound), and a 110v GPIO-activated relay switch which temporarily turns on and off the photographic light.

INPUT PINS:

  • GO BUTTON (called BUTTON_BCM_PIN in the code; I connected this to physical pin 15)
  • RESET BUTTON (used in testing but I didn’t end up using in deployment)

OUTPUTS:

  • LED LIGHT for GO BUTTON (called LED_BCM_PIN in the code; I connected this to physical pin 22)
  • RELAY (called RELAY_CONTROL_PIN in the code; physical pin 12) to turn on 110V extension cord — the LED ring light is plugged into this cord

You can see the current setting of these in the photobooth.py code on Github.

Server: How Photos are Seen & Shared

Rather than printing out photos, since everyone has a mobile phone these days, I wanted to use that as a way to share the photos. The photo booth shows you a QR code, which leads the user to a website I created (popsee.com) with the “album” of the evening. There, they can review the photos and send the ones they want to their own phone.

In addition, an administrator can “favorite” the photos, marking them to be shown in the big-screen slideshow (projected from another computer.)

This was a simple Angular application hosted on Azure which takes POSTed photos for a given “album”. This will be the subject of a future post.

For now, you can disable this POSTing of photos by commenting out the functions in the “postimage.py” code.

At present writing, I don’t plan on opening up popsee.com to the general public, but may consider doing so in the future. If you’ve gotten this far, it should be relatively simple to wire up your own photo posting and review service — or you might even consider rewriting the code to post them to Twitter, Google Photos or Dropbox.

Build Your Own Enchanted Rose Prop (Part II)

Part 1 of this article covers the basic parts list, code, and assembly.

UPDATE (January 2023): I’ve built a version 2.0 of this prop. See “Enchanted Rose 2.0: Raspberry Pi Prop with Falling Petals” for updated instructions. 

UPDATE (April 2021): The Bluetooth shield used in this Arduino-based project is apparently discontinued. If I were to build this project again today, I’d make it a Raspberry Pi Zero W with Headers (or 3B+) based device. Take note on that order page of the adapter cables and power supply you should also get.

The RPi would run a simple Flask (python) server to control the servo motors. I’d attach an Adafruit Servo Motor HAT to do the servo motor control, and then build a simple web application to control the prop. This would eliminate all the Swift Coding involved in the app controller, and allow for much easier building/debugging. I would absolutely use the same drop mechanism. That is, servo motors, spring loaded magnets mounted in a wooden golf-ball sized drawer handle.

To be clear, this updated approach would mean I would not order the Redbear Labs BLE shield nor the Arduino, nor would I futz with the fun but unnecessary iOS app. But nothing prevents you from building a nice one to control a Raspberry Pi based prop!

Now that the Enchanted Rose Prop is nearing completion, I wanted to cover a few final details. Here’s a video of the app and prop in its current form:

Aesthetic Touchup

Some paint and floral tape was used to give the stem a little more rose-like appearance. Still in progress, but you get the idea.

Ring Lights

The ring lights are a Neopixel 1 meter long strip. I cut the strip between the LEDs at roughly the 40 LED mark. Doing so has no effect on the Neopixel, as long as you cut between LEDs.

Big gotcha: These lights only want 5V maximum! I fried the first set by overpowering it. Don’t make that mistake — it’s irreversible.

Stem Accent Lights

I purchased a cheap set of LED lights to add some interest to the stem.

These are powered by their own 3-AA battery pack. I’m sure I could use the same 3 AA-battery pack used by the Neopixel strip, but after frying one of those strips, I chose not to risk wasting another $30 tempting fate. To turn these on and off, an N-channel MOSFET transistor is used, with its gate actuator tied to pin 10 of the Arduino.

Basically, the MOSFET transistor lets current pass through if voltage is applied to the Gate pin (pin 1 in the diagram above.) When voltage on the gate goes LOW, the LED accent lights turn off. When voltage on the gate goes HIGH, the accent lights turn on.

Soundproofing

The servo motors are a little squeaky when moving. I installed some foam sound barriers (ordinary shipping packaging) to help dampen the sound.

Drop Mechanism

The initial approach of using piano wire to move flexible wires up and down worked fine from a dropping standpoint, but it had two distinct disadvantages in practice:

  1. the vertical extension above the bud made it hard to get the upper petals to to look real
  2. the “re-set” procedure was going to be way too hard for young adults to do Did I mention that after I had the prop working for an adult, my wife told me that the crew would be entirely comprised of fifth graders? “Hardening” the prop for fifth grade use for 8 performances in ways such as this was actually the most time-consuming part of the project.

So instead, I revised the attach/drop mechanism, to fishing-line-pulls-a-magnet.

I drilled four holes into a wooden 1 1/2″ golf-ball. Tip: use two drill bits, a small one that goes all the way through (just for the fishing line), and a wider one for the hole where the spring mechanism sits. You’ll want to give the spring something to push against, so don’t go all the way through the wooden ball with the drill, as I mistakenly did.

The key part are rod magnets which are inserted into thread covers and put into a spring:

I later added rubber caps over these magnets (but first drilled a small 6mm hole in the center.) I then hot-glued these caps-with-holes over these magnets. In “normal” state, the magnet protrudes through the caps to make surface contact with the washers inside the petals. When the Servo motor moves, it temporarily (2-3 seconds, programmable delay) pulls the fishing line which separates the magnet from the petal, and then resets it to the normal position. The advantage of this design is that it only uses servo motor power during the drop operation.

Result: TOTAL SUCCESS. Worked flawlessly in production and could even be re-set by kids (though I admit I double-checked pre-show.)

The fishing line is pushed through the (orange) nylon thread cover and a double knot is used to prevent it from pulling through. Then, the rod magnet is inserted, finally that’s inserted into a spring. That subassembly is repeated three more times, and inserted into the four holes in the wooden “bud.” You’ll want to make the exit hole for the fishing line quite a bit smaller than the upper hole, so the springs have something to push against. The only thing that comes through the bottom of that wooden ball is four strands of fishing line, which are fed down into the stem, one to each of the four servos.

The petals have a small metal washer hot-glued to the base, which is magnetically attached to the bud. When the servo motor turns, the rod magnet is pulled down about a half inch to an inch into the chamber, and this action causes the petal to fall. The servo motor returns to “slack” position and the spring returns the rod magnet back to its ready position.

The petals can then be reattached.

This drop mechanism is much more durable, and now that the magnets are “self-resetting”, I’m thinking of switching the slider-control based drop mechanism to a simple push-button interface.

(Update: I did so, and those changes are reflected in the Github code. It’s a simple four-button interface for the drop mechanism, one for each petal; this initiates a retraction of the servo, a pause for a second or so, and then restoration to the ready position.)

Epilogue

The performances— all eight showings — were smashing successes!

Izzy, the fifth-grade prop controller, did a great job controlling it and the prop functioned just as designed.

Izzie and The Rose Prop

If there was a flaw, it was that one of the petal drops (of the 32) worked but got hung up on the LED light bush below it, so it appeared not to drop, but that was pretty minor and not a big deal.

Note that I did decide to replace the full set of AA batteries in the entire prop after the fourth performance. I can’t speak to whether that was unnecessarily premature, but there were no battery failures. Each performance was about 90 minutes, and the power to the prop was turned on about a half hour before and after each performance.

The Enchanted Rose Prop is now in the hands of the school theater director (and computer tech teacher; she’s one and the same) as a partial thank-you for all her great work with the kids.

Build Your Own Enchanted Rose Prop

NOTE: There’s a version 2.0 of this project! Follow this link for information on Enchanted Rose 2.0.

My daughter is in Beauty and the Beast this spring. So I thought it’d be a good opportunity to test my Internet of Things (IoT) skills using Arduino, Bluetooth and iOS, and build a remote-controlled Enchanted Rose prop which has variable-color lighting and can drop petals on cue. I contacted the director, volunteered to make the prop, and she was all for it. Read on to see how you too can construct one of these.


UPDATE September 2022: Enchanted Rose 2.0

The plans which follow are version 1.0, based on Arduino, Bluetooth, and a dedicated iOS app written in Swift to control the prop. But the Bluetooth shield in this project has since been discontinued, and the iOS app, while nice and functional, is hard to distribute to others and troubleshoot. Apple is constantly upgrading (breaking compatibility) for its Swift programming language, making it a headache to get running on each instance. 

In the roughly 4 years since I published this piece, I’ve heard inquiries from multiple production managers (UK, CA, CO, NY and more) who want to acquire or rent such a prop. Rather than continue with support on this, I’m building a newer version which will be available for rent.

That of course also means the new design must be shippable, not as delicate as this version 1.0 design is. The 1.0 design is being tossed; the 2.0 design will employ a web server powered by a Raspberry Pi.

Follow me on Twitter to see when the version 2.0 is available (ETA early October 2022.) If you’d like to rent the 2.0 version of the prop, reach out, and please include your production date and ship-to address, and we can discuss. 

So, to summarize: While version 1.0’s design described in this two-part blog series might help guide you in building your own remote-control Enchanted Rose, it employs a few parts and software components that are no longer available. I cannot provide any tech help on the Swift control app, as there are just too many idiosyncracies and configuration issues. The 2.0 version I’m building at present is a different design, based on a Raspberry Pi controlling solenoids to drop the petals. This approach will be far more durable for shipment, and should be plug-and-play for any production.

Now back to the 1.0 article.


This is a two-part article. Lessons are learned along the way, so be sure to read the complete two-part article (Part II here) before proceeding and/or sourcing parts. Some of the design decisions were changed in final implementation; this is more in narrative form with learning lessons along the way.

Part 1 : Basic Prop Setup

At this writing, the vast majority of the prop is working, but it’s not yet fully finished. Some aesthetic touches remain. The performances are still a couple months away, so I’ll be updating this post as the project nears completion.

Here’s a demo of the project in its current stage. This stage uses a v2 mechanism to drop the petals.

Figuring out the best petal-dropping mechanism was actually the most time-consuming part of this project. I found it relatively easy to get an app to control servo motors using Bluetooth, but the question is — how to do you translate servo-motor turns into petal drops?

I originally started out with the idea of stiff piano wire, attached to servo motors in the base moving up and down and the petals having small cocktail straw segments hot-glued to them. This worked, if the prop was set perfectly.

But for various safety reasons (and especially after my wife reminded me that a fifth-grade crew was going to be operating and re-setting this prop), I switched to a version 2.0 design of tiny rod magnets mounted on springs in the “bud,” pulled by fishing line connected to the servos.

There’s a parts list and notes below, with links to the complete source code. Hopefully this this may help other performances that might have this same prop need.

The prop has three basic components:

  • Physical Prop (Rose and Dome)
  • Control App (iOS)
  • Arduino Microprocessor Software

The app “speaks” to the prop via Bluetooth, ably powered by this BLE Shield from Red Bear Labs:

UPDATE (November 2019): I believe the above model, which I used in this project, is now discontinued. If you insist on sticking with Arduino and Bluetooth, you might try other Bluetooth shields, like this one: https://www.adafruit.com/product/2746. You can see a demo of this shield in action here: https://www.youtube.com/watch?v=5ZQ5JJTwONcYou will have to adjust the Swift code included in this blog post to include the new board-specific libraries. Swift has changed considerably since the release of this article. That’s in part why I’d recommend you consider a Raspberry Pi – Wifi approach rather than and Arduino/Bluetooth/iOS-app approach. 

In addition to servo motors which control the falling petals, it has a variable-color LED-strip for optional magical effects on cue:

Parts List, v1.0

  • Display dome (“cloche”) with wooden base
  • 2–3 large Silk roses (will cannibalize some to get petals)
  • Arduino MEGA — While an UNO will work just fine if you don’t want the Neopixel accent light, I chose a MEGA here because the NeoPixel and BLE shield together don’t supply enough available pins to control 4 separate servo motors. (UPDATE April 2021: I’d opt for a Raspberry Pi Zero W, since it can speak WiFi and run Python and small websites.)
  • Wood for base: 3 12×12″ thin plywood sheets, 1 2 foot segment of 1×1
  • 3M Mounting Tape and hot glue gun
  • Coffee straws (if you stick with version 1 design), OR four small rod magnets, 1 1/2″ wooden ball and metal washers (if you use version 2 design)
  • Electronics “breadboard” and jumper wires
  • 17 AA batteries, yes 17. You’ll need 3 for the Neopixel lighting strip (and no more!), 8 to power the servos, and 6 to power the Arduino & BLE Shield. If you want to be fancy, I’m sure you could use a regulator to get from the 9V down to the 5V for the Neopixel, but after frying one of them, I wasn’t interested in risking it.
  • 3-AA battery case (1)
  • 6-AA battery case (1)
  • 8-AA battery case (1)
  • Red Bear Labs Bluetooth Low Energy (BLE) shield see note above – discontinued; you’ll most likely have to use a different BLE shield (Update April 2021: Not needed if you go with the Raspberry Pi approach, since the communication from controller to prop would be via Wifi.)
  • Adafruit NeoPixel strip (60 LEDs, 1 meter)
  • 18″ Aluminum tube
  • 4 springs, about 1/8″ diameter by 1 1/2 inches — not too stiff. I purchased my springs from a local hardware store; the spring from inside a ballpoint pen might also work as well.
  • 4 silicon/rubber thread covers
  • High-strength (e.g., 60lb) fishing line
  • 4 servo motors (Update April 2021: With a Raspberry Pi Zero W approach, I’d definitely opt for a motor controller board, since controlling servos via software on the Raspberry Pi ends up with all kinds of timing issues and motor jitter; you really want a piece of hardware to take control of the Pulse Code Modulation. The right board for the job is this one by Adafruit.)
  • 1000 mu capacitor
  • 300 ohm resistor
  • Sound baffling and/or black felt curtain for the base
  • (optional) 3 toggle switches for power — alternatively, you can just remove a battery from each pack
  • Soldering iron and solder

Physical Prop

What actually causes the petals to drop are four servo motors located beneath the base. They move string that temporarily pulls down a spring-mounted magnet through the stem. This breaks a magnetic connection between the magnet and a washer hot-glued to the petal, causing petals to drop. After a second or two, the servo motor returns to its normal position (with the spring resetting the magnet to being just 1mm proud of the hole).

Use a vise to hold the ball before drilling through. Also, drill with two different sizes of drill bits — be sure to make bottom holes much smaller than top holes, to give something for the springs to rest & push against, so the springs cannot fall through

Dry-fit test, before fishing line was passed through the orange nylon thread cover

To assemble, find the exact center of the dome’s base, and drill a hole just large enough for the aluminum tube. Build a supporting structure which goes under the base, which consists of a shelf for the servos and room for the electronics underneath. Next, affix the servos to the “servo shelf” — I used wall mounting tape from 3M for this purpose. Run piano wires from each servo up through the aluminum “stem.”

The original design was to have the petals attached to the wire by means of small straw segments. When the piano wire withdrew 1/2″ or so into the tube, the petals should fall.

While this simple mechanism worked, I found it was extremely difficult to “reset” for every performance with the wires bunched so tightly together at the flower.

So the final version uses the spring-loaded magnet technique, which works great. Take the silicon/rubber thread covers, drill a very tiny hole in the bottom, thread high-test fishing line through, and tie a double knot at the end. Then, push the rod magnets into the thread covers, and thread the thread covers into the springs, as shown above.

Small metal washers are then hot-glued to individual petals. When the fishing line is pulled by the servo, the magnet withdraws into the stem and separate from the washers on the petals, causing the petals to fall off.

An electromagnetic way of attaching/dropping petals would also work, but for pragmatic reasons, I didn’t pursue that approach: the performance is 1–2 hours long, and I worried about the batteries giving out before the cue. With the magnet and fishing line approach, the petals can stay attached without power.

Control App (iOS)

  • Written in Swift 4 (XCode) and published straight to the device.
  • You’ll need a Mac and the IDE XCode (free at this writing). You do not need a developer program license, since you’ll be publishing the app straight to your iOS device (works with both iPhone and iPad.)
  • You can get the source code from Github here: https://github.com/stevemurch/EnchantedRoseBLE
  • This source code requires you to install the CocoaPod for the color picker. As with all Cocopod-based projects, you’ll need to open the .xcworkspace file, NOT the standard project file, to get the app to compile.
  • This source code assumes that your servos are linked to pins 2, 3, 5 and 6.

Arduino Software for the Microcontroller

Gotchas

  • You will RUIN your $35 Neopixel strip if you accidentally power it with more than 5V! I learned that lesson the hard way; in my haste I wired in the Neopixel strip to the 12V power rail being used for the servos. That permanently fried the light strip instantly. Don’t do that. Instead, create another 4.5V power rail, using 3 (and only 3) AA batteries. The Neopixel strip is awesome, but very sensitive to too much voltage. Be sure to read the Neopixel documentation that shows how to wire in a 1000 mu capacitor and 300 Ohm resistor.
  • The servo motors however require much higher voltage to operate smoothly (12V.) So I powered these entirely separately, using a separate power rail on the breadboard. Make sure you wire the common grounds together, and both back to the Arduino.
  • The Neopixel documentation suggests you power on the Arduino before powering on the Neopixel. So we’ll be powering up in the following order: (1) Board, (2) Servos, (3) Neopixel, (4) Launch app. If you fail to do it in that order, the app might try to connect before a signal is available from the prop and timeout. Simply relaunch the control app and it should discover the device.
  • Connection is excellent, and works through walls and for more than 40 feet. If connection is lost, simply restart the app.
  • It turns out there is a known conflict between the Neopixel strip and servo motors (has to do with timing/interrupts). The fix involves using a custom servo library which limits the Uno to just two servos. So, I decided to upgrade to an Arduino MEGA to get more servo ports. I also used the custom library for servos located here: https://learn.adafruit.com/neopixels-and-servos/the-ticoservo-library
  • This source code assumes that your servos are linked to pins 2, 3, 5 and 6 (note: there’s no 4), and that your Neopixel control pin is 7. All are digital pins.

Basic wiring diagram — note the batteries are just representative; each source has different voltage requirements.

Wiring (BLE Shield not shown, but it’s plugged into Arduino board)

At current writing, all servos and lights work, including the ability for stage crew to set the lighting color. I’m now working on improving the physical petal dropping, by making it easier to re-set (done, and Github code reflects that.) UX changed slightly from the screen below — I changed it to four pushbuttons, one for each petal.

App Screenshot

Servo shelf on top, electronics below. The servo shelf is doughnut-shaped.

Version 1.0 of Petals. I didn’t think this method will be easy for a stage-crew to re-set, so I switched to magnets and hot-gluing small metal washers to the petals.

Physical Prop (in progress — leaves and petals will be attached to stem, and perhaps the stem will be bent.)

Read more… Part II: Finishing Touches