• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

My first PCB - a micro streamer - advice welcome

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Hi all, I am in the process of drafting and ordering my first PCB ever, and thought i would post it here for suggestions or important deficiencies before sending out to print in China.

This is a project I make for fun. I came across recently of that very cool project squeezelite-ESP32 that shows you how to build a squeezelite streamer around a ESP32 microcontroller.


These things are tiny and i find fascinating that with one of them and a couple of cables you can build a fully working wifi and bluetooth streamer for less than 6 euros!

1675517597982.png

A raspberry pi zero looks gigantic besides this.

By coincidence, i am in the need of a streamer with a toslink output and i thought that for the money a spdif hat for my raspberry pi costs, i can build a squeezelite-ESP32 with toslink output and have a beer with the rest. And it works! I have it working attached to the programmer board that i got for it. As you can see, you just need to attach a toslink emitter to the power, ground and a gpio pin and you are in business! I still can't believe it.

1675517849273.png


Well what i need now is to have it working stand alone, without having to plug it to the programmer board. To achieve this, i want to make a small PCB with a voltage regulator based on AMS1117 (5V from a usb charger to 3.3V) and the possibility to add the toslink emitter and a spdif coax output. For the coax, it is necessary to bring down the voltage of the GPIO from 3.3 to 0.6V (as explained in the project github). I have not tried coax myself yet.
The PCB must fulfill the following:
1. that it is as small as possible, so i can glue the streamer to the back of the dac. My current draft is 18x65 mm.
2. the most important and difficult: That i can still insert the ESP32 in the programmer after soldering it to the PCB in case i need to flash it again.
3. versatile enough that i can build toslink and/or coax, that i can power it with 5V or leave the voltage regulator unpopulated and feed 3.3V directly
4. I also added 6 header pins to be able to use the two i2s ports that the ESP32 has (not necessary for the squeezeplayer project though)

What i think is the trickiest part is to be able to insert it in the programmer again. The programmer has "spring" pins that fit the two castellated sides of the ESP32. The only solution i can think of is making the pcb as thin as possible and 1 mm narrower than the ESP32 (that is, 17 mm wide instead of 18 mm). The problem in this case is how to solder it. I thought if i leave some holes coincident with some of the pads of the microcontroller, i can solder through the hole. I have no idea how this is going to work and that's why i am posting this here. Another option would be to be able to extract the module, but i cannot think how without making the pcb too big...

Other features are a header pin under the AMS1117 in case i need to skip it and use 3.3V source (i.e. a raspberry pi) and two header pins under the USB connector in the probable case that i don't manage to solder it (it is tiny) and i opt to just solder two cables or two header pin connectors. I left pin 1 disconnected not to short 5V to ground if i finally add the USB connector. i will solder the small bridge only if i use the header pins instead of the connector.

Well, long story short, this is the first time i use kicad, i had no clue of what a voltage regulator or a voltage divider was until this week, and the attached is where i am. Any advice is welcome. Note that i will only use 100 ohm resistors, i don't have other values.

These are the two very simple circuits on the board:
5V to 3.3V:

Voltage-Regulator-Circuit-5V-to-3.3V.png

Somewhere i read that the ams1117 is more stable using 22uF condensers, but that goes far beyond my understanding, so i will give it a try with what i have (10uF) unless someone tells me i must use more than that... Could i use 2x10uF in parallel??

spdif coax connector:

100nF
GPIO ----210ohm-----------||---- coax S/PDIF signal out
|
110ohm
|
Ground -------------------------- coax signal ground
 

Attachments

  • streamer.zip
    23.2 KB · Views: 81
Last edited:
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Decided to mount and test the circuit without pcb (yes, soldering smd components to free standing cables, never thought i would manage) and after a lot of troubleshooting i realized i missed a part that is shown in the datasheet of the programmer. The enable pin must be connected to power with a 10K resistor and to ground with a 0.1uF capacitor.

