Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIN14 always returns "1" #11

Closed
pixelwave opened this issue Oct 18, 2023 · 4 comments
Closed

PIN14 always returns "1" #11

pixelwave opened this issue Oct 18, 2023 · 4 comments

Comments

@pixelwave
Copy link

pixelwave commented Oct 18, 2023

I tried to replicate your project, so far power on works. But somehow my PIN32 (reads RESET pin from mainboard) always returns "1" no matter if power button pressed and pc running or not. I only shows "0" when I unplug the mainboard completely?

IMG_1793

IMG_1796

My ESP32 test code:

import machine
import time

# Define the pin for the LED and the boot button
led_pin = machine.Pin(2, machine.Pin.OUT)
button_pin = machine.Pin(0, machine.Pin.IN)
power_pin = machine.Pin(13, machine.Pin.OUT)
reset_pin = machine.Pin(32, machine.Pin.IN)

# Function to turn on the LED
def turn_on_led(pin):
    pin.on()

# Function to turn off the LED
def turn_off_led(pin):
    pin.off()

# Main loop
while True:
    if button_pin.value() == 0:
        turn_on_led(led_pin)
        power_pin.on()
    else:
        turn_off_led(led_pin)
        power_pin.off()

    print("Power State:", reset_pin.value())


@pixelwave
Copy link
Author

pixelwave commented Oct 18, 2023

I figured out ... what works though ... if I connect PIN32 to POWER_LED+ on the ATX header. Is that safe to do?

IMG_1797

IMG_1798

@Erriez
Copy link
Owner

Erriez commented Oct 22, 2023

@pixelwave Thanks for using this project. Reading the computer power state is motherboard dependent. What works for you may not work on another motherboard as it is not standardized. When the reset pin does not work, I also recommend to use a different pin like the power LED. When the input pin of the ESP32 does not exceed 3.3V, then you can use this pin. Otherwise you can use an optocoupler for isolation. Success!

@pixelwave
Copy link
Author

pixelwave commented Oct 23, 2023

Thanks for the reply! Yes I was quite confused that it works in your case. After my research usually the feedback was:

The reset pin on a PC motherboard is typically used to perform a hardware reset of the computer, forcing it to restart. It is not designed to provide information about the power state of the PC. The reset pin is a momentary contact switch or signal that, when triggered, causes the computer to reset and begin the boot process.

I went exactly down the road that you suggested in the meantime. With the help of the reddit community I came up with this scheme using optocouplers and the power LED. I assembled it - and it works!

Screenshot 2023-10-23 at 08 19 23

This code I used for testing:

import machine
import time

# Define boot button on ESP32
button_pin = machine.Pin(0, machine.Pin.IN)
power_pin = machine.Pin(13, machine.Pin.OUT)
reset_pin = machine.Pin(14, machine.Pin.IN)
reset_pin.init(mode=machine.Pin.IN, pull=machine.Pin.PULL_UP)

# Main loop
while True:
    if button_pin.value() == 0:
        power_pin.on()
    else:
        power_pin.off()

    print("Power State:", reset_pin.value())

With the onboard button of an ESP32 dev board (pin0) I can trigger the pc boot (pin13). When the PC is running pin14 outputs low/0 when it is off high/1. I tried to use PULL_DOWN on pin14 to reverse that but the output was always 0/low then.

Btw .. do you have a tip for a good online forum / community where ESP32/electronics stuff like this can be discussed?

@Erriez
Copy link
Owner

Erriez commented Oct 25, 2023

Good to hear that you found a solution. I probably designed exactly this schematic when opto isolation is required. So well done. :-)

Btw .. do you have a tip for a good online forum / community where ESP32/electronics stuff like this can be discussed?

I recommend https://hardwarerecs.stackexchange.com which if pretty new / Stackoverflow or Reddit.

I assume this issue can be closed. Otherwise let me know.

@Erriez Erriez closed this as completed Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants