Close
0%
0%

NFC Bose Wave Player

An NFC-enabled music player designed for kids to be able to pick their songs, built the hardest way possible

Similar projects worth following
I wanted to create a music player for my son who loves music, but is only three and doesn't know how to pick his favorite songs. But he can pick vinyl records he likes because he knows the pictures - then it occurred to me that NFC cards with images would let him pick what he likes. Sure, I could build it with a few off-the-shelf components, but where's the fun in that...

After deciding I was actually going to do this, I had to select a radio that I could gut completely - I needed it to have enough space inside that I could fit all my new hardware and space for a display. I also wanted something with a few buttons so I could have volume control, programming new cards, etc. I also wanted something that wasn't too painful to my ears (I can't stand cheap radios). This is for my kids, so audiophile isn't required - but something that I can stand, at least.

Really, I just wanted something my kids can use that can take a bit of a beating, doesn't cost the earth, isn't painful to listen to and can fit everything inside.

  • A little hacking to get over the finish line

    gilphilbert09/24/2021 at 19:27 0 comments

    It's been a while since I posted, and a lot has changed. For one, I now have another kid who will play with this (in a few years...).

    As for the project, it's actually coming along nicely. I made those few final changes to the PCB design and ordered a final set of components. I wasn't really expecting it to be the last set (how many times have I said it would be?) but it seems like I'm finally there! I populated the new boards, flashed the firmware and now it works perfectly. Well, it did for about 10 seconds, before there was a nasty grating sound and playback stopped. I had to reset the ESP to get it working again - and then only 10 seconds. I thought it was a hardware problem, as it only appeared when the front panel connector was connected. So I replaced the connector, replaced the cable, I removed the screen and the NFC reader but it still would only play music intermittently. Everything else was working, it was so frustrating.

    I decided that perhaps it was my software - even though nothing had changed. So I basically rewrote the whole thing... but still the same issue. It just would not work and definitely not when assembled. Determination is a powerful thing. I rewrote the NFC reader library code but that didn't fix it either. I then decided to remove the NFC from the SPI bus and give it a dedicated I2C bus, but I really didn't want to change the PCBs. I worked out that I could break the existing PCB traces and use the existing chip select as SDA and borrow the DC pin from the display (changing it to 3-wire SPI) and make that SDC for the NFC reader. I swapped the library over to SPI and... it was better. Not great. Not right, but better. What on earth?!

    Finally, one sleepless night, I decided to replace the audio library I was using... and it worked. It was that simple. Somewhere along the way, the library became incompatible with the ESP33 arduino-core framework library. All that fiddling and hacking... but it works and I didn't have to make any more PCBs. The back of the front-panel PCB isn't very pretty (I'll post pictures later) but it's finally all working!

    I assembled the unit and gave it to my two older kids (3 and 1) and I'm overwhelmed by how much they love it. I've put their favorite songs on it and they're so happy! Even my 1 year old is happy to put the cards in front and dance to her favorite songs (although I am getting slightly bored of Baby Shark...). They use it pretty much every day - very rewarding after all the work. There's still a little software development to be done - but since I built in OTA updates, I don't need to disassemble it to carry on!

    I'll post some more pictures later and again when the software is really finished. My last job will be to expand the number of songs, it's amazing how quickly you get bored of listening to the same eight songs...

  • So very close

    gilphilbert08/06/2021 at 18:32 0 comments

    As you might have guessed from the title, I've run into a couple of small issues. Before we get into that, here's a photo of the device all buttoned up and ready to play music. The NFC reader is to the right of the display, simply hold one of the cards to that blank space and it plays the song:

    First, let's talk good stuff: the hardware works (albeit with a few gotchas, read on...) and the software is coming along nicely too. I've finally buttoned the whole thing up and actually used it, which is fairly nice to do at last! It can read/write NFC cards, play songs, set the volume, you can navigate the menu and there's OTA firmware updates. I'll upload a video once I've got some of the loud "clicks" fixed!

    I still have a decent list of features to implement (select a song to play from the menu, better volume control, maximum volume settings, password protection, etc.). I'm pretty pleased with what I've accomplished so far. But it's definitely not perfect...

    More Hardware, More Problems

    As the most ambitious project I've taken on, I knew I would run into some problems. I wasn't expecting so many to be honest, but hey, that's part of the learning process. "So, what's  wrong with it now?" , you ask? Well, here you go:

    • Amplifier Shutdown. It didn't occur to me that when the ESP is in deep sleep, it disables it's GPIO. This means that pins set high/low before sleep start to float - including the amplifier shutdown and DAC mute circuits. Floating pins on amplifier ICs are not a good idea and lead to very strange behavior, including clicking, hissing and more. I can work around this by using light sleep instead of deep sleep but introduces other software complexities as well as consuming more power when powered off. This can be fixed with a weak pull-down resistor.
    • DAC Mute. Other than the floating pin problem, the DAC is actually fairly "noisy" during start/stop of playback - especially when switching songs (possibly relate to the I2S library I'm using). The Soft Mute feature of the DAC is nice, but you have to work out how long it will take for mute/unmute to take place based on sample rates and more. The amplifier can do this for me for "free" (it's fixed at 100ms). I'll switch over to the amplifier mute, include a weak pull-up resistor and pull the DAC's XSMT pin high
    • It sounds terrible - and there's a few reasons for that. First, I really should have measured the speaker impedance values more carefully. The left speaker is a 4 Ohm woofer, the right speaker is an 8 Ohm "twiddler". That was fine for the old Class-AB amp but a Class-D needs output tuning for different output impedance - this means my identical output filters and BC blocking caps are all wrong. On top of that, I completely mixed the values for those parts, so my low frequency cutoff is around 120Hz for both sides. Correct value components won't fit in the old PCB so I'll need to change the PCB to make it fit

    While I'm at it, I'm also going to swap the amplifier for the more powerful TPA3123 (instead of the current TPA3122) which requires a different PCB layout. I really, really hope that this will be the last version I have to create!

  • Could It Be?

    gilphilbert08/01/2021 at 18:17 0 comments

    The latest boards turned up a couple of days ago - as always JLCPCB did a great job (and no, they're not paying me to say that). They're practically the same as the last revision, except for the 14 pin header that replaces the previous 12-pin header for the front-panel connector, after moving the NFC card reader from I2C to SPI. As part of the update boards, I designed a small logo to be embedded into the copper pour on the boards, which turned out even better than I had expected:

    But I'm sure you're not as interested in the aesthetics of my PCB design as much as whether they actually work. The parts were already here so I started populating the boards. Having an SMT stencil really makes things much easier. I already know the design works, so I populated all of the SMT parts rather than doing them a section at a time. When it came to the DAC I was crossing my fingers - this must be the sixth time this particular IC has been soldered! I powered it all up, employing my usual I-hope-this-doesn't-explode wince and it was uneventful. That's usually a good sign... I checked all the major voltages, then plugged an FTDI connector to the ESP's header - a serial connection showed all was fine. I uploaded a basic firmware package that simply plays all songs on the SD card and tried it out (using loose connections pressed to a headphone jack) - I got sound! So the main board seemed to be working just fine.

    Populated main board with the transformer in place for testing

    Next I populated the front panel board. I decided this was going to be it - this one was going to work - so I populated every component, including the irreplaceable eMQ connector that I had to remove from the original top panel. The depth between the front plastics and the PCB isn't huge - to fit the NFC reader and the display into the gap I'm having to use short header connections, Samtec's TLW and CES models. They save enough depth for the front plastics into place but, because they're shorter, the ATtiny must be soldered directly to the board as it sits behind the display.

    Populated front panel, notice the ATtiny poking out from under the display

    I uploaded updated development firmware for the project, switched the NFC reader to SPI, connected the front panel to the main board and powered up the unit. The screen lit up! Pressing buttons gave me output to the serial, so the button controller was working, and the NFC reader works! Now I just have to make a small cutout for the SD card in the original case so I can mount the PCBs back in again. I won't be closing it up any time soon - I need access to the serial port on the main board so I can upload new versions as I finish the development work on the firmware. That's probably the one hardware change I would make; I would have added a USB-to-serial chip (UART) to the main board with a USB port coming out next to the SD card slot. This would have allowed me to upload new firmware with just a USB port instead of needing access to the board to upload/test new firmware. I'll probably do something over WiFi, but that's a pain for development purposes.

    On the software side, there's still a long list of firmware features. I've been stalled on development as I couldn't get any further until the NFC reader and button controller were working together. I've also discovered a bug in the button controller firmware that I'll have to address where some buttons are issuing strange I2C messages, but the front panel board has a built-in ICSP connector so I can reprogram the ATtiny without needing to take the unit apart.

    Building this hardware has been challenging but fun - I'm really pleased it's working, but I'm a little sad it's finished! I'll get to work on the software parts and post an update soon. There's plenty of small stuff to get on with, but the major components are all there. I have a list of "advanced" features as long as my arm...

    Read more »

  • Woohoo! (and D'oh!)

    gilphilbert07/22/2021 at 06:20 0 comments

    It's been an eventful week on this project. Where do I begin?

    Buttons

    Well, this one is a positive one (I guess...). I discovered a couple of slight bugs in the button firmware that had me pulling my hair out for two days. Fortunately my hair is fairly short, so the damage is minimal. It turned out that depressing a button wasn't being debounced at all - and worse, the button being sent was out by one (so you would see the last button pressed - always lagging by one button). After virtually rewriting the code I discovered I'd made a couple of small errors - one in my firmware and one in the ESP code. Long story short, that's all fixed - so the good news is that I believe the button firmware is now complete!

    Hindsight Is A Beautiful Thing

    While waiting for the power supply components to arrive in the mail, I fitted the ATtiny with the button firmware into the front panel. No suspense here - it didn't work. Then I tried the NFC reader - and that didn't work either. After some investigation, one will work at a time - but not both together. Obviously I assumed my code was to blame, but apparently that's not it. For some reason, the PN532 and the ESP32 aren't best friends. The PN532 will not share the I2C bus with any other device when connected to an ESP32 - this seems to be a known issue across multiple drivers. I haven't dug into it (since it seems a little pointless to do so), but that's how it is. So, this means my new set of PCBs coming in the mail are already doomed - they're based on a shared I2C bus which is now dead in the water.

    Of course, if I had prototyped the whole thing together, this wouldn't have happened. Regardless, the PN532 does play nice on the SPI bus. Well, it didn't, but I made some changes to the driver to maintain SPI settings on a shared bus and now it works fine with the SD card and display on the same SPI bus. Now I will need to make a few changes as some SPI pins are missing on the connector between the main board and the front board - so both boards will need to be changed to swap from I2C to SPI.

    Sound from the DAC, at last!

    Let's silver-lining this thing then. Once the new boards arrived, even knowing they wouldn't be final, I soldered up the new boards. I was going to check every section of this before I order any more PCBs. I started with the DAC section, since I was waiting for the power supply components to arrive in the mail. This has caused me headaches previously so I thought I'd give it a go again - it would be much nicer to use my own PCM5102A design instead of an off-the-shelf component. After wiring everything to my previous prototype and powering it on... I got sound first time! This is great news.

    We Have Power

    That's right, the final set of components arrived in the mail today and I assembled my faulty board. Well, mostly, anyway. The power section, ESP32 and PCM5102A are all assembled. I fired it up, measured all the voltages and it looks great. This was true last time, yet the thing failed miserably, so I connected to the ESP32 and loaded some firmware to simply play all the songs from the SD card through the DAC. I powered it up, popped on my headphones and... silence. Oh, no - not again. Then I realized that the XSMT (soft mute) of the PCM5102A needs to be pulled high... just maybe. A quick firmware change and... nothing. But why isn't it working? I grabbed my multimeter. Amazingly, the pin on the ESP32 wasn't soldered - it was missing on this one pin! I soldered it quickly, plugged the cable into the wall... and nothing. Oh, come on! Then I realized: in my haste, I hadn't reconnected the other end of the power cable to the PCB. I plugged it in and... glorious sound! No static, nothing!

    Looks like I can order my final set of boards. Again...

  • Block Diagram

    gilphilbert07/19/2021 at 20:08 0 comments

    This project can sound pretty complex. There are a few major parts (the button controller, display, etc.) as well as the main MCU. To try and help visual-thinkers see what's going on, I've put this together quickly to give an overview of the project's main components as well as how they communicate:

    The colored interconnecting lines show the type of communication as well as the direction(s).

    The lines on the sides of the boxes show the power source. The 3.3V regulator pulls it's power from the 5V regulator. The amplifier uses an unregulated rectified power supply from the transformer. 

  • Buttons

    gilphilbert07/18/2021 at 08:08 0 comments

    Remember when I wrote about the buttons on the top panel? After some investigation, I discovered the buttons use a scan matrix - nothing particularly complicated. The columns require the addition of pull-up or pull-down resistors on each row that's scanned to prevent floating pins from reading false positives.

    After spending some hours with a multimeter and pressing buttons repeatedly (it was a fascinating evening) I've mapped all of the buttons in the matrix. There are now two options: buy and off-the-shelf matrix scanner, such as the TCA8418 or do it in software. The keyboard scanner ICs are often both (relatively) expensive and produced for industrial applications, so they come in home-assembly-unfriendly WQFN packages. Sure, I can probably solder one - but where's the fun in that? (you'll find this is a common theme in my projects...)

    There are two options: I could connect the lines directly to the ESP32 - but there aren't enough GPIOs left for that, or I could use another MCU. This isn't a complex task, so the code will be fairly simple. The most complicated bit will likely be the communication. I2C makes the most sense as it only requires two pins, and since the NFC card reader will be using I2C on the front panel as well, the connections will already be present.

    I've settled on the ATtiny series from Atmel. I've used them before and the work here is trivial, so the ATtiny series is ideal. Only a few devices come with enough GPIO pins and come in packages I want to work with, so I've settled with the x61 series. Most likely I'll use the 861 although it will probably be overkill, even if I used the Arduino framework (which I won't). The only hiccup is that the ATtiny x61 series doesn't support any I2C slave functionality, but there is an application note on how to achieve this.

    A few days later...

    Well, that was fun! I've re-written my code a few times, but I've got there. With the use of timers, interrupts and a few modifications to the usitwislave library, I have the whole thing working nicely on a proto board. I've written a fairly in-depth readme to go with the code so you can read more about how it all works. I've tested this with an ESP32 dev module as the I2C master and it works perfectly. I've made up the PCBs for the front panel, so now I just have to wire it up to the prototype main board and insert the ATTiny. I'll write more about the front panel board in my next post.

  • SMT isn't so hard, but little luck

    gilphilbert07/13/2021 at 20:29 0 comments

    The SMT work wasn't anywhere near as hard as I was expecting. Having the SMT stencil really helped as it put the correct amount of paste down and it really helped keeping the components in place as I put them on the board. I did have the hot air gun power up too hard at first and sprayed my components around a bit, but after I fixed that it went pretty well. I had a tiny amount of reflow - two resistors that were pretty close had joined at one end.

    I built the power sections first and measured everything. 4.98V and 3.3V on the nose, so all good. I soldered on the ESP32, switches and resistors and the SD card slot and flashed the MCU. A quick test showed that the SD card was behaving a little oddly, but nothing serious it was working - I was just getting some spurious errors. Nothing serious, so I decided to put that on my TODO list. I wish I hadn't...

    Next I soldered on the DAC stage. Again, this wasn't too bad - I had to remove a little extra  solder that was bridging two the IC pins but that was it. I powered it back up and connected it to the amplifier stage on my previous prototype as I hadn't built the amplifier stage yet. This was a smart move, as it turned out.

    What did I get? HISSSSSSSSSSSSSSSSSSSSSSSSSS. Not good. Not only that, but now the ESP's serial was behaving strangely with some garbage characters and I couldn't get the i2c communication to work at all. The display was working nicely though.

    I've spent hours fiddling with this new prototype. I removed and re-soldered the ESP32, even trying a different module in case I had burned out the first one by heating it for too long. I removed the PCM5102A and resoldered it, but still I was getting tons of static. I removed the ESP32 and tried using the board as a very large DAC module, but nothing. I swapped my 1K i2c pullup resistors for 4.3K in case they were too strong (with the FPC cable they shouldn't be...) and I swapped out the input capacitor for the 3.3V LDO in case that was an issue. Here's the board after all that work:

    In the end, I've come to a single conclusion: the power supply is causing issues. It's the single item that could cause such widespread issues.

    It's very frustrating and I can't really track down the issue as I don't have an oscilliscope. I may have to buy one to track down the issue. The documentation for the LMR14020 isn't wildly clear and while I'm no fool, I can't figure out some of their calculations which don't seem to add up.  Perhaps I'll try a different 5V switching regulator design. Back to the old prototype for now while I try to work out how to solve this issue.

  • A quick update on the prototype

    gilphilbert07/11/2021 at 06:08 0 comments

    This is my current prototype with all through hole components (except the ESP32-WROOM-32U which only comes in castellated form). This shows the PCB in the enclosure:

    You can see the larger heatsink (it says "PAT. PENDING" on top), the amplifier stage at the rear, the ESP32 at the front and the SD card reader on the right. At the front is header for the connection to the front panel. That thing hanging from wires is the DAC module - as the header is around the wrong way, I had to use dupont connectors to get it working. In this model, you can see the empty footprint where the DS logarithmic potentiometer was. I've removed it since I've discovered the ESP32 can control the gain of the DAC directly in software. It doesn't go super-quiet (think whisper quiet) but my kid will be rocking out to this, so that's OK for my purposes. I need to cut a chunk out of the battery bay so it will be possible to change the SD card without taking the lid off - simply removing the battery cover will provide access.

    This one shows the unit a little more assembled:

    The thing hanging off from the left is the PN532 NFC card reader. It's connected via I2C and uses interrupts. Hidden behind the OLED is an ATtiny 841 that powers the (currently missing) button pannel. I only have one connector for the button panel and I don't want to ruin it, so I won't solder it on until the top board is final. At this point, you can scan a card and it will play a song!

  • A new power section and DAC

    gilphilbert07/11/2021 at 05:51 0 comments

    I've been fiddling with my prototype - enabling the wifi on the ESP32 sends the temperature of the LM7805 through the roof, so it's fair to say that it's not going to cope - even with a better heatsink. Even if it could, the sheer power consumption is drawing too much power from the transformer which no doubt was never designed to provide this much power on the electronics line. Sadly, there's no way to find out what the rating for the transformer is. It's obviously more for the 12V line (since this was previously driving a 35W Class-AB amplifier) but the line for the electronics (which was powered at a surprising 20V, down to 12V via an LDO) isn't designed for what I'm drawing from it.

    The solution I can see is a switching regulator instead of a linear one. This will generate considerably less heat (potentially negligible) and put less strain on the transformer. In my hunt for a good switching regulator, I've tried to avoid the low frequency switching regs (~150kHz) and instead have settled on the LMR14020 - a 2A switching regulator at 1MHz. The components are pretty minimal so it shouldn't be hard to integrate... but it's SMT, not through-hole. My plan was to use through hole components for ease, but footprint (I have less space than expected) and component design has forced my hand. Once I've gone down this road, I may as well go all-in. I've swapped the 3.3V regulator from a through hole LM1117T to an SMT LM1117T-MPX and the associated components. I've also swapped the supporting components for the ESP over to SMT. To squeeze the TPA3122 into the smallest space, I've also swapped a few components over to SMT (just a few capacitors) but most of it is the same as before.

    Finally, I've taken a brave step. While I have a lot of experience soldering - even the odd bit of SMT, I've never dealt with anything tiny. I've ditched the large DAC module for a much smaller design of my own, leveraging the PCM5102A that I know works with the ESP32. It's a pretty tiny chip - SSOP - so that's going to be fun! Given all the SMT components, I've ordered an SMT template as well which should help putting down the solder paste. That's another first - so wish me luck!

    This is my next PCB design:

  • Well, I guess it kind of works

    gilphilbert07/07/2021 at 04:03 0 comments

    So good news, bad news and some more good news. Oh, then some more bad news.

    Good News

    I've populated the new board (good news) starting with the power components. One of the changes I made was to make space for a much larger heatsink for the LM7805 5V linear regulator - the input voltage is 12V from the transformer and it was getting very hot. A much larger heatsink is keeping the LDO cool enough to not constantly go into thermal shutdown, which is nice. However, I read the temperature with a IR thermometer - the heatsink is around 85 degrees (celcius) so the internal temperature must be through the roof - and while it's not in thermal shutdown, simply putting the lid on might make that happen. Nonetheless, I'm counting this as good news because otherwise I don't have much good news...

    That said, the new microSD card reading is working perfectly now that the power lines are wired correctly. I can now read files from the SD card - definitely good news.

    The Bad News

    I added some headers for the DAC and plugged it in, hoping for glorious sound from the little PCM5102A module I bought from eBay/Amazon (don't remember which). It has a headphone socket on it, so I don't need to populate the amplifier stage to hear audio. No sound. This is annoying. Then I noticed there's no red light on (indicates power) so went to investigate. The DAC has two rows of pins adjacent to one another. One side is just fine, one side is... well... backward - and there's absolutely nothing I can do about it. I've used dupont cables to plug the DAC module in, but that's definitely not a long term solution. Still, with the pins round the right way I can hear audio... woohoo! Now on with the amplifier.

    More Good News

    I had a couple of "hiccups" (including a short under the ESP32 that caused me some confusion when a simple pin state change took down the entire board by connecting GND and 3.3V. After I fixed that, I heard sound from the speakers! I was a little worried about the amplifier stage - I've never built one and my prototype didn't work - but it works perfectly! All I need to do is fix the header issue and it looks like the main board is done!

    Don't Get Your Hopes Up

    Fortunately (depending on how you look at these things) I decided to put the lid on the thing before I ordered the new PCBs with the corrected header. I'm so glad I did - the lid doesn't fit (not even a little bit). The underside of the lid which houses the speakers is a very odd shape underneath. There's a few things in the way (a bulk capacitor, both LDOs, the DAC) that stop the lid from fitting on. I thought I'd measured this... but apparently not. So now I need redesign the PCB to cram anything over 12mm into the top right corner and work out how to cool down that LM7085...

View all 17 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates