HackerBox 0070: Radio Over Internet

Introduction: HackerBox 0070: Radio Over Internet

With HackerBox 0070, we will configure a dual core ESP32 development kit supporting both Bluetooth and Wi-Fi communications. Work through the Bluetooth Capture the Flag challenge. Assemble the HackerBox Internet Radio Platform while exploring rotary encoder user input, infrared remote control, full-color LCD graphical user interfaces, audio decoder hardware, MicroSD memory card file storage, shared Serial Peripheral Interface (SPI) buses, and leveraging embedded web servers for application control and configuration. Uswksj Uahzwj Cryptanalysis.

HackerBoxes is the monthly subscription box for enthusiasts of electronics and computer technology - Hardware Hackers - The Dreamers of Dreams.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0070. The full box contents are listed on the product page for HackerBox 0070 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month with a $15 discount, you can subscribe at HackerBoxes.com and join the revolution!

A soldering iron, solder, and basic soldering tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Deluxe Starter Workshop for a set of basic tools and a wide array of introductory activities and experiments.

Most importantly, you will need a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

Step 1: Biohacking With Isochronic Tones

Enjoy this DEEP FOCUS house music mix while working on HackerBox 0070. The mix creator has embedded beta wave isochronic tones intended to induce a high-focus mental state for completing complex tasks. The session starts off beating at 10Hz and ramps up to 18Hz by the 6-minute mark. It stays at 18Hz until the final 5 minutes where it ramps back down again.

Isochronic tones are regular beats of a single tone that are used alongside monaural beats and binaural beats in the process called brainwave entrainment. At its simplest level, an isochronic tone is a tone that is being turned on and off rapidly. They create sharp, distinctive pulses of sound. (Wikipedia)

Step 2: ESP-WROOM-32 Development Kit and the 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.

There are several types of ESP32 Development Boards. The one used here is a variant of the "DOIT ESP32 DevKit". It is one of our favorites and has been widely tested in various maker/hacker applications. Most of the SoC's 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.

PROGRAMMING THE DEVELOPMENT BOARD

Make these initial tests of the ESP32 board BEFORE soldering to it or connecting to any of its pins. You'll only need a microUSB cable to interface the board to your computer.

If necessary, download the Arduino IDE software and set up the ESP32 support package in the Arduino IDE.

Under tools>board in the Arduino IDE, select the "DOIT ESP32 DEVKIT V1" which is the same board used in the link above.

As an initial test, you can try the WiFiScan sketch as shown in the link, or stick with the traditional LED "blink" sketch. Either way, make sure you can compile, flash, and run a sketch on the ESP32 before connecting the module to anything else.

TIMEOUT TROUBLESHOOTING

You may get a timeout error while attempting to program the ESP32 as if it just never makes a connection with your computer. This timeout problem can be mitigated as explained in the link above. On that page, scroll down to the "Troubleshooting" heading and read about how to use the BOOT and ENABLE buttons during the flashing process.

Step 3: Bluetooth Low Energy (BLE) Capture the Flag (CTF)

The BLE CTF is designed to teach the core concepts of Bluetooth Low Energy client and server interactions. While it is a lot of fun, it was primarily built with the intent to teach and reinforce core concepts that are needed to plunge into the world of Bluetooth hacking. After completing the CTF, you should have everything you need to start fiddling with any BLE GATT device you can find.

BLE CTF can run on the ESP-WROOM-32 Development Kit.

Spoiler Alert: BLE CTF Walkthrough

Next Level: BLE CTF Infinity - continuation of the original BLE CTF.

Step 4: Internet Radio

Like traditional broadcast radio stations, Internet radio offers news, sports, talk, and various genres of music. Many Internet radio services are associated with a corresponding traditional (terrestrial) radio station or radio network, although low start-up costs have allowed a substantial proliferation of independent Internet-only radio stations.

Streaming technology is used to distribute Internet radio, typically using a lossy audio codec. Streaming audio formats include MP3, Ogg Vorbis, Ogg Opus, Windows Media Audio, RealAudio, AAC and HE-AAC. Audio data is continuously transmitted serially (streamed) over the local network or internet in TCP or UDP packets, then reassembled at the receiver.

Popular examples of modern-day internet radio platforms and applications include TuneIn Radio, iHeartRadio, and Sirius XM. In the U.S., unlike over-the-air broadcast radio, an FCC license is not required to operate an Internet radio service. (Wikipedia)

Click here to sample over 22,000 Internet Radio Stations.

What is ROI? Silicon Valley: Radio On Internet (NSFW).

Step 5: Rotary Encoders

The exclusive HackerBox ROI (Radio Over Internet) platform starts with the supercool purple ROI PCB.

