An IoT system that visualizes the current Spotify track on a physical LCD screen. It bridges the digital and physical worlds using Arduino and a background Python script.
The Challenge: Originally designed to utilize the official Spotify API. However, since Spotify for Developers temporarily disabled the creation of new apps (blocking access to OAuth credentials), a creative alternative was required.
The Solution:
I implemented a process monitoring technique on Windows (win32gui). The Python script:
- Scans the OS active windows.
- Detects the
Artist - Songpattern in the Spotify window title. - Cleans and formats the data.
- Transmits it via Serial to the microcontroller.
Result: A fully functional system that does not depend on external API keys or internet connection on the microcontroller side.
- Board: Arduino Uno.
- Display: LCD 1602 (with potentiometer for contrast).
- Languages: C++ (Arduino) and Python 3.x.
- Python Libraries:
pyserial,pywin32.
Configuration for the LiquidCrystal library:
| LCD Pin | Arduino Pin | Description |
|---|---|---|
| RS | 7 | Register Select |
| E | 8 | Enable |
| D4 | 9 | Data 4 |
| D5 | 10 | Data 5 |
| D6 | 11 | Data 6 |
| D7 | 12 | Data 7 |
| RW | GND | Write |
| V0 | Potentiometer | Contrast Adjustment |
Follow these steps strictly to avoid Serial Port conflicts.
- Open
Spotify_LCD.inoin Arduino IDE. - Connect your board via USB.
- Select the correct Board and Port.
- Click Upload.
Once uploaded, COMPLETELY CLOSE THE ARDUINO IDE.
If you leave the IDE (or Serial Monitor) open, Python won't be able to access the USB port, triggering an
Access Deniederror.
Open a terminal (CMD or PowerShell) in the project folder and install dependencies:
pip install -r requirements.txtOpen spotify_lcd.py with a text editor (or VS Code) and verify the port line:
SERIAL_PORT = 'COM3' # <--- Make sure this matches your Arduino port- Open the Spotify desktop app and play some music.
- In your terminal, run the script:
python spotify_lcd.py- If successful, you'll see: "Connected to COM3. Waiting for music..." and your LCD will display the track.
Access is deniedError: You didn't close the Arduino IDE! Close it and run the Python script again.- White squares on LCD: Adjust the potentiometer on the back or breadboard to fix the contrast.
- Song not detected: Ensure you are using the Spotify Desktop App (not the web player) and that it's not minimized to the system tray.
Project developed by franlrs. Distributed under the MIT License.
