How to use Spotify API on ESP32 with NFC Reader to control Echo Dot
HTML-код
- Опубликовано: 7 авг 2024
- Learn how to program an ESP32 microcontroller to read a Spotify Playlist link form an NFC tag and make Spotify play that playlist on an Amazon Echo Dot.
Source Code on GitHub: github.com/makeratplay/esp32S...
Other Videos:
• How to Build a Retro C...
• Magical Alexa-Spotify-...
• How to Authenticate an...
Parts:
esp32: amzn.to/37c61mM
NFC reader: amzn.to/3d8m6xy
NFC tags: amzn.to/3tXHBa7
00:00 intro
00:08 the project
00:47 use visual studio code
01:30 project hardware
02:45 code time
03:32 setup()
04:37 fun fact 1
05:04 loop()
05:14 read NFC tag
06:01 parse NFC data
06:53 now call play on Spotify
07:54 fun fact 2
08:36 deep dive on Spotify API
09:49 fun fact 3
10:34 down load ssl certificate
11:55 back to the code
12:47 fetch access token
13:34 play API
15:04 fun fact 4
16:19 get Spotify devices API
16:30 janky sh!t
17:12 wrap up
18:01 ask me for help
This is my second RUclips Channel where I focus on software development. My other channel 'Maker At Play' is where i share my maker projects related to woodworking and electronics. / makeratplay
Want to support my Diet Dr Pepper addiction?
/ makeratplay
buymeacoffee.com/makeratplay
Follow:
/ makeratplay
/ makeratplay
/ makeratplay1
You can find me here as well:
makeratplay.com/
/ hawkinsmlh
about.me/michaelhawkins/
Tools used to make my videos:
Video Editor Software: Davinci Resolve
Camera Samsung Galaxy S8 Phone & Canon EOS M50
Mic: Rode Videomic Shotgun microphone with Rycote Lyre Suspension
If you appreciate this content and would like to help give back FREE OF CHARGE, simply give this video a “thumbs up”, leave a positive comment, subscribe to my RUclips channel and share this video with someone who you think would enjoy it. Some of the links that I’ve provided are affiliate links. That means that when you make purchases through those links, I earn a small commission. I only list products or services that I believe in.
#arduino #esp32 #spotify Наука
love your work!!! :p
Thanks
This is so much useful, thanks you so much, i was building something like this and this video help me with that http client bug LOL
Glad it helped!
Hey mate, love your work. I'm building a similar device for which I've written the code. The only part I haven't written is the Spotify API library. I'm encountering an issue: on the first boot, I need to have Alexa already playing, otherwise the device ID becomes outdated. I'm also using the device name; I get the player details and then grab the device ID based on the specified device name. However, this doesn't seem to work unless Alexa is playing first. After that initial step, I have no more issues. I can play on my phone and then hit play on my little device, and it will transfer and work fully as intended. It's just that initial boot that's problematic.
Great, thanks for the thorough walkthrough. I'm just working on the same idea but for Raspberry Pi and I have a ESP32 on the way to try out your project. To get the "Next song" feature working might be tricky... I guess you need code that checks if the RFID tag is continuously read (which means ignore these calls). If it stops being read for a certain interval, we can read it as a new tag. Just in general, is everything else still working for you or did the API change?
You are incredible
Thanks for the kind words.
Freakin awesome.😀
Thanks
I like this man
Thanks
This is awesome. I knew I kept all my records, cassettes, and cd's for a reason. Ordered the parts and got the info needed from spotify. New to Visual Studio Code, how do I flash the code to the ESP32?
Glad it inspired you to build your own. Share your results. Would love to see how it turned out.
That's awesome. Thanks a lot for you sharing it.
just to ask, is there a reason to use vs code/arduino-cli and not vs code/platformIO?
Keep up the great work!
They all achieve the same end goal of putting a program on your microcontroller. They each just offer different helping tools to get you there. I like VS Code because I use it to program for other platforms as well like windows, web, AWS. I don't have to learn a new IDE/Tool set each time I switch target platforms.
I have two questions. 1. How to write the links on rfid cards.
2. My serial monitor only shows nfc card present. Nothing else is happening. What am I doing wrong?
i am getting a return 400 and return 403 on the spotify nfc project. what do i set for redirect upi's?
Did you create yourself an app in the Spotify Dashboard? For the code ESP32 it doesn't matter what the redirect url is as long as you use the same when in the api calls that you used when you created the app in the Spotify Dashboard.
do the code to which it redirects one after providing redirect_url and clientId and the refresh token expire? I got my redirect token using Spotifys own example in GitHub aß well as your application from the other video but i cant get it to work. it always says "failed to connect to..."
Yes the code / auth token you get from Spotify does expire every 60 minutes or so. That is why you have to use the refresh token to get a new token when it does expire.
You are not implementing Auth 2.0 in your code?
do you have a video creating projects and importing libraries like wifi.h into visual studio code?
I have not created a video on that topic. I assume it is something you are interested in. Exactly what are you wanting to understand?
@@makeratplaycoding2666 I'm new in vs code and Arduino, I would like to know how to import libraries and send code to esp32, I have very little time working with esp and the Arduino app
Hi! Thanks for the code, i watched the video but probably didnt understand how to deal with the deviceName. Can you help me?
In my example I had to use the device_id query parameter to ensure that Spotify played the music on the echo dot I wanted since I have multiply devices connected to my Spotify account. I believe you can make the API calls without the device Id and Spotify will just default to the last device that was playing Spotify music. If you give me a more detailed question, I might be able to help.
How do you program esp32 with VS Code. Isn't the Arduino IDE the only which is supported?
You can use VS Code, but it still requires the Arduino tools to be installed. I enjoy it a lot more than using the Arduino IDE. Here is a link to how to setup VS Code for Arduino learn.sparkfun.com/tutorials/efficient-arduino-programming-with-arduino-cli-and-visual-studio-code There are lots other help on the web too if you search for 'use visual studio code for Arduino'
@@makeratplaycoding2666 Thanks :)
Could you give us a hint on how to write the spotify link onto the NFC tags. I'm currently using an app on my Android but it seems to corrupt my card
I created a TikTok video on this topic. www.tiktok.com/@makeratplay/video/6926358046079716613?sender_device=mobile&sender_web_id=6934138888244823558&is_from_webapp=v1&is_copy_url=0
@@makeratplaycoding2666 I followed exactly the steps on the TikTok but once I write the Spotify link my whole nfc card becomes unreadable. It gives this error on each sector: PCD_Authenticate() failed: Timeout in communication
hey actually my cards were defective managed to grab new ones
Did someone get it up and running? I tried it with an ESP8266 i had lying around. I have no experience with programming an ESP.
However, my approach seems to be correct. First I downloaded Arduino IDE, adjusted the Seetings.h file with my values and loaded the board software of an ESP2866 into IDE. Then I added the .ino file and in the Library Management I added the WiFi.h and the rest of the .h files from the folder. Unfortunately, I get a error message in IDE afterwards
EDIT: I did not connect the RFID Reader. Could this be a part of the problem
C:\Users\Rob\Desktop\esp32SpotifyEchoDot-main\esp32SpotifyEchoDot\esp32SpotifyEchoDot.ino: In function 'bool readNFCTagData(byte*)':
C:\Users\Rob\Desktop\esp32SpotifyEchoDot-main\esp32SpotifyEchoDot\esp32SpotifyEchoDot.ino:143:1: error: no return statement in function returning non-void [-Werror=return-type]
143 | }
| ^
cc1plus.exe: some warnings being treated as errors
exit status 1
Compilation error: no return statement in function returning non-void [-Werror=return-type]
Is the ESP2866 perhaps to small and out of memory?
bad boy ahhaha :)
I am going to take that as a compliment. 😀
can I use an ESP8266 for this project?
You should be able too as long as you have enough IO Pins.
All your talk of nerds using a "real IDE like VS Code", and not one person has dropped an elitist, snide comment about VIM? *sigh*.
"Pfft. VS Code is a REAL nerd IDE? I only use VIM, because a GUI that makes sense with a mouse to click on stuff is for LOSERS".
Now your comment section is complete...and I hate myself a little...
Yes, I agree VIM takes you to a higher level of nerdism. 😂
me >:)
Use your new knowledge wisely. 😁
amazing work!!!
but i keep getting "abort() was called at PC 0x40154642 on core 1" after getting the deviceID. can you offer some advice thank you