



What am I doing wrong? Powering PC using esp32 c6 and PC817 4 channel optocoupler board - Not Working!
Hey all, hoping for some fresh eyes on this one.
I’m using an ESP32-C6 to remotely trigger my PC’s power button instead of the case power button.
The signal path is:
ESP32-C6 GPIO pin -> PC817 4 channel optocoupler board (only using 1 of the 4 channels) -> motherboard PWR header
So it’s 4 wires total on that one channel: two on the input side going to the ESP32 GPIO 4 and ground, and two on the output side going to the two PWR pins on the motherboard.
The idea is the ESP32 pulses the GPIO briefly, which switches the optocoupler’s output transistor on for that same brief moment, which closes the PWR circuit just like a normal button press would.
Then I used Esphome in Home Assistant to write the firmware (which seems to be fine, showing the device connected and popped up in integration and added correctly)
esphome:
name: pc-power-control
friendly_name: PC Power Control
area: Living Room
esp32:
board: esp32-c6-devkitc-1
framework:
type: esp-idf
api:
encryption:
key: !secret pc_power_api_key
ota:
platform: esphome
password: !secret pc_power_ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: NONE
ap:
ssid: "PC-Power-Control Fallback"
password: !secret pc_power_fallback_password
logger:
level: INFO
switch:
- platform: gpio
pin: GPIO4
id: power_button_relay
internal: true
button:
- platform: template
name: "PC Power Button"
icon: "mdi:power"
on_press:
- switch.turn_on: power_button_relay
- delay: 300ms
- switch.turn_off: power_button_relay
However, i believe the problem is on hardware level.
When I plug in the PSU cable, the PC powers on for a second or two, then shuts itself off. Clicking the power on button in home assistant doesn’t do anything. Nothing in the logs as well.
All the wires are properly screwed into the terminal blocks on the optocoupler board, nothing loose.
Appreciate any help, I’m still learning this thing