Muffsy Stereo Relay Input Selector

Open Source, versatile audio relay input selector controlled by an ESP32 or a rotary switch.

Similar projects worth following
Two takes on the stereo relay input selector.

* One is controlled by an ESP32 or a rotary switch, with full ESP32 pin break-out for maximum flexibility
* The other is controlled by a rotary switch only, but adds LED footprints (the other board can use the ESP32 for this)

This project uses Panasonic TQ-2 relays and separates power and signal grounds to prevent any switching noise, clicks or pops in the audio channels.

This project is fully open source. Use it for any purpose and change it into whatever you like. I would appreciate some credit if you decide to fork the project, but it's not required.

This project is fully built and tested. There's no programming of the ESP32 offered as of yet.

Eagle project files and gerbers are available in the files section.


  • Five stereo inputs, switched with Panasonic TQ-2 relays
  • One stereo output
  • Controlled with ESP32 or rotary switch
  • Space for the ESP32-DevkitC/NodeMCU, with break-out for all pins
  • IO pins go high when activating a relay, can be used for indicator LEDs
  • Power/GND for ESP32 and relays separate from signal power/GND
  • Pin distance for power and signal input/outputs: 5.08 mm / 0.2"
  • Pin distance for optional rotary switch: 2.54 mm / 0.1"
  • Fully open source, no strings attached

Schematics and Downloads

ESP32 Module

The ESP32 module used for this project is the one called ESP32s NodeMCU. It's got 2x19 pins, no pin labels on the top, and a white bottom side with the text "NodeMCU ESP-32S v1.1"

The ESP32 development kit has a CP2102 USB to UART bridge, drivers are available from Silicon Labs:

Information on how to program the ESP32 using the Arduino IDE is available from Espressif:

Espressif's "IoT Development Framework" IDF/SDK is available here, along with a lot more information:

Muffsy Relay Input Selector - Eagle project files

x-zip-compressed - 39.45 kB - 02/26/2018 at 07:19


Muffsy Relay Input Selector without ESP32 - Eagle project files

x-zip-compressed - 46.23 kB - 04/15/2018 at 15:28


Muffsy Relay Input Selector - Gerbers for PCB manufacturing

x-zip-compressed - 296.32 kB - 02/26/2018 at 07:22


Muffsy Relay Input Selector without ESP32 - Gerbers for PCB manufacturing

x-zip-compressed - 152.83 kB - 04/15/2018 at 15:29



The ESP32S Devkit - Eagle Library

lbr - 16.82 kB - 02/04/2018 at 22:35