As a first step, populate only the ESP-WROOM-32 module and the Rotary Encoder

The Rotary Encoder is a position sensor used to determine the angular position of a rotating shaft. Sort of like a potentiometer, it makes for a nice control knob, but rotary encoders work in an entirely different way. This one is an EC11 Rotary Encoder with a Push-Button Switch. It's an incremental encoder, which means it reads changes in the angular displacement of the shaft instead of reading the absolute angle of the shaft.

The two output signals, A and B, are square waves that are generated when the encoder shaft rotates. The two square waves have a frequency indicating the speed of shaft rotation. The two waves are in quadrature with the phase relationship between them indicating the direction of shaft rotation.

Grab the sample sketch Rotary_Encoder_Demo.ino attached here. After loading the sketch to the board, use Tools > Serial Monitor (set to 9600 baud) to observe the sketch output. Rotate the encoder shaft and depress the shaft button.

The demo sketch is already hard-coded to the wiring of the ROI PCB with EncoderPinA, EncoderPinB, and SwitchPin assigned to I/O pins 25, 26, and 27 respectively. Note that all three pins are configured with pinMode parameter INPUT_PULLUP, which invokes pullup resisters internal to the ESP32 microcontroller. These are used instead of having to solder the three pullup resistor components on the PCB (just above the rotary encoder). As such, these three resistor components can be left unpopulated on the PCB as shown.

Step 6: Infrared Remote Control

Solder the three-pin VS1838B Infrared Receiver Module (datasheet) onto the ROI PCB as shown. The IR module can "stand up" facing the PCB edge or it can folded down against the PCB facing outward from the surface of the ROI PCB.

In the Arduino IDE, navigate to Tools > Manage Libraries to search and install the library IRremote by shirriff et al.

Grab the sketch IR_Demo.ino attached here. Open the sketch and note that I/O pin 35 is defined as the IR receive signal according to the connection on the ROI PCB. The command value decodes in the sketch correspond to the "Car MP3" infrared remote. Output from sketch is presented via the Serial Monitor at 9600 baud.

Step 7: Full Color 128x160 LCD Display

The LCD Display features 128 x 160 Full Color Pixels and it measures 1.8 inch on the diagonal. The ST7735S Driver Chip (datasheet) provides the interface from the ESP32 microcontroller using a Serial Peripheral Interface (SPI) bus.

Solder the LCD modules eight-pin header to the ROI PCB. Because the connection is only along one side of the module, it is helpful to pad the space between the LCD module and the ROI PCB with 2 or 3mm of cardboard and a bit of double-sided or rolled tape. This allows the LCD module to lie firmly parallel to the ROI PCB instead of sloping downward away from its eight-pin header.

The library called "Adafruit ST7735 and ST7789" can be found in the Arduino IDE using menu Tools > Manage Libraries. While installing, the library manager will suggest a few dependent libraries that go with that library. Allow it to install those as well.

Once that library is installed, open up Files > Examples > Adafruit ST7735 and ST7789 Library > graphicstest

The I/O pins defined within graphicstest have to be updated to match the wired connections within the ROI PCB.

Under the line:

#else // For the breakout board, you can use any 2 or 3 pins

change TFT_CS from 10 to 15

change TFT_RST from 9 to -1

change TFT_DC from 8 to 2

Under OPTION 1, Comment out the line:

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

Under OPTION 2,

Uncomment the line for TFT_MOSI and change the value from 11 to 23

Uncomment the line for TFT_SCLK and change the value from 13 to 18

Finally, uncomment the line:

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

Compile and upload graphicstest. This will produce a colorful graphics demo on the LCD display. You might notice some rows and columns of noisy pixels at the edge of the display. These noisy pixels can be fixed by changing the TFT init function used near the top of the setup(void) function.

Comment out the line of code :

tft.initR(INITR_BLACKTAB);

And uncomment the line a couple of lines down:

tft.initR(INITR_GREENTAB);

Reprogram the demo and the noisy pixels along the edges should be gone.

Step 8: Final Assembly of the HackerBox ROI Platform

There are now only two elements of the HackerBox ROI platform that remain to be installed...

MicoSD Card Module

For connecting the MicroSD module, the module must be oriented such that the GND pin is closest to the LCD display module. If the header pins are already soldered onto the MicroSD module, they are probably on the wrong side than what we would like. There are two ways to deal with this. The easiest option is to just mount the MicroSD module from the bottom of the ROI PCB. Note how that will position the GND pin next to the LCD. The trickier option is to unsolder the header pins from the MicroSD module and then resolder them onto the backside of the MicroSD module. Then, the module can be mounted onto the top of the ROI PCB (as shown) while still positioning the GND pin next to the LCD.

