1 post tagged

raspberry pi

diPlayer

diPlayer assembly

This is a desktop player for DI.FM that I made for the 20-year anniversary.

I gathered a lof of experience during this proejct:

  • learned how to solder (again)
  • familliarised myself with Python
  • wrote and debugged firmware for an Arduino Nano
  • learned to model in Fusion 360
  • found out that 3-d printing don’t happen right on the first time

Details

Desktop player based on Raspberry Pi, that can play DI.FM channels (IceCast streams to be exact).

It is controlled with photoslides frames that have NFC-stickers on them, the stickers point to certain channels.

The player can also play other sources like Spotify, Google Play Music, Soma.fm thanks to MusicBox software.

It has a physical Play/Pause button, volume knob and a small screen that displays current track. Sound output is through audiojack or HDMI (Raspberry Pi standard).

Inspiration

Last year I saw these tweets:

And some comments had a link to the PlasticPlayer project.

It’s a small device based on Espruino with NFC-sensor and a screen. Upon detecting NFC-chip it gets its reference track from the database and sends the link to it to the Raspberry Pi that sits on the same network.

The author, Brendan Dawes, released all the source code and models for 3-d printing on Github, which helped me a lot.

My Attempt

I started to work on the project in June 2019.

It was around the time I just received a couple fresh ESP32 from China. I did reflashed one of them with Espruino, but even simplified code from the Brendan’s repo didn’t run.

Also I didn’t like that in such a simple project there will be two separate wi-fi connected devices, and I deemed suboptimal Arduino getting track data from the remote server in the face of Raspberry Pi power and possibilities.

So I rewrote and remodeled everything from scratch.

I just forked the repo and dove into unraveling all the upcoming issues.

Mistakes and Experience

On the breadboard

NFC PN532

This is a very popular Arduino NFC-module. It took me only one a half months of unstable work (!) for me to read to the original manual.

One of the keys issues here was that the wire management – the wires should go under the antenna turning in 90°.

The wires should go under the antenna turning in 90°

NFC-module is very susceptible to electromagnetic noise from other devices and wires.

Encoder

I also decided to replace the “Next Track” button with the volume knob.

On the first iteration I tried to use encoder with Arduino.

Encoder is a knob you must be familiar with from a wide range of electronics. It uses two rings inside and a cursor to determine if it goes forward or backward.

On a separate breadboard and an Arduino with only the encoder connected everything worked smoothly.

But whenever I tried to use it with my main board, together with NFC-module, screen and a couple of buttons, the volume was unstable at all, and I couldn’t use it.

I couldn’t discover why it happened. Maybe it was due to some regular voltage spikes that I could measure. Some tutorials stated that encoder needed hardware interruptions to work, and so maybe I used the wrong Arduino pins.

After some struggling, I almost gave up on the project and decided to try potentiometer.

Potentiometer

It’s a more traditional knob, based on the resistance change inside itself.

It didn’t come out easily as well. Looked like the NFC-module emitted a lot of noise, and potentiometer readings bounced by 10% either side all the time. 10% is quite a span, which is to easy to smooth out.

At some point, I got an advice on an Arduino forum, to connect the potentiometer physically closer to the power source. It did help, just until the final assembly.

Case

In the original Brendan’s repo (above) there is a case 3-d model. But it appeared I need more height due to the fact that I wanted to squeeze both Raspberry and Arduino inside, and also I wanted a different type of wiring on the back side.

I tried to model it at first in Blender – from my knowledge it was a popular program to make Counter-Strike skins 15 years ago.

I did a case model from scratch using the relative units. In a day the printing guys sent me a picture of a bottom lid with the Raspberry mounting holes spaced apart too much. They suggested me redoing the model in Fusion 360.

I never tried parametric modeling before and it worked like a charm. Fusion is an awesome and fast peace of software, and it took me only a complete Sunday to learn the program and model the case with exact measurements.

This time printing went smoothly in terms of dimensions. However the surface quality appeared to be poor in some places, and I couldn’t fix it afterwards.

The case before painting

I tried to sand it and apply different Dremmel rigs, but it didn’t really help. In the end I coated it multiple times with acrylic paint which made it look a little better.

Final Assembly

I had only two weeks left to the deadline (a trip to Croatia to meet my colleagues), so I was calm thinking that I have a lot of time.

By this time I got desperate a couple of times and was close to abandoning the project due to unexpected issues. Now, remembering those moments, I can’t understand why it scared me that much. My wife really helped in those moments, encouraging me to continue.

One of the first surprises was the fact that the USB-cable that I used to connect Raspberry Pi and Arduino did not fit into the case. So I soldered a shorter version of USB-A — mini-USB.

Soldering mini-USB plug

Then I soldered all the components and headers onto the circuit board, and potentiometer started to report incorrect readings again. I got some more advices on the forum, tried to put a capacitor.

In the end I replaced the potentiometer with the encoder, but this time plugged it into the Raspberry Pi. I added another small class to read the encoder readings in my Python program and it was good.

One of the iterations of my expansion boards for Raspberry Pi
One of the iterations of my expansion boards for Raspberry Pi

It was only three days before the flight, and I had more plans for the firmware updates, Raspberry Pi suddenly stopped working.

It looked very strange – I could connect via ssh, but the Musicbox web-interface was not available. The solution was too straightforward – reinstalling Raspberry Pi. Later I discovered the sd-card got corrupted due to multiple hard power-offs.

At some point it all worked together, but I didn’t have any emotions left to rejoice.

It took me about two months of almost every evening (after my main work), which came with some exhaustion.

Final layout of the player

I still did some programming right until the flight, and also had to make Python program autostart when I was in Croatia.

Cutting the NFC-cards covers, night of the flight

Presentation

Ari, Andrew, me, Mich

It was a good one, despite the device looks.

Links

P.S. Want to say thanks to my wife who cheered me up many times during this project, helping me to go forward. Thank you 😘

P.S.S. I had a couple people asking me when I’m going to make the ones for sale and I started thinking about it. Let me know using this form if you are interested.

Originally published in my older blog in Russian in October 2019.

 No comments    6   6 d   arduino   DI.FM   hardware   projects   raspberry pi