Using GPIO1 to Turn On Amps & Power Supplies, Turn Off When No Music

I’m setting up my outdoor pool speakers using an Arylic Mini. I need massive sound outside, so I’m using Aiyama’s 600W TPA3255 mono amp per speaker. These fans run constantly when powered. I’m also using Mean Well’s 48V 9.6A power supplies. Those fans runs constantly as well. Therefore, I need to turn off the power with a relay when there’s no music playing. This also saves wasted electricity when there’s no audio playing.

Here’s a video of the process in action.

Fortunately Arylic gives us the ability to get a GPIO signal when the audio comes on, and then it auto turns that signal off 60s later when the audio goes off. We can feed this signal into a relay to toggle the amps and power supplies. For setting GPIO1 we can do that with ACP Workbench.

In the Audio Effect tab you can assign GPIO1 to Out Ctrl.

Back on the Audio Module tab, I had to set GPIO1 to Output with a Pull Up so the relay board would trigger correctly.

Initially I just fed the GPIO1 signal into my relay board. Unfortunately the first time I triggered the relay on, it welded itself shut. This is because there is a large spark generated when you turn on the power supplies and amps. The capacitors in there suck in so much power, they always cause a spark whenever I’m plugging them in.

I was going to give up on this whole idea, but figured I’d try an SSR (Solid State Relay) instead.

The SSR worked to remove any sparking, but it gave me warbled audio output from the speakers. Not sure why that is, but it was quite noticeable. I’m guessing the SSR adds enough noise to the incoming 110V that the power supplies and amps pick up on it.

So, I figured perhaps combining the two solutions might solve my overall problem. I could turn the amps and power supplies on with the SSR, but switch over to the mechanical relay once the system was on. To do this, I’d need a more complicated setup with a microcontroller adding the logic. Time to use the beloved ESP32.

I setup my ESP32 with ESPHome from inside Home Assistant. I configured the ESP32 to read in the GPIO1 signal from the Arylic and then send out the correct signal to the SSR first, then wait a few seconds, turn the mechanical relay on, and then turn off the SSR.

Here’s my ESPHome config file.

esphome:
  name: "esphome-test-btn"

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-82F084"
    password: "AiPmXmiGNAh6"

captive_portal:

# Configure the 2 Relays
switch:
  
  # Main basic relay that can get welded together on spark if don't have SSR below firing first
  - platform: gpio
    name: "Pool Amp 10A RelaY"
    id: pool_amp_relay
    pin: 
      number: GPIO26
      inverted: True
      mode:
        output: True
        open_drain: True
    restore_mode: ALWAYS_OFF
    
    # SSR Relay to avoid sparks on basic relay above, but this SSR sounds bad during music playback so need real metal wire connection on relay above long term
    # This MUST fire first when this rig goes on so the spark goes thru the SSR, not the basic relay
  - platform: gpio
    name: "Pool Amp SSR RelaY"
    id: pool_amp_ssr_relay
    pin: 
      number: GPIO32
      # inverted: True
      mode:
        output: True
        # open_drain: True
    restore_mode: ALWAYS_OFF

# Set setup_mode to true to see the threshold output of the touch button when touched and not touched
# Then change threshold: setting below in my_touch_sensor close to the touched value
esp32_touch:
  setup_mode: False

binary_sensor:

  # Test touch button. Just hang a wire off of GPIO15 and touch it to toggle on/off the relays as if the Arylic sent the signal
  - platform: esp32_touch
    name: "ESP32 Touch Pad GPIO15"
    id: my_touch_sensor
    pin: GPIO15
    publish_initial_state: True
    threshold: 300
    filters:
      - delayed_on_off: 500ms
    on_press:
      then:
        - if:
            condition:
              switch.is_on: pool_amp_relay
            then:
              - logger.log: "turning off relays (in cascaded way)"
              - switch.turn_on: pool_amp_ssr_relay
              - delay: 2s
              - switch.turn_off: pool_amp_relay
              - delay: 2s
              - switch.turn_off: pool_amp_ssr_relay
            else:
              # Cascade turn on SSR first to avoid spark, then turn on normal relay, then turn off SSR cuz it makea audio quality bad
              - logger.log: "turning on cascaded ssr, then relay"
              - switch.turn_on: pool_amp_ssr_relay
              - delay: 20s
              - switch.turn_on: pool_amp_relay
              - delay: 2s
              - switch.turn_off: pool_amp_ssr_relay
                
  # Feed the Arylic GPIO1 Out Ctrl signal to GPIO23
  - platform: gpio
    pin:
      number: GPIO23
      mode:
        input: true
        pullup: False
      # inverted: true
    name: "Arylic State"
    id: arylic_state
    publish_initial_state: True
    on_press:
      then:
        - logger.log: "Arylic Got Press (On)"
        - logger.log: "turning on cascaded ssr, then relay"
        - switch.turn_on: pool_amp_ssr_relay
        - delay: 2s
        - switch.turn_on: pool_amp_relay
        - delay: 2s
        - switch.turn_off: pool_amp_ssr_relay
    on_release: 
      then:
        - logger.log: "Arylic Got Release (Off)"
        - logger.log: "turning off relays (in cascaded way)"
        - switch.turn_on: pool_amp_ssr_relay
        - delay: 2s
        - switch.turn_off: pool_amp_relay
        - delay: 2s
        - switch.turn_off: pool_amp_ssr_relay
    on_state: 
      then:
        - logger.log: "Arylic State Changed"

Here’s the wiring for the ESP32 to the SSR and mechanical relay.

It now works like a charm. When I choose the Pool from Spotify, it sends to the Arylic Mini, which turns on GPIO1. That goes to the ESP32. The ESP32 turns on the SSR, waits a few seconds, then turns on the mechanical relay, then waits a few seconds, then turns off the SSR. It does the reverse when the audio turns off.

3 Likes