Introduction: HackerBox 0028: JamBox
JamBox - This month, HackerBox Hackers are exploring sound generation and interfacing on the JamBox Audio IOT Platform. This Instructable contains information for working with HackerBox #0028, which you can pick up here while supplies last. Also, if you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!
Topics and Learning Objectives for HackerBox 0028:
- Configure the ESP32 System-on-Chip
- Program the ESP32 from the Arduino IDE
- Assemble the JamBox Audio IOT Platform
- Control I/O for buttons, knobs, and LED grids
- Construct user interfaces from I/O hardware
- Communication audio streams over I2S
- Stream audio samples to DAC modules
HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. We are the dreamers of dreams. HACK THE PLANET!
Step 1: HackerBox 0028: Box Contents
- HackerBoxes #0028 Collectable Reference Card
- Exclusive JamBox Printed Circuit Board
- ESP32 DevKitC
- CJMCU PCM5102 I2S Digital-to-Analog Module
- Four MAX7219 8x8 LED Matrix Modules
- Five 10K Ohm RV09 Potentiometers
- Five Potentiometer Knobs
- Eight Tactile Momentary Buttons
- Four Adhesive Rubber Feet
- 3.5mm Audio Patch Cable
- MicroUSB Cable
- Earbuds with Case
- Exclusive HackerBoxes Skull Decal
- Octocat Fan Art Decal Sheet
Some other things that will be helpful:
- Soldering iron, solder, and basic soldering tools
- Computer for running software tools
Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore DIY electronics is not a trivial pursuit, and we are not watering it down for you. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from learning new technology and hopefully getting some projects working. We suggest taking each step slowly, minding the details, and don't be afraid to ask for help.
Note that there is a wealth of information for current, and prospective, members in the HackerBox FAQ.
Step 2: Exclusive JamBox Printed Circuit Board
The JamBox PCB supports an ESP32 microprocessor module, four MAX7219 8x8 LED matrix modules, five 10K potentiometers for analog input, and eight tactile momentary buttons for digital input. Audio output is provided using an ESP32 internal Digital-to-Analog Converter (DAC) block or optionally connecting to an external CJMCU PCM5102 I2S DAC Module. The PCB has mounting holes, or adhesive rubber feet may be applied.
IMPORTANT ASSEMBLY NOTES:
- To use the ESP32 built-in DAC for audio output, do not solder the PCM5102 module into place. Simply use the IO25 and GND pins to drive headphones or an amplified speaker.
- The four 8x8 LED Matrix Modules are oriented with the input lines at the top and output lines at the bottom.
- The mechanical strain "pins" on the five potentiometers are just a tiny bit too wide for the holes in the standard RV09 footprint. An easy fix is to use small pliers to fold the flat strain "pins" into more of a taco or taquito shape. Then they should slip right in. [VIDEO]
- The 15x5 prototyping grid may be used for additional I/O interfacing. MIDI anyone?
Step 3: ESP32 and Arduino IDE
The ESP32 is a single chip computer. It is highly integrated featuring 2.4 GHz Wi-Fi and Bluetooth. The ESP32 integrates the antenna switch, RF balun, power amplifier, low noise receive amplifier, filters, and power management modules. As such, the entire solution occupies minimal Printed Circuit Board (PCB) area.
The ESP32DevKitC is a small ESP32-based development board produced by Espressif. Most of the I/O pins are run out to the pin headers on both sides for easy interfacing. A USB interface chip and voltage regulator are integrated into the module. The ESP32 is supported within the Arduino ecosystem and IDE, which is a very quick and easy way to work with the ESP32.
The Arduino ESP32 github repository includes installation instructions for LInux, OSX, and Windows. Click to that link and follow the instructions that correspond with the operating system on your computer.
Additional Resources:
ESP32 Datasheet
ESP32DevKitC Schematic
ESP32 Technical Reference Manual
ESP32 Arduino Instructable
Step 4: JamBox I/O Demo
The attached demo code (IOdemo.ino) is useful to demonstrate basic operation of the 8x8 LED outputs and user inputs from the eight push buttons and the five analog potentiometers. These I/O hardware elements are the basis of our user interface system.
Arduino Library for the 8x8 LED modules.
Attachments
Step 5: ESP32 Internal DAC for Audio
A digital-to-analog converter (DAC or D-to-A) is a system that converts a digital signal into an analog signal. DACs are commonly used in music players to convert digital data streams into analog audio signals. Audio DACs generally low-frequency and high-resolution. [Wikipedia]
The ESP32 has two internal 8bit DACs. These DACs can convert any 8 bit value to an analog voltage output. The 0-255 8-bit input values map roughly to the voltage range of 0V to 3.3V on the ESP32. A digitized audio sample can be played it back through the DAC.
Check out the example sketch shown here as internalDACsimple.ino to see what happens when you sample a sine wave and push the samples out to the internal DAC.
The video shows a demo doing this with some Pac-Man game sounds. This is basically doing the same thing but with more complex sampled signals than the points on a sine curve. You can try out the Tutorial and Code for the Pac-Man sounds in this link from Barton Dring.
Remember that we are only using the internal DAC inside the ESP32 so you can grab the analog signal directly from ESP32 pin 25 and ground. The external DAC is not needed. The analog signal from pin 25 can go directly into some earbuds or amplified speaker inputs, but it cannot really drive a speaker on its own.
Attachments
Step 6: ESP32 Using I2S
I2S or IIS (Inter-IC Sound) is an electrical serial bus interface standard used for connecting digital audio devices together. It is used to communicate PCM audio data between integrated circuits in an electronic device. The I2S bus separates clock and serial data signals, resulting in a lower jitter than is typical of communications systems that recover the clock from the data stream. [Wikipedia]
The ESP32 has two I2S peripherals. They can be configured to input and output sampled auto data. They also support direct memory access (DMA) to stream sample data without consuming CPU cycles. The I2S outputs can be routed to an external I2S codec or to the onboard ESP32 DACs as shown in this demo from IOTSharing.
Step 7: Grid Step Sequencer Demo
The video shows a typical Grid Step Sequencer concept. The JamBox 8x32 LED Matrix, button inputs, rotary inputs, and audio DACs provide a very nice platform for implementing a grid step sequencer.
The sketch in this repo from Stephen Beechen implements a grid step sequencer on the JamBox. This example sequencer employs the external DAC board over I2S as well as the buttons and dials for various user control features.
Step 8: JamBox to the Limit!
The JamBox hardware can support a wide variety of sound machines. Show us what you come up with!
Browse some other DIY sound toys for a little inspiration...
Simple Synthesizer
Codeduino Grid Step Sequencer
Auduino sound synthesizer
General background on making sounds
One crazy block sequencer
Step 9: HACK THE PLANET
If you have enjoyed this Instrucable and would like to have a box of electronics and computer tech projects like this delivered right to your mailbox each month, please join the HackerBox revolution by SUBSCRIBING HERE.
Reach out and share your success in the comments below or on the HackerBoxes Facebook Page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of HackerBoxes. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!
55 Comments
Question 4 years ago on Step 9
I done messed mine up, I think. Or it messed itself up. So I had the main processor and the matrixes and buttons, without the DAC and pots, and it was working great visually. Then I added the DAC and pots, I don't think I did anything incorrectly there, and now the display's gone all bonkers. Bonkers, in my case, translates to the rightmost matrix displaying rolling text, and the other three either blank or fully lit, randomly.
First thing I did was try to trace continuity among all the matrixes. Since those are in/out, I assumed correctly that I should have continuity for each corresponding pin along the whole path. EXCEPT I don't have continuity from DATA IN to DATA OUT on the rightmost matrix (the first one). Even touching the pins themselves. Does that mean the board for that matrix has gone bad? DATA OUT has continuity all the way to DATA OUT on the last matrix (leftmost). I suppose it's worth trying to resolder, but here's the thing. If matrix 1 is getting rolling text, that means DATA IN is connected, right? And if I have continuity from DATA OUT on matrix 1 to the rest of the path, that means DATA OUT is connected, right? Maybe something on the board of MATRIX 1 got shorted? Even though it's not exposed? Any pointers would be appreciated.
5 years ago
As the assembly notes above say, the strain relief pins on the pots are just slightly too big to fit into the holes in the PCB. It recommends folding them so they fit, but I was at a bit of a loss about how to do this at first, given that they're pretty small. Eventually I found an easy way: I took some wire cutters and made a small score down the middle of the pin (longwise, of course!), then just squeezed with a set of needlenose pliers. This allowed the pins to bend easily, and they fit well.
Reply 4 years ago
I trimmed the sides of mine with flush cutters, just enough to fit snugly into the holes.
Reply 5 years ago
Exactly what I did too.
Reply 5 years ago
Me too. Kind of a drudge but it all came out good enough.
4 years ago
I made a 3D printable case for the Jambox. You can find it here:
https://www.thingiverse.com/thing:3070124
Question 5 years ago
How do I change the frequency of the tones in the HB28Sequencer.ino sketch? The tones sound pretty monotonous. I tried changing the second arguments in the loadwavetable() function, thinking that might change the frequency of the tones. But no, the frequencies all seem to remain the same, only the timbre changes. It sounds like the only thing that's changing is the duty cycle of the same monotonous tone. Does anyone know how to modify the code so that it generates a set of distinct audio frequencies?????
Answer 4 years ago
Its not just you, I had the exact same problem. The sketch on the instructable that uses the external DAC has AFAICT a number of bugs. I rewrote it to fix those problems and published it here: https://github.com/sabeechen/FixedJamboxSequencer
Give it a try!
Reply 4 years ago
Thank you so much! Fantastic work! This is just exponentially better than the original sketch. From dud to delightful!
4 years ago
The code sample for the completed Jambox with external DAC in the last step (HB28Sequencer.ino) has a number of bugs that cause it to produced garbled audio. I rewrote it to fix the problems and published a working version on my Github page https://github.com/sabeechen/FixedJamboxSequencer
If you've gotten this far, I recommend giving it a try since its pretty fun to play with. I made it a priority to document how my rewrite works, so I'd expect it to be a lot more helpful from an educational standpoint and easier to hack apart for your own purposes.
If someone from hackerboxes is interested in fixing the instructable I documented what the problems were in my github's readme and you're welcome to use any part of it.
Reply 4 years ago
Very nice work, Stephen. Thank you! We edited step 7 to include a link to your improved example including attribution.
5 years ago
I've spent some time fixing the provided sequencer code, and I now have a (kind-of) nice step sequencer. Yes, it pops each column, but the code is documented enough now that you should be able to understand how it works.
https://github.com/toddkrein/HB28_Sequencer
5 years ago
Step 7 includes a second sequencer demo using the far simpler internal DAC (instead of the external IIS DAC). It also shows some improvements on the user control system including an "edit mode" when the sweep speed is on its lowest setting and another knob for moving the cursor around in edit mode.
Question 5 years ago
Anyone able to make this more of a sequencer/synthesizer? Hackerbox have any more code on this or any more teasers?
5 years ago
My ESP32 says it successfully uploads the new code, but will not change. It is stuck displaying the same thing no matter what I upload. I have triple checked every solder and it seems very clean. Any help would be greatly appreciated, I am stuck for now.
Reply 5 years ago
The console output:
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 5957.9 kbit/s)...
Hash of data verified.
Compressed 14128 bytes to 9196...
Writing at 0x00001000... (100 %)
Wrote 14128 bytes (9196 compressed) at 0x00001000 in 0.8 seconds (effective 139.0 kbit/s)...
Hash of data verified.
Compressed 168464 bytes to 87388...
Writing at 0x00010000... (16 %)
Writing at 0x00014000... (33 %)
Writing at 0x00018000... (50 %)
Writing at 0x0001c000... (66 %)
Writing at 0x00020000... (83 %)
Writing at 0x00024000... (100 %)
Wrote 168464 bytes (87388 compressed) at 0x00010000 in 7.7 seconds (effective 175.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds (effective 1445.7 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting...
Reply 5 years ago
Try pressing the boot button on your esp32 board?
Reply 5 years ago
Thanks for the response! I’ve done a number of these boxes and they usually work great, so I’ve tried ‘the usual’. This one is actually acting funky, it doesn’t respond to the reset or boot button at all, just persists with the same lights on. Is there some logic to the middle LED matrices showing that pattern?
Reply 5 years ago
Can anyone post what the default state of the board from first cold boot after successfully soldering everything? Are these lights on or is this possibly an indication there is a short somewhere?
Reply 5 years ago
Solved. Had a cold solder joint on a clock pin. Makes sense it would be something physical (solder) from the always on behavior. Thanks for the help!