Space Drums 2.0 - Smart Air Drum Sticks That Gamify Your Learning
by Makestreme in Circuits > Microcontrollers
623 Views, 12 Favorites, 0 Comments
Space Drums 2.0 - Smart Air Drum Sticks That Gamify Your Learning
A while back, I built an open source prototype of Space Drums, a pair of smart motion tracking sticks that let you play a full drum kit in thin air. It was fun, but it had one (of many) problem that almost all air drummers face.
If you look at reviews for commercial air drums, most people who buy them are beginners because they want a cheap, silent, portable way to learn drumming without buying a massive, expensive physical kit. But once beginners start playing, they find it quite difficult. Not being able to match the way the YouTubers who marketed them play, they give up and the sticks end up gathering dust in a drawer. I wanted to fix that.
Meet Space Drums 2.0 and the Space Drums Trainer!
Space Drums 2.0 completely upgrades the hardware with self contained motion tracking, haptic feedback, and wireless foot pedals, all in nice looking 3D printed housings. But the real deal is on screen. I built a full arcade learning engine in Python, inspired by the gameplay of VR hits like Beat Saber. And you learn to play the drums while you have fun playing a game!
Notes roll down a 3D visual highway mapped directly to where your sticks swing in the air. The tempo starts at a slow 42 BPM and gently ramps up as you play, while the sticks give you haptic feedback and sound on every hit. It turns complex hand and leg coordination into an addictive (yes, trust me!) game.
Supplies
Electronics & Hardware (Drumsticks x2)
- Custom Space Drums 2.0 PCBs (2x): Gerber files and BOM are available in my GitHub repository.
- 3.7V Rechargeable LiPo Batteries (2x): Purchase Link
- Momentary Power Switches (2x): Purchase Link
- 3M Double-Sided Foam Tape: Purchase Link
- M2 Screws (6x total): Purchase Link
Foot-Pedal Hub Assembly
- Esp32 S3 (1x): I'm using a xiao esp32s3. Purchase Link
- Momentary Foot Switches (2x): Purchase Link
- USB-C Data Cable: Connects the XIAO hub to your computer.
3D Printed Parts & Enclosures
- Drumstick Base & Tip Sets (2x): STL files provided in the GitHub repository.
- Power Button Covers (2x): Optional printed caps for the power switch.
- Adafruit USB Foot Switch Enclosures (2x): Printable pedal housing designs. GitHub repository.
Software & Digital Assets
- PC: Running Python 3.10 or newer.
- Python Packages: pygame-ce (graphics/audio) and pyserial (hub communication).
- Drum Samples (9 WAV files): Placed in an audio/ directory (crash.wav, snare.wav, tom1.wav, tom2.wav, ride.wav, floor_tom.wav, kick.wav, hihat_open.wav, hihat_closed.wav). All in my GitHub repository.
- Arduino IDE: To flash firmware onto the sticks and XIAO hub.
Tools Required
- Soldering iron & solder
- Wire strippers & hookup wire
Game Overview
This Instructable will have two sections. In one, I will cover building the sticks and in the next, I will explain the game.
Game Overview (Space Drums Trainer)
The Space Drums Trainer is an arcade style visual game built in Python using pygame. Notes drop down a spatial highway designed around how your arms swing in 3D space.
- Visuals: Lanes are arranged to match where drums sit in the air, with target pads split into two tiers (upper for cymbals/toms, lower for snare/floor tom). Notes are color coded: Blue for left hand, Red for right hand, Yellow bars for kick pedal strikes, and dashed yellow bands instructing you to lift the hihat pedal.
- Mode 1: Learn to Play (20 Levels): A step by step curriculum for complete beginners. Every level launches at a slow 42 BPM and smoothly ramps up speed as you play, guiding you from basic quarter note snare hits up to full kit 2 bar grooves with fills.
- Mode 2: Learn Rhythms: A library of standalone loops (Rock, Disco, Shuffle, Funk). You can listen to an audio preview, select a custom slow starting BPM, and practice at a comfortable pace while the tempo dynamically scales up toward target speed.
- Mode 3: Custom Rhythms (Coming Soon): An upcoming mode designed for importing custom MIDI drum files to auto generate falling tile tracks for any song so you can learn it through the game.
The video above explains the game clearly.
Hardware Overview
The original Space Drums prototype had some a major flaws. It relied entirely on a smartphone camera to track your body posture and determine which virtual drum you were pointing at. This made the setup clunky, introduced good amount of latency, and offered zero physical feedback when striking a drum.
Space Drums 2.0 solves these issues by moving orientation tracking and swing detection directly onto the sticks themselves:
- Self Contained Sensing: Each stick houses an ESP32-S3 microcontroller, dual ICM-42688-P IMUs, and an MMC5983MA magnetometer. The sensors together track pitch, roll, and hit deceleration accurately on the sticks.
- Built in Haptic Feedback: An onboard haptic motor produces a tactile vibration pulse the exact millisecond a virtual hit registers, giving your hands physical impact feedback.
- Ultra Low Latency: The sticks transmit hit packets directly to a central pedal hub using ESP-NOW protocol, completely bypassing latency heavy Wi-Fi or Bluetooth approaches.
- 3D printed housing: Gone are the heavy PVC pipe sticks. Now we have sleek, lightweight ABS printed sticks and foot pedals.
How Space Drums 2.0 Works
From here, I'll explain the working and build process of the hardware. For the game details, jump to Step 11
Before heating up the soldering iron, let's take a quick look at how all the pieces work together.
Space Drums 2.0 is made up of three main parts:
- Two ESP32-S3 based drumsticks that track motion and detect hits
- An ESP32-S3 foot-pedal hub that receives the sticks' wireless data and reads the pedals
- A PC or Android application that turns those events into drum sounds and provides the user interface
The two sticks communicate with the hub using ESP-NOW. The hub then sends the drum and pedal events to the computer over USB serial, where the audio application plays the appropriate samples.
The drumsticks
When you calibrate the sticks, you point them toward the location where you want the snare to be. That direction becomes the reference point for the virtual drum kit.
From there, the firmware continuously tracks the stick's orientation. When you swing the stick, it detects the swing and determines which virtual drum corresponds to the direction you're pointing.
The drum layout is divided into two rows.
The upper row is selected when the stick is angled above 35 degrees, while the lower row is selected below 35 degrees horizontal playing. Within each row, the stick's yaw determines which drum zone you're pointing toward. Outside the defined angular zones, no drum is triggered.
Detecting the hit
The firmware uses the motion data to detect a swing and the resulting deceleration. Once a hit is detected, it produces a drum ID and a velocity value. The velocity is represented as a value from 1 to 6 loudness values.
The stick can also trigger its haptic actuator, giving you physical feedback when the virtual hit occurs.
The foot-pedal hub
The foot pedals are connected directly to a separate Xiao ESP32-S3, which acts as the receiving hub for both sticks.
The left pedal is connected to GPIO 1 and the right pedal to GPIO 2. The switches are wired between the GPIO pins and ground, with the ESP32's internal pull-ups making the inputs active-low.
The right pedal always acts as the kick drum.
The left pedal can be configured either as a second kick drum or as a hi-hat controller. In hi-hat mode, pressing the pedal closes the hi-hat and releasing it opens it. This assignment is handled by the application (PC/Android), so changing the left pedal's function doesn't require reflashing the hub.
3D Printing
The assemblies were designed on Fusion 360.
There are three assemblies to print. All files can be found in my Github repo
1 x Drumstick assembly
- Stick base
- Stick tip
- Power-button cover (Optional)
2 x Foot-pedal assemblies
- This design was taken from an Adafruit project. Follow their guide here.
Print all the parts before beginning the electronics assembly. The stick enclosure is designed around the custom PCB, with openings for the USB-C connector and power button, so make sure the printed parts are clean and the relevant openings are unobstructed.
Build the Drumsticks
Mount the PCB
Start by placing the Space Drums PCB into the printed stick base.
Use strong 3M double-sided tape to secure the PCB in position. Make sure the board sits correctly in the enclosure and that the USB-C connector lines up with the opening in the printed housing.
The USB-C port is accessible from the outside so you can use it both for charging the battery and uploading new firmware without having to open the stick.
Connect the battery
The stick is powered by a rechargeable battery.
Solder the battery wires to the BAT pads on the PCB, making sure to observe the correct polarity.
Install the power button
Next, solder a momentary switch to the dedicated switch pads on the PCB.
The printed stick housing has a mounting location for this switch, allowing the button to be operated from the outside. I also designed a small 3D-printed cover for the switch, which can be fitted once the switch is in place.
Repeat the same process for the second stick.
The foot pedals can be built with adafruit's guide: https://learn.adafruit.com/usb-foot-switch-circuit-python/overview
Then the switches can be connected to the hub esp32 as mentioned before.
Flash the Firmware
With the hardware assembled, it's time to load the firmware and set up the software that will turn the drum events into sound.
There are two firmware programs involved:
- Stick firmware — runs on both drumsticks and handles motion sensing, hit detection, calibration, and battery monitoring.
- SpaceDrums2 Hub— runs on the XIAO ESP32-S3 and handles ESP-NOW communication, the foot pedals, and the USB serial connection to the computer.
Start with the ESP32-S3 hub.
Open the hub firmware in the Arduino IDE and upload it to the XIAO ESP32-S3. Once it has booted, open the Serial Monitor at 500000 baud.
The hub will print its MAC address at startup. Make a note of this address, because both drumsticks need it to know where to send their wireless data.
Configure the drumsticks
Open the stick firmware and make two small changes for each stick.
First, assign a unique ID:
Then enter the MAC address printed by the hub into the hubAddress[] setting.
Both sticks should use the same hub address, but each must have its own STICK_ID.
Now flash the firmware onto each stick.
Arduino IDE settings
For the ESP32-S3-MINI-1-N8 used on the sticks, use the settings in the image above.
Setup the PC Application (Optional)
The PC version of Space Drums uses Python for the audio engine and user interface. Skip this if using the android app from my Github.
First, install the required Python packages:
Then start the application:
Before running it, set COM_PORT near the top of audio_hub.py to the serial port belonging to the hub, not either of the drumsticks.
The audio application expects the drum samples to be in the same folder. The default sample names are:
If a sample is missing, the application falls back to a buzz rather than crashing.
If you're using Android instead, the provided SpaceDrums.apk can be used in place of the PC application. Both applications perform the audio playback, kit UI, and battery display functions.
Calibrate and Play
The hardware and software are ready. Before you start drumming, there are just a couple of calibration steps to complete.
Calibrate the sticks
First, turn on both drumsticks by long-pressing their power buttons.
When a stick powers up, point it toward the position where you want the snare to be and hold it still. The calibration process uses this direction as the zero point for the virtual drum kit.
The stick goes through a short settling and calibration sequence. Keep it steady while the calibration is running. If you move during this period, the calibration window restarts, so simply hold the stick still until it finishes.
Once calibration is complete, that position becomes your reference for playing.
The calibration also re-measures the gyro bias and establishes the stick's attitude using gravity. It sets the pitch and yaw zero at the direction you're pointing, so it works regardless of which direction you're facing in the room.
One-time magnetometer calibration
There is also a separate magnetometer calibration that needs to be performed once per stick after a fresh firmware installation.
This compensates for magnetic distortion caused by components within the stick itself, including the battery, haptic actuator, and PCB.
To perform it:
- Move away from speakers, computers, steel furniture, and other sources of magnetic interference.
- Open the stick's serial connection.
- Type magcal. Press enter
- For the next 18 seconds, slowly move the stick in figure-8 patterns.
- Check the calibration result.
Failed calibration data is not saved, so a failed attempt won't overwrite a previous good calibration.
Recalibrate while playing
As you play for long durations, you may occasionally feel that the virtual drum positions have shifted slightly.
If that happens, simply point the stick back toward the snare position and short-press the power button.
The stick runs the same short zeroing sequence again. Once calibrated, the space in front of you becomes your drum kit.
Tune and Troubleshoot
At this point, you should have a working pair of air-drumming sticks. But because the entire system is open source, you don't have to stop there. You can tune the way the sticks feel, modify the drum layout, or dig into the communication between the hardware and software.
Fine-tuning the playing experience
Most of the parameters that affect how the sticks feel are grouped near the top of stick_firmware.ino.
For example, you can adjust the boundaries of the virtual drums using parameters such as TOP_ROW_PITCH, TOP_YAW_CRASH, TOP_YAW_RIDE, and the bottom-row yaw limits. This lets you change how far you need to move the stick to reach each drum and how large each virtual playing zone is.
You can also adjust the hit-detection thresholds:
- SWING_START_THRESHOLD controls how hard a swing needs to be before it is armed.
- HIT_DECEL_THRESHOLD controls how much deceleration is required to register the hit.
If you're getting accidental hits, increasing these thresholds can make the system less sensitive. If hits aren't registering reliably, you can experiment with lowering them.
There are also parameters controlling orientation correction and gyro-bias learning, as well as pedal debounce and pedal velocity.
A note about latency
One of the things that makes the system feel responsive is keeping the communication path lightweight.
The sticks send compact ESP-NOW packets to the hub. A hit packet contains the event type, stick ID, drum ID, velocity, and battery information. The hub then converts these events into simple serial messages for the audio application.
For example, a hit is represented as:
Pedal events use P, while battery updates use B.
If you're playing through the PC application, keep CONSOLE_LOG disabled during normal use. Printing every hit to the terminal adds measurable latency on Windows.
Troubleshooting
The sticks don't connect to the hub
Make sure the hub was flashed first and that its MAC address is correctly entered into hubAddress[] on both sticks. Also check that the left and right sticks have different STICK_ID values.
Calibration keeps restarting
The stick needs to remain still during the calibration window. If you move it, the calibration process restarts automatically.
The drum positions feel rotated
Simply point the sticks toward your desired snare position and short-press the power button to re-zero them.
Magnetometer calibration fails
Perform the one-time magcal procedure away from speakers, computers, steel furniture, and other sources of magnetic interference. Make sure you're rotating the stick through different orientations during the figure-8 movement.
A pedal triggers repeatedly
The hub uses a software lockout for pedal debouncing. The default PEDAL_LOCKOUT_MS is 35 ms; Increase it toward 50 ms if a press produces repeated triggers, while keeping it below roughly 75 ms for fast double-bass playing.
Under the Hood
The code is quite long to explain in an already long Instrucctable. Feel free to refer to my repo and read the Readme. It explains a lot.
Here's a brief overview:
The sticks don't need to know anything about audio samples. They simply detect an event and report which stick hit which drum and with what velocity.
The hub similarly doesn't decide which sound to play. It receives the wireless events, reads the pedals, and passes everything to the application.
This separation makes the project easier to modify. The current protocol already distinguishes between hit, battery, and pedal events, and the application can decide how those events should be presented or sounded.
Setting Up the Trainer Software
Install Prerequisites: Ensure you have Python 3.10 or newer installed. Open your terminal or command prompt, navigate to the project directory, and install the required dependencies: pip install -r requirements.txt (or install pygame-ce and pyserial manually).
Add Drum Samples: Create a folder named audio/ in the game directory and place nine standard .wav files inside:
- crash.wav, snare.wav, tom1.wav, tom2.wav, ride.wav, floor_tom.wav, kick.wav, hihat_open.wav, hihat_closed.wav. These are all available in my github repo.
- If any audio sample is missing, the game gracefully falls back to a soft synth buzz so you can still play.
Launch the Game: Plug in your XIAO ESP32-S3 pedal hub via USB and run: python -m spacedrums_trainer.
- The software automatically scans your serial ports, connects to the hub at 500,000 baud, and auto-reconnects if unplugged.
- Offline Testing: You can test without hardware using keyboard shortcuts (A through J for drums, Space for kick, Shift for hi-hat lift).
Here is a guide on installation and getting started.
Understand the UI
The trainer uses a visual highway designed around physical drum kit geometry:
- Kit-Matched Lanes: Lanes only appear for the drums required by the current groove, arranged left-to-right to match where you swing in thin air. Target pads at the bottom sit on two vertical tiers: upper for cymbals/toms, lower for snare and floor tom.
- Visual Color Syntax:
- Blue Discs: Play with your left stick.
- Red Discs: Play with your right stick.
- Solid Yellow Bars: Strike the kick pedal with your right foot.
- Dashed Yellow Bands (LIFT): Lift your left foot to open the hi-hat, returning it down when the band passes.
- Joining Lines: Connect notes that must be struck simultaneously.
- Live Micro-Timing Bar: A horizontal bar at the bottom gives real-time visual feedback on whether your physical hits are landing slightly Early or Late.
Mastering the Game Modes
Mode 1: Learn to Play
- Designed as a 20-level step-by-step curriculum for complete beginners.
- Starts at Level 1 ("First Beats") at a slow 42 BPM crawl and smoothly accelerates up to target tempo as you play.
- Progress builds from single-limb quarter notes up through 3-limb coordination, fills, and full-kit patterns.
Mode 2: Learn Rhythms
- A practice library containing standalone grooves (Rock, Disco, Half Time, Shuffle, Funk, Tribal Toms, Stadium Anthem).
- Press Space to listen to an audio preview. Once selected, use the slider to choose a comfortable starting BPM. The groove dynamically ramps up speed as you play to build confidence.
Mode 3: Custom Rhythms (Coming Soon)
- Placed on the main dashboard for importing custom .mid drum tracks, automatically generating falling-tile levels for any song.
Scoring & Timing Calibration
- Grading System: Each hit is judged on timing relative to note impact: Perfect (100 pts), Good (75 pts), OK (45 pts), or Miss (0 pts). Timing windows scale dynamically with tempo so adjacent notes never overlap.
- Performance Readout: Completing a run awards XP, accuracy stars (1 star at 65%, 2 stars at 80%, 3 stars at 92%), and a timing diagnostic (e.g., "You are running 24 ms late"), telling you exactly how to calibrate your swing.
- Timing Calibration: If hits feel consistently off due to serial processing or display lag, open ~/.config/spacedrums/settings.json and adjust input_offset_ms to align the visual target line perfectly with your physical movement. But you'll probably not have to do this.
Closing Thoughts
Space Drums 2.0 took me almost a year to get to this point. From researching whether something like this was possible, to building the first version, learning PCB design, developing the electronics and firmware, and iterating on the design.
I didn't build it with the intention of turning it into a commercial product. It started as a curiosity that I wanted to satisfy.
And that's ultimately why I'm open-sourcing it.
The complete project is available so that you can build your own version, modify it, improve the tracking, experiment with the firmware, design your own enclosure, or simply use it as a starting point for something completely different.
You don't need to already know how to build something before you try.
So if you've been thinking about building something that seems a little beyond your current skills, give it a shot.
Stay curious, keep experimenting, and have fun building.