I don't understand what that does, but without it, it doesn't boot.

1675614917000.png


Fixed now and working, but must add that to the PCB draft.

I find surprising that this detail is not mention anyware i could find in the internet, i thought these modules were super popular in DIY circles....
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
And the PCBs arrived!

1677327363205.png


I eventually ordered one partially assembled (it adds very little to the cost and i was afraid of soldering the small SMD). That is the big one, it can output both toslink and coax and has a voltage converter to plug to a USB charger. I also added a few pads for programming and potential i2s inputs and outputs in the future. The medium is only coax and keeps the 5V to 3.3V circuit and the smallest one is toslink only and 3.3V only.

The picture does not really show it but they are super small:

1677328023419.png


Yes, it is one cent, not one euro :D

It took me like 20 min to add the ESP32 module and the toslink emitter to one of the partially assembled ones. It was easier than i thought. castellated edges are very noob friendly (first IC that i solder ever):

1677327045254.png


Plugged it, and in a couple of seconds (this is the magic of microcontrollers vs computers) it was working!!!

1677326820172.png


I can't believe it guys, what a time to be a tinkerer...

There are, however, a few learnings and things that i would do differently today, and the first one is already evident in the last picture. That led is way too bright. The good thing is that this particular one is aimed to be used in the summer outside, so not a big deal...
 

Marc v E

Major Contributor
Joined
Mar 9, 2021
Messages
1,106
Likes
1,607
Location
The Netherlands (Holland)
Maybe this is a great time for hifi tinkering again. This time not in cables, amps or speakers, but more on the streamer and dsp side, everything that relies on software.
 
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Maybe this is a great time for hifi tinkering again. This time not in cables, amps or speakers, but more on the streamer and dsp side, everything that relies on software.
Agree. And i wish i had the base knowledge to understand stuff faster and not to have to spend 2 hours dissecting a voltage divider or reading the datasheet of a transistor because the one in the tutorial is not available.... but i guess there is where part of the fun is...

It is truly amazing the kind of things you can make with a bit of reading, patience, and asking around. Next project: an automatic i2s/spdif source selector hat for raspberry pi. wish me good luck :D
 
Last edited:
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
KiCAD gets pretty addictive, and i could not help but starting my second PCB project....

My audio system is built around a raspberry pi 4b running camilladsp. Nowadays i do the actual DSP in a minidsp 2x4HD running Dirac Live, but still use the pi as streamer/hub/volume/tone control etc. It looks more or less like this:

TV/HDMI extractor/other sources -> toslink switch -> minidsp 2x4HD -> raspberry pi -> DAC -> amp

Over time, i have been adding switches so that all the devices turn on and off pressing one remote control button, displays, etc, and even though everything is hidden in a cabinet, every time i open it, someone starts rising questions about "all those cables.... is this safe..." :rolleyes:...
So i have decided to bring all these additional circuits to one PCB together with the pi. And this is the result so far:

PCB project.jpg

PCB project 2.jpg


The pi is going to be upside down with the header plugged to a female header. I need to cut the PCB because the USB ports of the pi are taller and would not fit otherwise. There will be a duplicate of the 40 pin header so that i can test other stuff without needing to take it apart.

A raspberry pi pico W controls the on/off of the system shorting the necessary gpio pins of the pi to ground via optocoupler switches (on the contrary to the rest of the devices, the pico will be on 24/7).

bottom left there are mosfets that will power/unpower the external cards that have their own DC power (the minidsp and a motu ultralite mk5). There is a lot of space left besides that because i dont know yet if i am going to use the mosfet with the Motu. I want to make sure first with their customer support that i am not going to damage it.

To the top, besides the fan, is the most interesting part, and the only one that i have not tested yet: is is a small i2s to spdif plus spdif selector based on a wm8805 chip. With this, i will take the i2s audio from the streamer running in the pi, convert it to spdif and select between this and all the other spdif inputs. It can even be made so that it switches automatically when it detects a valid spdif signal and locks to it.
I am not sure if i will manage to make it work and i need to thank @phofman that is helping me a lot to understand the details of how these things work. thanks man!!