The MicroSD Card Module connects to the ESP32 using an SPI bus that is shared between the MicroSD, the LCD, and the VS1053. This bus uses ESP32 pins 18 for CLK, 19 for MISO, and 23 for MOSI. The chip select (CS) for the SD card is ESP32 pin 22. While the MicroSD card module appears to work 100% by itself, the shared bus can introduce some problems when the MicroSD card is used at the same time as the LCD display. Some reports imply that using a higher speed MicroSD card may mitigate these issues.

VS1053 MP3 Audio Decoder Module

The VS1053 chip (datasheet) is a monolithic MP3 / Ogg Vorbis / AAC / WMA / MIDI audio decoder based on a high performance, proprietary, low-power DSP processor core. Also integrated are working data memory, 16KB instruction RAM for user applications, and 0.5 KB of data RAM. With 8 available general-purpose IO ports and a serial port, the chip also comes with a variable sampling rate stereo ADC, a high-performance stereo DAC, and audio headphone amplifier.

The VS1053 audio module is soldered to the ROI PCB using the included 2x5 pin header. Because the header connection is in one corner of the module, it is helpful to pad the space between the module and the ROI PCB with 2 or 3mm of cardboard and a bit of double-sided or rolled tape. This allows the module to lie firmly parallel to the ROI PCB instead of sloping downward away from its header connection.

Step 9: ESP32-Radio

ESP32-Radio is an amazing Internet radio project based on the ESP32, VS1053, and an LCD screen. It can be compiled and installed through using the Arduino IDE.

Download the project from the repo linked above and start by flashing the project to the ROI platform using the ESP32-Radio.ino file which is an Arduino sketch wrapper for all of the actual project code. Also start digging into the main PDF documentation located in the doc folder.

In particular, note page 18 of the PDF document entitled Configuration. It explains how upon first launch, the ESP32-Radio code on the ESP32 is not connected to your network and the I/O pins are not defined correctly.

The ESP32 will default to acting as a Wi-Fi Access Point (AP) with the name “ESP32Radio”. You can connect to this AP from your PC using the password “ESP32Radio”. Once connected to the AP, browse to 192.168.4.1 to access the ESP32-Radio configuration screen.

From the configuration screen, various settings and preferences may be entered. The Wi-Fi SSID and password for your local network can be entered (usually near the bottom of the configuration) and the ESP32 I/O pins can be set corresponding to the wiring in the ROI PCB Schematic...

pin_enc_clk = 25                 # GPIO Pin number for rotary encoder "CLK"
pin_enc_dt = 26                  # GPIO Pin number for rotary encoder "DT"
pin_enc_sw = 27                  # GPIO Pin number for rotary encoder "SW"
pin_ir = 35                      # GPIO Pin number for IR receiver VS1838B
pin_sd_cs = 22                   # GPIO Pin number for SD card "CS"
pin_spi_miso = 19                # GPIO Pin number for SPI bus MISO
pin_spi_mosi = 23                # GPIO Pin number for SPI bus MOSI
pin_spi_sck = 18                 # GPIO Pin number for SPI bus clock
pin_tft_cs = 15                  # GPIO Pin number for TFT "CS"
pin_tft_dc = 2                   # GPIO Pin number for TFT "DC"
pin_vs_cs = 5                    # GPIO Pin number for VS1053 "CS"
pin_vs_dcs = 16                  # GPIO Pin number for VS1053 "DCS"
pin_vs_dreq = 4                  # GPIO Pin number for VS1053 "DREQ"

Once entered, the contents of this page must be stored into the ESP32-Radio Preferences by clicking the “Save” button. Changes will take effect upon the next restart of the ESP-Radio, so click the “Restart” button.

Step 10: Spork Multitool With Carabiner

We learned about this crazy spork survival multitool from renowned hardware hacker and engineer Joe Grand (Kingpin). Joe mentioned the spork as one of his favorite tools in an interview on the Cool Tools Podcast. We figured if this crazy spork is good enough for Joe, we needed to get one for every HackerBox member.

Step 11: Dwyg Pda Lhwjap

We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the revolution. Live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month. Surf over to HackerBoxes.com and sign up for your monthly HackerBox subscription.

7 People Made This Project!

Recommendations

  • Cheese Challenge

    Cheese Challenge
  • Back to School: Student Design Challenge

    Back to School: Student Design Challenge
  • Metal Contest

    Metal Contest

72 Comments

0
wjgeorge
wjgeorge

6 months ago

The SD card is not enabled by default in the ESP32 radio code. Seems to cause errors in initializing the VS1053 (floating CS pin?) when a card is loaded. The end result is no no sound.

Uncomment the #define SDCARD line in main.cpp

0
jstalin
jstalin

