By Duane Benson, Technical Journalist, Consultant, and Futurist.
As a child, I spent a few years living in Manassas, Virginia, with a backyard bordered by a generous hedge of honeysuckle vines. Throughout the summer, fireflies (a.k.a. lightning bugs) would spend the evening feeding on the flowers in the hedge, making for an enchanting light show. I live out west now, where the fireflies don’t live, so I’m creating my own in the form of a self-forming network of ESP32-powered electronic fireflies.
It never ceases to amaze me how much capability you can get for just a few dollars these days. Take these ESP32 boards I picked up from Seeed Studio. Seeed has a line of ESP32 boards called XIAO that range in price from $4.99 USD for the ESP32C3 to $7.49 for the ESP32S3 used in this project.
The S3 is powered by an ESP32-S3R8 System- on-Chip (SoC) with a dual-core Xtensa LX7 running up to 240MHz with 512KB of SRAM. It also has 8MB of PSRAM and 8MB of Flash in the chip. For wireless, it has Wi-Fi and Bluetooth 5.0. The version I bought comes with an external antenna for better range and a 100mA LiPoly charging circuit.
It comes with, among other I/O capabilities, up to nine capacitive touch pins and Bluetooth mesh networking, both of which I need for this project. The boards support several development environments, including MicroPython and the Arduino language, which I use here.
Bluetooth Mesh is a 5.0 feature that allows devices to form a mesh network. The mesh feature was designed to allow many devices to join into a network without requiring a central controller, a feature I will rely on for this project.
My fireflies will be built around an undetermined number of S3s. Each will come equipped with a few LEDs, a battery, a hard power switch, a shake switch, and one or more capacitive touch sensors. There will be no primary controller as each S3 can assume that role. I plan to put my finished fireflies in small glass jelly jars with screw-on metal lids. The electronics will be hot glued to the inside of the lid, with the individually wired LEDs hanging down to be visible through the glass. The lid will be connected to one of the ESP32’s capacitive touch inputs. Power can come from a trio of AAA batteries or a small LiPoly rechargeable battery.
The program flow will be reasonably simple: Sleep while nothing is happening. Wake up upon a shake, capacitive touch input, or Bluetooth signal. Once awake, flash the LEDs in a semi random pattern and send an outgoing signal to the mesh. Each device will be limited to a set number of outgoing signals within a given time span to prevent the network from running on forever (you can find my code and a parts list on my GitHub site at bit.ly/47ytMDs)
In practice, this network of firefly jars will be deployed in various spots across my backyard. When someone stumbles across a firefly, they can pick it up, which will cause all of the other fireflies to light. If multiple people pick up fireflies, any one of them can cause the whole set to flash. Different flash patterns will be based on the combination of patterns detected from the capacitive touch and the shake switch.
Got a design project you’d care to share? Contact our Editor: [email protected]