To the left there is a "i/o expansion pcb" with more spdif inputs and outputs. As of today i only need two toslink and one coax input and one toslink output, that are all in the main board. But the wm8805 has 8 spdif inputs. This expansion board is made to cut out and be placed on top of the main board and will have more spdif inputs and outputs. I have already placed some more coax and toslink and want to add AES/EBU as well just in case, but i dont know yet how to build an appropriate circuit for those.

The whole thing measures 16x18.5, that would be 13x18.5 without the i/o expansion board and 13x16 if i decide not to include the mosfet switch for the Motu.

I am pretty entertained with this and specially the wm8805 part is being very interesting.

What i have pending as well is to decide on exact size and size and position of the mounting holes to have a good variety of fitting boxes available. Wanted to make it Eurocard but it was not possible. Any suggestions or advice in this regard will be very much appreciated!
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
and two months and a lot of datasheet reading later....
1682165065646.png


and populated....

1682165213476.png


1682165296980.png


to the left, IR receiver connector, DC connectors to power/upower the input and output cards (a minidsp DDRC2x4 as input and Motu ultralite as output/dac), power in. And to the right, spdif inputs and outputs and display connectors.

And most importantly, it works!!

1682165510253.png


all the system (including external cards) get powered on/off via ir remote, can switch spdif inputs also via remote and hopefully very soon it will auto switch upon detecting a signal input. This is actually being easier than i though, what i have not sorted out yet is how to make the wm8805 audio interface (is2 to spdif and spdif to i2s) work without driver.... that one might take some more time...

Ah, and printing an enclosure, of course!!
 
Last edited:
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
and this is the overkill input expansion board that provides a lot more of spdif inputs as toslink, coax and AES/EBU and converters to all three formats of the output as well.
Unfortunately i dont have any AES/EBU source/receptor to test it...

1682165968320.png


I don't think i will ever have a use for them, but now I can confidently say "i have more spdif inputs than you" :p:


1682166116515.png
 
Last edited:
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
And after a few weeks more, i am almost done with the project.

I 3D printed an enclosure with PETG filament. I chose PETG over PLA because i was concerning about the enclosure getting too hot in the summer. The PETG that i used has a Tg of 78°C vs ca. 60°C of common PLA. The difference is very significant and i think in this regard PETG is fit for purpose. ABS would have been much better but i don't have a dedicated space for the printer and my wife is pregnat, so we didn't like the idea of melting ABS in our livingroom... I am not very satisfied with the aesthetics and a bit of warping from the PETG, but as the box will be inside a cabinet, i don't care too much.

What was very difficult to set up but is working better than expected is the small Noctua fan. To assemble the fan on the PCB is most probably not the best option given where the raspberry pi is placed. I can imagine that placing the fan on one of the walls would make it more efficient but it would complicate the design. My approach here was to just make a bit of air move inside the enclosure to avoid it getting too hot after hours of operation in the summer. Beyond that would go well beyond my knowledge and i believe it would go into diminishing results territory. It would be a different story if there was an amp module or something like that inside the box, but besides the two rpi, nothing else here generates significant heat, not even the MOSFET switches.

