Soft Power Switch - USB-C -> Simulated Press Not Working

Greetings all,

I’ve hooked my Soft Power Switch - USB-C board up to both an Arduino Uno (R3) clone (the Adafruit Metro) and an Arduino Mega 2560 clone (RobotDyn MEGA) and have been unable to simulate a button press to turn the connected device in the “OUT” back on. I can, however, turn the device off with pin 32. Pressing the button manually does restore power to “OUT” and the device works again.

I’m unsure what I’m doing wrong as the sketch is copied 1:1 from the example, and neither pin A14 or D14 on the Mega connect to the board’s “PUSH” pin seem to do the trick. The only things that differ from the example page is that I do not have the arduino powered by the USB-C line, as that would kill power to the arduino that I am also using to send serial commands, I am not using a separate serial board, though I guess I could?

Any advice would be appreciated, else I think whatever components that simulate the button press may have gone bad. Is there a way to test that pin specifically outside the USB-C circuit, like by probing the component and setting the pin high or low?

Thanks for any help in advance!

Hi @biggestsonicfan ,

Unfortunately you can not turn the soft power switch back on again using the PUSH or OFF pads.

PUSH is an output. It is low when the switch button is being pushed. This allows your microcontroller to detect the button press and do a graceful shutdown.

OFF is an input. Pulling OFF high - to 3.3V or 5V - will turn the soft power switch off.

If your microcontroller sees PUSH go low, it can: do a graceful shutdown (close any SD files that might be open for example); and then power the system off by pulling OFF high.

The only way to turn the system back on again is to push the button on the soft power switch. Or connect an external normally-open push switch between BTN and GND and close that briefly to turn the power back on again.

But, if I understand your application correctly, you could connect a transistor (NPN, open-collector) or a MOSFET (N-channel, open drain) to the BTN pad and use that to pull BTN low. You would need to drive the Gate of the MOSFET high, to pull the Drain low and simulate a button press.

If the soft power switch is off, pull BTN low for ~100msec to turn the output on. If the soft power switch is on, pull BTN low for > 10sec to turn the output off.

I hope this helps,
Paul

2 Likes

Ah, I had not thought about that at all when purchasing but you’re absolutely right.

If your microcontroller sees PUSH go low, it can: do a graceful shutdown (close any SD files that might be open for example); and then power the system off by pulling OFF high.

Unfortunately, if the SD card could be closed, the data I see could be recovered from from the card without the need for such a device. Accessing corrupt data on this card hardlocks the i/o of the port until the drive simply disappears from the computer’s list, requiring a full unplug and replug to restore functionality and I attempt to recover the next file in the sequence of files. I was hoping this board would allow me to disconnect and reconnect the device fully, however this was something I had not anticipated.

But, if I understand your application correctly, you could connect a transistor (NPN, open-collector) or a MOSFET (N-channel, open drain) to the BTN pad and use that to pull BTN low. You would need to drive the Gate of the MOSFET high, to pull the Drain low and simulate a button press.

Correct, however I think I’m having an issue with ground? The NPN transistors I have are NPN Bipolar Transistors (PN2222), but it’s GND connection is coming from the Arduino Mega, not the USB-C cable providing power to the soft-switch board, and driving the transistor high doesn’t seem to have any affect. Connecting the Mega to the power of the soft-switch isn’t an option, as I wouldn’t be able to drive the button via serial.

I could probably have the Mega read when it’s turned off, wait, and turn it back on without serial. However without the ability to send a signal to turn it off I feel that defeats my use-case.

The most likely scenario is that I have wired something incorrectly, even though I did do a 5v LED test with a push switch, a 1k Ohm resistor, and a 10k Ohm resistor on the 5v LED to keep it on while the button was pressed, activating the NPN. I will continue to troubleshoot but I’m running out of configuration ideas.

EDIT: The NPN was inserted incorrectly, oops! It’s working now!

Hi @biggestsonicfan ,

Excellent. Thank you for the update. I am glad it is working.

If you need full isolation between the Arduino and the soft power switch, it should be possible to use an opto-isolator. The Arduino side would drive the opto-isolator input (via a suitable resistor). The opto-isolator output - which is usually an NPN open-collector output - would pull BTN low when the input side is ‘high’ (illuminating the internal LED).

Best wishes,
Paul