<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Evgeny Petrov on Medium]]></title>
        <description><![CDATA[Stories by Evgeny Petrov on Medium]]></description>
        <link>https://medium.com/@evgenypetrov?source=rss-7a5388d9d9a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eLAgAxbtypc7Zk2CRDCRxQ.jpeg</url>
            <title>Stories by Evgeny Petrov on Medium</title>
            <link>https://medium.com/@evgenypetrov?source=rss-7a5388d9d9a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:49:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@evgenypetrov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jukebox. Solving sound quality problem]]></title>
            <link>https://evgenypetrov.medium.com/jukebox-solving-sound-quality-problem-f3a6891f8e63?source=rss-7a5388d9d9a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a6891f8e63</guid>
            <category><![CDATA[diy]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Evgeny Petrov]]></dc:creator>
            <pubDate>Sat, 29 May 2021 14:49:00 GMT</pubDate>
            <atom:updated>2021-05-30T07:40:28.332Z</atom:updated>
            <content:encoded><![CDATA[<p>Last time I’ve finished connecting amplifier to the Raspberry Pi and playing music. But we heard not only music but the relatively high level noise as well.</p><p>Now we I’m trying to figure out where the noise is coming from and how to get rid of it.</p><p>What do we know?</p><p>The noise sounds like digital data line connected to the output. No surprise: the raspberry pi is a computer and the “sound card” there has interesting approach: the jack output is connected to the GPIO pins with a couple of resistors and capacitors. And PWM signal produced by the CPU is averaged over small time and looks like sound wave afterwards. There are blog <a href="https://hackaday.com/2018/07/13/behind-the-pin-how-the-raspberry-pi-gets-its-audio/">posts about how does it work </a>or <a href="https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/pi-zero-pwm-audio">how to do the “sound card” for smaller raspberry pi</a>.</p><p>But we tested the sound with headphones already and haven’t heard this noise.</p><p>The noise apparently appears only when the amplifier is connected.</p><p>Maybe amplifier is noisy? Let’s connect it to the laptop output.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaBlznsJ-fdA&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaBlznsJ-fdA&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FaBlznsJ-fdA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6a22eb62034faf9266ff8b92d3afe89/href">https://medium.com/media/a6a22eb62034faf9266ff8b92d3afe89/href</a></iframe><p>No noise. So it is not amplifier</p><p>Maybe it’s power output of Raspberry Pi provides noisy power? Let’s connect amplifier to the separate power supply?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F65_1X9GUN_c%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D65_1X9GUN_c&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F65_1X9GUN_c%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a967d0b9950e8b157df1f8569a708ff0/href">https://medium.com/media/a967d0b9950e8b157df1f8569a708ff0/href</a></iframe><p>No noise as well. So the noise appears only when the amplifier is connected to raspberry pi power. But in experiment with notebook, we connected the amplifier to the raspberry pi power and there was no noise.</p><p>So the noise appears only when the amplifier is connected to both power output of raspberry pi, and audio output.</p><p>Most credible explanation of this effect, that we build a circuit with something similar to a <a href="https://en.wikipedia.org/wiki/Ground_loop_(electricity)">ground loop</a>.</p><p>I.e. the power line, amplifier, raspberry pi internals and audio wires form a circular wire. And it acts as an antenna or a transformer winding. And some of the raspberry pi internals act as a sending antenna or primary winding of a transformer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/0*zGjgwJ64BPMdJQmj.gif" /></figure><p>And as we see at the <a href="https://en.wikipedia.org/wiki/Ground_loop_(electricity)">ground loop wiki page</a>, the main approach to solve this problem is to break the ground loop. This is what we have done by connecting the second power supply. But two power supplies for a simple toy is an overkill. Let’s try to solve the problem and use only one.</p><p>So the power line should stay, and we should break the ground loop on the sound wires.</p><p>There are devices to do ground loop isolation. One thing is that they cost something and are quite bulky for portable devices.</p><p>So basically, what we want is transfer two alternating current signals without having electrical connection between circuits. There are two approaches for such decoupling: optoisolator (LED and photo-sensor) works well with didgital signals, since it can transfer direct signal. But since they are not used for sound transmission.</p><p>Another approach is to use transformers. So we need two transformers, one per channel. And the transformation coefficient should be 1. So that we do not change signal voltage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*11kql8lDcPFHY0z9.png" /></figure><p>Let’s try it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0dOXfamKEv8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0dOXfamKEv8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0dOXfamKEv8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a70c4eac6c98a80268fce9494a87d6b/href">https://medium.com/media/2a70c4eac6c98a80268fce9494a87d6b/href</a></iframe><p>Sound looks good enough now.</p><p>Next we will connect NFC reader.</p><p><em>Originally published at </em><a href="https://blog.epetrov.net/2021/05/jukebox-solving-sound-quality-problem.html"><em>http://blog.epetrov.net</em></a><em> on May 29, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a6891f8e63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jukebox. Playing music for the first time]]></title>
            <link>https://evgenypetrov.medium.com/jukebox-playing-music-for-the-first-time-ebbcce5088a5?source=rss-7a5388d9d9a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebbcce5088a5</guid>
            <category><![CDATA[diy]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Evgeny Petrov]]></dc:creator>
            <pubDate>Sat, 22 May 2021 14:10:00 GMT</pubDate>
            <atom:updated>2021-05-30T07:38:36.662Z</atom:updated>
            <content:encoded><![CDATA[<p>Last time <a href="https://blog.epetrov.net/2021/05/jukebox-intro-choosing-componets.html">I unveiled the jukebox project</a>, I’m working on. I’ve described parts I building it from. Let’s continue and connect them together.</p><h3>Setting up Headless Raspberry Pi</h3><p>For initial configuration, and ease of debugging it will be easier to connect HDMI monitor and keyboard. But many do not have them in the lap-top era, so let’s set up Headless Rapberry Pi</p><p>Components we need are:</p><ul><li>desktop/laptop PC (I use mac, some steps can be different for Windows, Linux should be mostly the same)</li><li>micro-SD card</li><li>SD card reader</li><li>Raspberry Pi</li><li>USB power supply</li><li>WiFi access point</li></ul><h3>Software</h3><h4>Configuration</h4><p>Let’s use Raspberry Pi OS for this project. Other Linux-Based distributions can work as well, but Raspberry Pi has libraries and tools preinstalled, which you may need for configuration and debug.</p><p>Let’s download <a href="https://www.raspberrypi.org/software/">official tool for flashing images on SD card</a>. And write Raspberry Pi OS on our SD card</p><p>Next follow the <a href="https://www.raspberrypi.org/documentation/configuration/wireless/headless.md">headless setup instruction</a>, and a headless part from the <a href="https://www.raspberrypi.org/documentation/remote-access/ssh/README.md">SSH configuration</a> instruction.</p><p>Now insert card into Rapberry Pi connecte power and wait for a while. If everything is OK, in a couple of minutes you should see “raspberrypi” computer in the list of wireless clients in the router.</p><p>Take the IP address of it and connect to it over SSH:</p><p>default password is “raspberry”.</p><p>In the Raspberry Pi shell, call the “sudo raspi-config” command. It will show you the pseudo-graphic interface for configuration.</p><p>In “System Options” -&gt; “Audio” select “Headphones” as audio output.</p><p>Now reboot:</p><p>Let’s connect headphones to the audio jack, and test.</p><p>After the Raspberry Pi boots we hear the weird robot-like sound “To install the screen reader press….”, repeating every 5 second. It is produced, by the GUI app which is automatically started on the “first” boot and is disabled, once you click through it.</p><p>But with headless setup, you can not do it. To disable this annoying sound I recommend to disable the “Desktop” environment in “raspi-config “ go to “System Options” -&gt; “Boot / Auto login” and choose “Console”.</p><p>Reboot again.</p><p>To test that sound is working I recommend to upload some mp3 file onto raspberry pi, and try to play it: “omxplayer &lt;your_song&gt;.mp3”</p><h3>Speakers and amplifier</h3><p>Let’s connect speakers and amplifier now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*b19n40NerXC55Hhj.png" /></figure><p>Amplifiers typically have COMMON, LEFT, and RIGHT as input. They can be connected directly to the headphones output of the Raspberry PI.</p><p>The headphones jack pinout:</p><p>In my case I want to have analog volume control. Therefore I connect a <a href="https://en.wikipedia.org/wiki/Potentiometer">potentiometer</a> in between.</p><blockquote><em>The potentiometer connection can be a bit confusing if you are unfamiliar with electronics. “It is variable resistor, why it has 3 pins, not 2 like normal resistor?”, “Why do you connect both channels to ground through it?”<br>If we look at just one channel:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*L6dXBKPjPgDRWcPz.png" /></figure><blockquote><em>We connect signal line to the ground through quite high resistance resistor, and there is barely any current. But this small current, allows us to get different “portion” of input signal, by adjusting position of the sliding contact. The </em><a href="https://en.wikipedia.org/wiki/Potentiometer"><em>potentiometer</em></a><em> acts as a </em><a href="https://en.wikipedia.org/wiki/Voltage_divider"><em>voltage divider</em></a><em> in this case.<br>Why the voltage is divided proportionally to the resistance values, can be explained by </em><a href="https://en.wikipedia.org/wiki/Ohm%27s_law"><em>Ohm’s law</em></a><em>.</em></blockquote><p>Power connected to power pins of the Raspberry Pi, just ensure polarity is correct. And we need 5V pins, not 3.3V ones.</p><p>Note that both outputs of the amplifier have separate “+” and “-” contacts and there is no “common”.</p><p>Now when everything is connected we can try it out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fe9cW9W0br7w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3De9cW9W0br7w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fe9cW9W0br7w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/023c8295a2a4ae3faca862e2b3aa554b/href">https://medium.com/media/023c8295a2a4ae3faca862e2b3aa554b/href</a></iframe><p>Wow. It works! But what is this noise. Which seems to be dependent on something, what happens on the raspberry pi: you see the noise changing, when green LED is blinking. This we will need to solve later.</p><p><em>Originally published at </em><a href="https://blog.epetrov.net/2021/05/jukebox-playing-music-for-first-time.html"><em>http://blog.epetrov.net</em></a><em> on May 22, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebbcce5088a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jukebox. Intro. Choosing components]]></title>
            <link>https://evgenypetrov.medium.com/jukebox-intro-choosing-components-c5ca408dbee7?source=rss-7a5388d9d9a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5ca408dbee7</guid>
            <dc:creator><![CDATA[Evgeny Petrov]]></dc:creator>
            <pubDate>Sun, 16 May 2021 07:09:00 GMT</pubDate>
            <atom:updated>2021-05-16T09:10:48.895Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jukebox. Intro. Choosing componets</h3><p>For last couple of month I’m working on a project which I call “Jukebox” — a portable player for my 2-year old daughter.</p><p>The project was inspired by <a href="http://phonybox.de/">Phonybox.de</a> project but I decided to start from scratch to learn all the basics.</p><p>The idea is simple: kid can play songs by placing RFID-cards onto the box. <br>It is hot it works now:</p><p>That’s the initial Idea for the project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/0*YDD4MobtQnnJ7zMi.png" /></figure><h3>Components selection</h3><p>Since I do such a project for a first time, choice of components is relatively random. Some are based on the availability, some on price, some on number of number of mentions in the Internet.</p><h4>Main control unit</h4><p>I’ve decided to build system around Raspberry Pi:</p><ul><li>I already had one, and have some experience with the platform</li><li>Bigger versions of raspberry pi (3B+, 4B) have audio-jack on board</li><li>has WiFi for remote access (to upload content, update soft)</li><li>has GPIO (for buttons and hardware control)</li></ul><h4>RFID reader</h4><p>There are many modules based on MFRC522 chip, often referred as RC-522. These ones are quite cheap an often are shipped with compatible cards. I’ve ordered a package of 3 modules, 3 cards, and 3 tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*f8nlzyk6-gLLUsGM" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*VuvOOu_kfIrfB0OL" /></figure><h4>Speakers</h4><p>Speakers and amplifier have to be selected together. What parameters to look at:</p><ul><li><strong>Impedance</strong>. Typically amplifiers have specification, what range of impedance they support. For speakers it’s just a fixed number. Typical values here are 4Ohm or 8Ohm.</li><li><strong>Power</strong> The amplifier output power shouldn’t be higher than speakers one. Otherwise speakers can be damaged. If amplifier power is less than speakers, it means you can not use the whole “capacity” of speakers, but it won’t harm anything. Note that with power more than 3W per channel, you may need more than 5V power supply.</li><li>Input voltage for amplifier. The raspberry pi is powered by 5V so it’ would be handy to feed the amplifier from the same source.</li><li><strong>Size</strong> speakers can vary in size. So, ensure they fit the housing you choose.</li><li><strong>Frequency range</strong> there are designed for producing sounds of only narrow sound range, they are intended to be used in the bigger sound systems, with different speakers for different ranges. For our needs we need a “Wide range” speaker, which will produce as large sound range as possible (we hear from 20Hz to 20kHz, but for our purposes something like 200Hz to 15kHz should be fine).</li></ul><p>I’ve selected a pair of 5cm 2W speakers to make stereo device, and a DIY amplifier set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*Z1NaZDWU5VcP2tzz" /></figure><h4>Power bank</h4><p>The bigger the better. There is a couple of features to consider, but they are not typically mentioned in descriptions.</p><ul><li>If power bank is connected to the power supply will it still provide electricity? For us is better if it would, then we can charge while the device is turned on.</li><li>Does it require to push some buttons to turn on output electricity. Some devices require to push the button to turn on the output. It doesn’t suite well our needs. There are devices which turn on, once load is connected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*z8t6kK6NP9POQsl_" /></figure><h4>Hosing</h4><p>The device should look at the end as a toy. So look up for something, what can fit all the components. Wooden boxes suite well this purposes. I had one as packaging for a present.</p><h4>Other</h4><p>Of cause to build everything together you will need some smaller components as well.</p><ul><li>Wires</li><li>Audio jack 3.5mm you need 3-pole jack</li><li>Stereo Potentiometer</li></ul><p>That’s how it looks everything together. The components are glued with hot glue or double sided tape. The photo is taken after a couple of iterations and improvements, which I hope to describe later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/0*J2C-jW4VMdaKCNw8" /></figure><p><em>Originally published at </em><a href="https://blog.epetrov.net/2021/05/jukebox-intro-choosing-componets.html"><em>http://blog.epetrov.net</em></a><em> on May 16, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5ca408dbee7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>