In principle i was planning to use any random fan for raspberry pi from amazon, but i read that those cheapo fans dont work well (=make too much noise) when at intermediate speeds, so i finally decided for the Noctua because users find them silent independently of the speed (and now i can report it is true). However Noctua doen't make fans that work at 3.3 V, minimum is 5V, and that is for both power supply and PWM signal, so i needed to connect a logic converter between the gpios and the fan. Like this, i can still power the fan with 5V directly from the pi power supply and use the 3.3V PWM signal from the gpios.
But to my surprise, Noctua fans come with a pull up resistor, so if there is no signal (i.e., if you switch off the rpi), the fan starts spinning at full power. I have found no documentation at all about the value of such resistor and Noctua did not answer my requests, so i needed to try different pull down resistor values until i made the fan stop when switching off the rpi...
I designed the enclosure so that the flow from the fan gets somehow focused on the pi (i did it by eye, so go figure out if my design is doing something. capture below), and wrote a script so that the fan starts working at 40% power when the CPU reaches 50°C and increases the speed linearly until 100% speed at 80°C. I am quite impressed with the result as the temperature stays at ca. 58°C vs reaching 73°C only after a couple of minutes working without fan.
So all in all very satisfied with the performance and low noise of the Noctua but very surprised by the poor documentation and support.

1685829015424.png
1685829175017.png


On the source selection side, I need to say i am very much impressed on how well the old wm8805 chip spdif multiplexer works. It changes instantaneously from one source to the other even at different sample rates. wm8804/5 chips don't report the exact sample rate of the incoming spdif signals, so I also wrote a small program in C (python is too slow to give any meaningful value) to measure the actual sample rate of the signal measuring how fast the LRCLK signal out of the wm8805 switches between 1/0. The sample rate measurement takes <1 second to be completed.
As you can see in the video below, the audio switching is instantaneous and very smooth, without any drops or noises that i can detect. The video shows the manual source selection at work using the remote control (the noises you hear is me pressing the button of the remote).


And finally, and this was something i was not sure i would be able to achieve, i also wrote a script that allows me to chose an "Auto" source, that is, an "audio detect" function.

It was not evident to achieve because the wm8805 only reports if it has locked an incoming spdif signal, but not if the signal is actually outputting any audio. And it turns out that most of my sources lock their signals even when not outputting anything. As example, my TV toslink sends a valid spdif signal even when turned off!! And this is not very helpful for an audio signal sense function...
So i decided to make use of the python library of camilladsp to solve this. pycamilladsp reports the incoming audio signal level, and this can make the trick. What my program does is to scan all the inputs, passing the signal to camilladsp, and then reads back the audio level reported by camilladsp. And when it detects an actual signal, it stays there.

I don't know how other commercial solutions solve this, but i find the camilladsp approach very neat and after a couple of weeks using it, i can say it works perfectly well and is very robust.
But the best part is that you have freedom to program it to work exactly like you want it to. For instance, what i ended up with is that if the current signal stays 20 seconds with a value lower than -86db (that is, complete silence, not just very low volume like it could happen when watching a film), the script starts scanning the other inputs, and when it finds another signal, it switches. You can also assign priorities, the order of scanning etc, etc.


the video above shows how the process works. At the beginning there is no signal in any of the sources. Then at around second 0:17 i start the tv and the software detects the signal and locks to it. Then i stop the tv, the signal goes to ca 1.4x10-6 (ca. -115db if i am not mistaken) and after a few seconds without any relevant signal, it starts scanning again.
I played conservative and measure 5 times each source with a pause of 0.1 seconds and an initial pause of 0.8 seconds for each source. This is fast enough for my needs, but it can be done faster if needed.

And basically that's it, i really want to explore other materials for the enclosure and work more on the display script to make it more smooth, but in terms of functionality i am already quite satisfied. I really liked this project, it kept me busy for a couple of months and i learned a lot of stuff!
 
Last edited:
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Something i realized with while doing all this, is how necessary stand-by leds are. I always hated them, but when it is the only way to know if your system is on...

Luckily, the oled display that i use (thanks to @mdsimon2 ) has pin3 free, and pin3 happens to be just besides a ground pin. That allows to solder a tiny smd led between the two:

1685901312733.png


I can control that pin with the raspberry pico - that is in charge of powering on/off the system and shares the ir receiver- and allows me to have a nice standby indicator whenever the system is off or receives certain ir remote instructions. Most useful feature ever :)

1685901546933.png
 

AudioThinker

New Member
Joined
Jan 30, 2024
Messages
4
Likes
0
Hi @MCH ,