View all 9 components

  • Combating the 250V peak when turning off the relay

    skrodahl05/25/2018 at 08:01 0 comments

    I just found this video that shows very clearly why the diodes on the relays are needed. Worst case, you'll get a 250V peak without them. This can harm your electronics, and will create very audible pops.

    The Muffsy Relay Input Selector combats this by using the flyback diodes, of course, and separating the power and signal grounds.

  • Lo Tech Muffsy Stereo Relay Input Selector - Without ESP32

    skrodahl04/15/2018 at 15:22 0 comments

    A version that excludes the ESP32 and adds LEDs has been requested. So I made one. Eagle project files and Gerbers are available in the files section.

    Here it is (just imagine the drum roll first):

  • Wifi problem gives great cable for rotary switch - The Muffsy Input Switch is now fully tested

    skrodahl04/06/2018 at 13:27 0 comments

    This project log discusses using the relay board without the ESP32. There's now a board designed specifically for this:

    One problem with projects like these is that the wiring has a tendency to end up as a heap of spaghetti.

    So I've been wondering about how I should do the rotary switch in particular (in a setup without the ESP32 module). This is the simplest setup, and you don't have to write any code at all.

    Coinciding with this, wireless coverage isn't that great in my new house. So I bought a Google Wifi bundle, and look what came with it:

    Yup, a very flat network cable. Great timing, hey? Let's get snipping!

    I kept the white leads on each side, and cut the white ones in the middle. The switch is 2P5T, I'll only use one of the poles. Yeah, and the ESP32 module will be removed.

    Here's the board without the ESP32 and the transistors, cable fully connected:

    There are crimp connectors on the rotary switch, since it's fairly sensitive to heat (such as from a soldering iron). That's it, apart from connecting power to the relays, connect inputs and output, and cut the flat cable to the correct length.

    Finally, with power connected. The rotary switch works perfectly, turn it to slowly and it will break one channel before connecting the other one. So no two channels mixed at any time.

    There you have it. A stereo relay input switch that can be controlled by either an ESP32-module or a rotary switch. Fully tested and all.

  • Simple sketch - Switch between Relay1 and 2, every 4 seconds

    skrodahl03/31/2018 at 15:53 0 comments

    This sketch will:

    • Define all the relays, and the ESP32's internal LED
    • Turn on Relay1, blink internal LED once
    • Wait four seconds
    • Turn off Relay1, turn on Relay2, blink internal LED twice
    • Wait four seconds, turn off Relay2 and start over
    • It also writes to the serial monitor when a relay is turned on or off, and uses two different ways of blinking the LED

    This shows how to turn on and off relays. Remember, you can connect an LED between the relay1-5 IO pins together with a 330 ohms resistor to GND. This LED will light up when the corresponding relay is active.

    The ESP32 has the capability to store the last selected relay, so it can be selected directly if the device is turned off and on again. (not shown here)

    Instead of just looping through the relays you can use push buttons, a potentiometer or a rotary encoder (and lots of other things that can hook up to the ESP32) to decide which relay is turned on.

    #define LED   2       // Internal LED
    #define relay1 23     // relay1 on IO23
    #define relay2 22     // relay2 on IO22
    #define relay3 21     // relay3 on IO21
    #define relay4 19     // relay4 on IO19
    #define relay5 18     // relay5 on IO18
    void setup()
        pinMode(relay1, OUTPUT);
        pinMode(relay2, OUTPUT);
        pinMode(relay3, OUTPUT);
        pinMode(relay4, OUTPUT);
        pinMode(relay5, OUTPUT);
        pinMode(LED, OUTPUT);
    void loop()
        // Turn on relay1
        Serial.println("Relay #1 - ON");
        digitalWrite(relay1, HIGH);
        // Blink internal LED once
        digitalWrite(LED, HIGH);
        digitalWrite(LED, LOW);
        // Wait 4 seconds
        // Turn off relay1
        // Turn on relay2
        Serial.println("Relay #1 - OFF");
        digitalWrite(relay1, LOW);
        Serial.println("Relay #2 - ON");
        digitalWrite(relay2, HIGH);
        // Blink internal LED twice
        for (int counter=0; counter<2; counter = counter+1){
          digitalWrite(LED, HIGH);
          digitalWrite(LED, LOW);
        // Wait 4 seconds
        // Turn off Relay2
        Serial.println("Relay #2 - OFF");
        digitalWrite(relay2, LOW);

  • Eagle Project Files and Gerbers

    skrodahl02/26/2018 at 15:13 0 comments

    Eagle project files and Gerbers are now available in the files section.

  • First Test of Audio Switching - Success

    skrodahl02/25/2018 at 21:30 0 comments

    The ESP32S is now mounted on pin headers:

    Testing with an oscilloscope and the QA401 audio analyzer reveals that there's no switching noise, nor any clicks or pops injected in the audio channels. And, it does of course switch the left and right stereo channels. :) 

  • Boards Received and Assembled

    skrodahl02/19/2018 at 21:11 0 comments

    The slow boat parked outside my house today and brought with it some shiny white PCBs.

    As you can see from the pictures, it's already built. The board was tested successfully using a short loop turning the relays on sequentially. I was able to verify that each relay turned on and off using the continuity tester on my multimeter.

    This first picture shows a test mounting of the ESP32S and the terminal blocks for signal input/output.

    A first for me, silk screen on the back:

    Stuffing the board was a quick job. Since my pin headers haven't arrived yet (and I am quite excited to see if it works), I soldered the ESP32S to the board.

    I need to either skip the terminal block for input power, or be really convinced that my programming is correct before I mount it. The screw terminals will block the USB connector of the ESP when in place. Of course, I am going to build a few more, so I might just consider this the prototype.

    Here's the completed board, without any kind of sensors or mechanics for actually switching channels:

  • Project Coder: Zeev Glozman

    skrodahl02/09/2018 at 11:12 0 comments

    I am not the best programmer there is, so I'm happy to say that @Zeev Glozman kindly volunteered to do the ESP32 coding for this project.

    Thanks Zeev!

  • Test - Controlling a relay with ESP32

    skrodahl02/05/2018 at 09:21 0 comments

    The ESP32 switches the relay on and off, just as a proof of concept:

  • ESP32S Devkit - Eagle Library

    skrodahl02/04/2018 at 22:38 0 comments

    I couldn't find the footprint for the ESP32S Devkit anywhere, so I made my own.

    You'll find it in the files section.

View all 11 project logs

Enjoy this project?


Discussions wrote 03/12/2018 at 10:24 point

Hey, do you plan to offer this as a kit like with the MC Phono Amp? I would be very interested.

  Are you sure? yes | no

skrodahl wrote 03/20/2018 at 15:28 point


Due to the cost of both the ESP32 module and the relays, it would be a very expensive kit indeed. Also, it lacks a power supply.

The answer is no on this one. But you do have all the design files to have your own boards produced, and a Mouser shopping cart for easy ordering of the components.

  Are you sure? yes | no

Zoltan Sisko wrote 02/25/2018 at 22:57 point

The emitter and collector of the transistors are reversed on the schematic diagram.

  Are you sure? yes | no

skrodahl wrote 02/26/2018 at 07:14 point

In what way? I am connecting two grounds. The circuit is shorted when the base goes high, regardless which sides are connected to the base and the collector.

I have changed it though, so it looks the way it "should". New schematics, Eagle project files and gerbers are in place.

  Are you sure? yes | no

Zeev Glozman wrote 02/06/2018 at 16:28 point

Hey i just wanted, to share this while its a completely differnet application, its an interesting read.

  Are you sure? yes | no

skrodahl wrote 02/02/2018 at 15:25 point

The following steps have been taken to avoid pops and noise:

 * Using "make before break" relays
 * There are diodes between the relay rails
 * The relay power/GND is separated from signal/GND (which means this things needs its own separate PSU to work as intended)

I hope that will make this thing silent. I won't know before I build it though. PCBs are on their way on the slow boat, so it'll be a week or four...

  Are you sure? yes | no

skrodahl wrote 03/02/2018 at 10:18 point

UPDATE: The relay board has now been fully tested using an oscilloscope and the QA401 audio analyzer.

There are no clicks, pops or noise of any kind entering the audio channels.

  Are you sure? yes | no

K.C. Lee wrote 02/02/2018 at 12:47 point

I had to use relay for muxing audio because I didn't want to wait for my PCB.  It worked but there are pops when they switches.  Video shows it.

Relay contacts bounce during switching and inject noise into the audio. That's why I didn't use them for my design.    Analog MUX on the other hand are quiet.

If you still want relays, you could mute the output during switching.  Also looks for something with less bounce.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

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