I created a PCB that controls Spotify playback using an ESP32 and a few Cherry MX switches.
Include a link to your demo video here
- Download Files: Download the
esp32gerber.zipfile from this repository. - Order PCB: Go to JLCPCB or any PCB manufacturer and use the following settings:
- Gerber file:
Gerber_ESP32-Spotify-Controller_PCB_ESP32-Spotify-_Y1 - Base Material: FR-4
- Layers: 2
- Dimension: 109 mm x 73 mm
- PCB Qty: 5
- PCB Color: Green
- Silkscreen: White
- Surface Finish: HASL (with lead)
- Gerber file:
Note: The minimum quantity might be 3 or 5 PCBs.
- Install Arduino IDE: Download and install the Arduino IDE.
- Configure Arduino IDE: Open the Boards Manager in Arduino IDE, search for
ESP32, and installesp32 by Espressif Systems. - Install Driver: Download and install the USB to UART Bridge VCP drivers.
-
Open Arduino IDE: Open the file in the repository named Code.ino
-
Save the file and we will come back to it later.
- Spotify Developer Dashboard: Go to the Spotify Developer Dashboard.
- Login or Sign Up: Log in or create an account.
- Create an App: Create a new app and set the redirect URI to
http://localhost:8888(we will change it later, so this doesn't matter for now). - Configure the Code: Put the client ID from the Spotify dashboard into the code near the top, named
client_id. Do the same with the client secret forclient_secret.
- Upload Code: Upload the code to the ESP32 (select
ESP32 Dev Moduleas the board). - Connect and Test: Connect your ESP32 and test the functionality.
- Connect to the Wi-Fi network named
ESP32_Spotify_Controlleron a device. - The password is
12345678. - Go to
192.168.1.2in your browser while being connected. - Enter your Wi-Fi credentials and submit.
- Switch back to your regular Wi-Fi on your device, then check the serial monitor in Arduino IDE. It should show the new IP address of the ESP32 (make sure to open the serial monitor beforehand).
- Go to that IP address and copy it.
- Go back to the Spotify dashboard, edit the app, and change the callback URL to
http://your_esp32_ip/callback. - Return to the ESP32 webpage on the IP address and press "Log in with Spotify". After you log in, it should be set up.
The only way to reset the network it's connected to is to reset the EEPROM. Do that at your own risk:
#include <EEPROM.h>
#define EEPROM_SIZE 512 // Adjust this value to the size of EEPROM you are using
void clearEEPROM() {
// Begin EEPROM with the size specified
EEPROM.begin(EEPROM_SIZE);
// Write 0 to each byte of the EEPROM
for (int i = 0; i < EEPROM_SIZE; i++) {
EEPROM.write(i, 0);
}
// Commit the changes to the EEPROM
EEPROM.commit();
// End the EEPROM to free resources
EEPROM.end();
}
void setup() {
Serial.begin(115200);
Serial.println("Clearing EEPROM...");
clearEEPROM();
Serial.println("EEPROM Cleared.");
}
void loop() {
// Your main code
}