I found your project while google esp32+spidf. I have some questions before ordering the pcbs.

Which programmer are you using to program the esp32?

Did you updated your pcb that prevents booting the esp32 up? Which Wrover module are you using 4mb/8mb?

Best regards.
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Hi @MCH ,

I found your project while google esp32+spidf. I have some questions before ordering the pcbs.

Which programmer are you using to program the esp32?
Hi @AudioThinker,
You need to use ESP32-DEVKITS-R to program the module. It is the only one that works with these modules as far as I know. It is normally available in the regular distributors (mouser, digikey…)
Did you updated your pcb that prevents booting the esp32 up?
Yes, fortunately I realized the issue before printing the PCBs, so I added the necessary parts and all works well.
Which Wrover module are you using 4mb/8mb?
Regarding the modules, I ordered ESP32-WROVER-E-N16R8 (with PCB antenna) ESP32-WROVER-IE-N16R8 (with external antenna connector). Both 16mb RAM and 8mb PSRAM. The bare minimum is 4 + 4 MB. I ordered the ones with more memory I guess because there were the ones available at the time. The difference in price is cents if I remember correctly. The idea behind ordering the one with the antenna connector is because I planned to install one inside an amplifier with metallic box. I did not do it eventually but if you plan to use it in a place with weak signal it might be a good idea (you will need an external antenna).
Months later I ordered a few more WROVER from Aliexpress at a very low price, I can find the link if you want.

Your post reminds me that other member asked me for the gerber files and I wanted to make them a bit better to send to him but I completely forgot…. If you wish I can do that and send you both the updated gerber files. This was my first PCB but now I have a bit more practice with kicad
 

AudioThinker

New Member
Joined
Jan 30, 2024
Messages
4
Likes
0
Hello @MCH ,

thank you for the fast response. It would be great if you update the Gerber files.. Also with the fix for the boot issue. I am mainly interested in the SPDIF Version, because it would allow an easy integration into existing amps.
I want order them directly in CN. Presoldered or not depends on the price.. I can solder but for me it would save a lot of time.
To be precise: If the esp32 is soldered to the pcb I can flash it anyways because the small connectors of the ESP32-DEVKITS-R will attach to it, right?

I will choose an module with 8mb or more. I know that it costs not that much more. The WiFi antenna is a good idea..
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Also with the fix for the boot issue. I am mainly interested in the SPDIF Version, because it would allow an easy integration into existing amps.
Do you mean coax or optical (toslink) spdif?
I want order them directly in CN. Presoldered or not depends on the price.. I can solder but for me it would save a lot of time.
To be precise: If the esp32 is soldered to the pcb I can flash it anyways because the small connectors of the ESP32-DEVKITS-R will attach to it, right?
The programmer has spring connectors. If you order a thin PCB and you solder it well, it can be pressed in and programmed after soldering. Safest though is to do it before in case. In the worst case you can also solder cables to the necessary pins if you have no other solution but you need to be relatively good at soldering
 

AudioThinker

New Member
Joined
Jan 30, 2024
Messages
4
Likes
0
Do you mean coax or optical (toslink) spdif?
Toslink.

I can solder but I hate soldering smd components ;-) … Do send the Gerber via PM or update it here? Where did you order your pcbs? I will try to order them at JLCPCB
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Toslink.

I can solder but I hate soldering smd components ;-) … Do send the Gerber via PM or update it here? Where did you order your pcbs? I will try to order them at JLCPCB
I can do either, maybe PM so we can discuss any details if you want. I will do only PCB + schematics (it is very simple). If you want it populated by jlcpcb you will have to do the placement and BOM documents. I will do with the toslink transmitter and usb connector that I used, if eventually you want to use a different one we can change the footprint in the PCB, no problem.

Yes, I use jlcpcb, as they are smaller than 10x10 cm they cost next to nothing to make and ship :)
 
Top Bottom