HackerBox 0028: JamBox

Published

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.

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...

Simple Synthesizer

ESP32 Soundboard

The Arduino synth page

Codeduino Grid Step Sequencer

ESP32 Web Radio

Arduino Step Sequencer

Auduino sound synthesizer

Groovesizer Sequencer

Arduino MIDI

General background on making sounds

Notes and Volts

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!

Recommendations

  • Oil Contest

    Oil Contest
  • Clocks Contest

    Clocks Contest
  • Planter Challenge

    Planter Challenge
user

We have a be nice policy.
Please be positive and constructive.

Tips

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...

5 Questions

0

Anyone able to make this more of a sequencer/synthesizer? Hackerbox have any more code on this or any more teasers?

1

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

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

"C:\\Users\\(My User)\\Documents\\Arduino\\hardware\\espressif\\esp32/tools/xtensa-esp32-elf/bin/"

the file "xtensa-esp32-elf-g++" does in fact, exist, and even exists where the arduino client wants it to exist.

suggestions?

Error compiling for board ESP32 Dev Module.

0

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...

38 Comments

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

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.

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.

photo5001380736795781108.jpgphoto5001380736795781109.jpgphoto5001380736795781110.jpgSuccess_writing.PNG
5 replies

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...

Try pressing the boot button on your esp32 board?

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?

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?

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!

The super simple sketch internalDACsimple.ino (see Step 5) shows how to "play" waveform samples via the internal DAC. This is a bit more straightforward than I2S comms to the external DAC. The tradeoff is that you have to carefully tend to your own timing.

The Grid Step Sequencer demo doesn't seem to do much. A few limited tones and that's it. looking at the code it seems like something is missing. What about the wavetables? Are there wavetable data files that are missing from the linked code???

How would you go about adding wavetable data files?

I don't know. It may be that my understanding is too limited. My idea of a wavetable is that there would be an array of digital data used to define a waveform that the DAC would convert into an analog signal. Maybe be wavetables come already built into the ESP32 firmware? Or maybe there should have been a file appended to the Arduino code that contains the wavetable data but it was inadvertently omitted? Or maybe the whole thing is working exactly as intended and I just need to tweak the code until it's the way I like it.

i keep getting this error when trying to compile the HB28Sequencer.ino.

error:

In file included from C:\Users\[Username]\Documents\Arduino\libraries\LEDMatrixDriver\src\LEDMatrixDriver.cpp:8:0:

C:\Users\[Username]\Documents\Arduino\libraries\LEDMatrixDriver\src\LEDMatrixDriver.hpp: In member function 'void LEDMatrixDriver::clear()':

C:\Users\[Username]\Documents\Arduino\libraries\LEDMatrixDriver\src\LEDMatrixDriver.hpp:58:43: error: 'memset' was not declared in this scope

void clear() {memset(frameBuffer, 0, 8*N);}

^

exit status 1

Error compiling for board Hornbill ESP32 Dev.

i tired different board types but none seem to work. The ESP32 Dev worked with the IOdemo

I have been getting this error while trying to upload the demo code to the board. Any help would be helpful! Not sure if I installed the ESP32 drivers wrong or what but I haven't been able to upload any other code to the board as well.

Esp32.png
1 reply

not sure why the screenshot came out like that but the error is:

D:\Arthur\Documents\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-uart.c:16:1: error: missing terminating ' character

exit status 1

Error compiling for board ESP32 Dev Module.

So I have been getting brownout issues and haven't got it to work yet. Busted out the trusty multimeter and the first (far right) headers seems to have 5v and gnd swapped. If I connect the maxim breakout board, my 3.3 out drops to -1.x and the LED goes to 25% or so strength. I checked all my solder points and they look ok. Any ideas?

1 reply

Just an observation and suggestion, this pcb uses thru hole plating with solder pads on both sides of the circuit board (two sided soldering). Make sure your solder makes a good bond on both sides. Being certain that the solder with resin flows thru to both sides. I see a log of comments on flaky operation here where the soldering may not have been hot enough and causing a "cold solder joint". Here's a good tutorial with pictures. That should eliminate a lot of problems.

https://learn.adafruit.com/adafruit-guide-excellent-soldering/common-problems