Can anyone guide me on how to add a 3.5 mm audio jack to this so that the music could be played through wired headphones? A picture/diagram would be nice if possible.
I don't want to upset you, but TMRpcm.h nano library can only play very simple computer sound files, consisting of beeps of different duration and frequency. You don't need headphones to listen them.
Still no DAC (digital to analog converter) so no true-analog and the same low-quality sound. There are audio boards with an audio chip that includes a DAC and SD card slot, etc., and the Arduino simply acts as a controller. (There are limitations to these things too.... The Arduino can't read the files on the SD card, so it can' read the file names or metadata.)
You'll probably need a multimeter and a mating plug to figure-out the pinout. ...If you buy from a reputable supplier you'd get a link to the datasheet showing the pinout.
Here are the connections for the mating plug. (With the jack you have, you can't see the connections.)
Or, you can plug-in headphones and randomly connect a battery to figure what connections make a "click".
Since the player is mono you can connect left & right together.
You'll need a resistor in series. The "absolute maximum" current from an Arduino is 40mA. At 5V that works-out 125 Ohms (Ohms Law). That's the minimum load resistance. Headphone impedance varies but 30-60 Ohms is typical so a 120-Ohm (or more) resistor in series will keep it "safe". Two equal resistances/impedances in parallel are cut in half, so with 30-Ohm headphones and left & right connected together that's 15-Ohms.)
I think I have decided that I will take a different approach to my project, so I will not need to use an audio jack, but if anybody has an answer I'd still like to hear it
Another way is to use an arduino compatible board with a i2s digital audio output, such as an ESP32 or a w806. In this case, the arduino turns into a audio player - you can read sound files from the SD card and send them to an external audio amplifier via an i2s channel - I gave an example of such a project in the post #4