1 year ago

Everything appears to be working for me but I get no audio at all. Any suggestions?

EDIT: The problem was the ground on the VS1053 wasn't fully soldered. Now it seems to be working well.

0
larpyboy
larpyboy

Reply 7 months ago

I know it's late, but maybe it can help someone; for me, one of the other leads (not ground) between the VS1053 and the ESP-32 had no continuity; it was not soldering, it seemed like the trace on the PCB wasn't functional. I connected the pins with a short wire and everything works great now. Excellent box!

6
JimMcKeeth
JimMcKeeth

Tip 1 year ago

And the rotary encoder pins were wrong. This is the correct values:
pin_enc_clk = 26 # GPIO Pin number for rotary encoder "CLK"
pin_enc_dt = 25 # GPIO Pin number for rotary encoder "DT"
pin_enc_sw = 27 # GPIO Pin number for rotary encoder "SW"

0
buduz0r
buduz0r

Reply 7 months ago

Thanks Again!

0
d4e5
d4e5

Reply 9 months ago

Hi there, I have not been able to fix that... which file did you update?

6
JimMcKeeth
JimMcKeeth

Tip 1 year ago

If your screen isn't displaying right you might need to adjust the bluetft.h file:
tft->initR ( INITR_GREENTAB ) ; // Init TFT interface # Un-comment this line
//tft->initR ( INITR_BLACKTAB ) ; // Init TFT interface # comment this line

0
buduz0r
buduz0r

Reply 7 months ago

Thanks!

0
cbp2
cbp2

Reply 10 months ago

What do mean "isn't displaying right"? I'm finding that the screen is cut off at the edges. And looks like something's wrong at the bottom. Actually... now that I look at it... it looks like it's shifted up and left.

screen-cropped.jpg
0
LauraG
LauraG

Reply 11 months ago

How do I edit this bluetft.h file?

0
cbp2
cbp2

Reply 10 months ago

I assume he means alter the file ESP32-Radio/src/bluetft.h and then recompile and load.

0
StanMac
StanMac

Question 9 months ago

I got everything working but absolutely No Sound Any ideas?

0
AllihandraJ
AllihandraJ

Answer 8 months ago

Did you figure this out? I am running into the same issue.
EDIT: I didn't turn it up loud enough lol

0
lmperkins
lmperkins

Question 11 months ago on Step 9

Using the other hints in the comments I was able to successfully install the radio and it works fine. I'd like to go back to the setting page but can't figure out how to get there. Any help would be appreciated.

0
petronivs
petronivs

Answer 9 months ago

When it's booting up, it'll display its ip address. go to that ip address on the network it's connecting to, and you'll see the settings page.

0
JeffT130
JeffT130

Answer 10 months ago

When you downloaded the project with ESP32-Radio.ino in it, it also has a tools directory containing ESP32_radio_init.ino in it (it might be in a further ESP32_radio_init directory).

Open and build that ESP32_radio_init.ino sketch. When you upload that sketch to the ESP32, the SSID/Password (among other things) will be replaced. Upload the ESP32-Radio.ino sketch again. It won't be able to connect to a WiFi network and will create its own ESPRadio AP instead, at which point you should be back to where you started connecting to 192.168.4.1, etc.

The ESP32_radio_init.ino sketch has some default values in it; you could conceivably make your changes there instead of in the settings page.

0
autotech
autotech

9 months ago

My display seems to be stuck on "Starting...." after the initial boot.
It shows the isp address and other info, then clears and gives the starting prompt again, then just sits there.

0
lmperkins
lmperkins

11 months ago on Step 6

Kind of fun to watch the changes on the Serial Plotter as well.

0
tednunn
tednunn

Question 11 months ago on Step 9

I have compiled the Arduino code and can get to the configuration page @ 192.168.4.1, but I don't see where "The Wi-Fi SSID and password for your local network can be entered", so I keep getting "D: WiFi Failed!" in the serial monitor.

All I see on the configuration screen is the list of available networks at the top, along with the following in the window:
preset = 0
#
toneha = 0
tonehf = 0
tonela = 0
tonelf = 0
#
volume = 2

This is where I'm stuck. Can any of you intrepid souls provide some guidance to help with this?

0
mrc0de
mrc0de

Answer 11 months ago

This confused me as well, how to below:

1. Copy the config they gave us into clipboard.
2. At the config window, find the 'DEFAULT' button and hit that, this will populate all the options we were not seeing.
3. Nuke the default GPIO settings and replace with the ones we copied into clipboard from these instructions

tl:dr ---> just add a line: wifi_00 = ssid/Password and edit it to match your needs

I suspect this was intentionally not disclosed to force us to RTFM, which is where I found all this.