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.
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.
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.
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 attached sketch for HB28Sequencer.ino uses the external DAC with minimalist user inputs.
The attached sketch for HB28InternalSeq.ino uses the internal DAC, which is far simpler. It also has some improved user control features, including cursor slider.
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...
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!
5 People Made This Project!
We have a be nice policy.
Please be positive and constructive.
FYI I used small files on the "...mechanical strain 'pins' on the five potentiometers...", as I couldn't get a pair of pliers make the taco shape...
Anyone able to make this more of a sequencer/synthesizer? Hackerbox have any more code on this or any more teasers?
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?????
:\Users\NEO\Documents\Arduino\libraries\esp32-led-matrix-master\esp32-led-matrix-master\examples\esp32spi\esp32spi.ino:2:23: fatal error: LedMatrix
Can you let me know what you figured out?
figured it out
Why would I not want to use the CJMCU PCM5102 I2S Digital-to-Analog Module?
So, I'm having a bit of trouble getting the ESP32 board to work. After several hours of fiddling with GIT, I finally got the Arduino client for windows to list esp32 boards as options. After that, any attempt to verify a sketch returns;
"C:\\Users\\(My User)\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++": file does not exist
looking at the directory
the file "xtensa-esp32-elf-g++" does in fact, exist, and even exists where the arduino client wants it to exist.
Error compiling for board ESP32 Dev Module.
did you run get.exe?
Platform and Arduino version?
I used the GUI git to gather the resources as you did.
I see a \\ vs my \.
Windows treats \\ as \ ( single backslash) However this IDE is using
Java based on Processing and other open-source software, so that could be an issue?
cross platform environments
The double \\ is for path strings within code, hence escape character from within strings.
I am using:
Windows 10 with 1.8.3 Arduino. along with the GIT 2.16.2 +GUI following the instruction, and leaving everything default.
Mine works .. here is a cut from the Arduino IDE console:
Build options changed, rebuilding all
Detecting libraries used...
"C:\Users\Mike\Documents\Arduino\hardware\espressif\esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM ... and so forth...