How to read the signal from POWER_EN pin

Continuing the discussion from Power on signal from Jetson Nano:

I tried to use the library GitHub - NVIDIA/jetson-gpio: A Python library that enables the use of Jetson's GPIOs to read a signal from POWER_EN pin, it is my code

import Jetson.GPIO as GPIO
GPIO.setmode(GPIO.TEGRA_SOC)
GPIO.setup('POWER_EN', GPIO.IN)

And I got an error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 358, in setup
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 121, in _channels_to_infos
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 121, in <listcomp>
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 104, in _channel_to_info_lookup
ValueError: Channel POWER_EN is invalid

when I ran this code.

It looks like the POWER_EN pin is not defined in the GPIO library.

How can I read the signal from POWER_EN pin with Python3?
Thansk.

hello monchatparle ,

please assign a pin number of your POWER_EN into this GPIO.setup function.
you may also check Jetson Nano Pinmux for the reference, thanks

Hi JerryChang,
Thanks for your reply.
But I can not understand your advice. I spent some hours on trying to grasp the term pinmux. But I could not find the pin number for the POWER_EN signal. I’ve tried the number 3 or 5, but both of them were invalid channel. Sorry, I’m a beginner of Jetson Nano even of Linux.
Could you please provide me with more details about the pinmux?
Regards.

which pin you’re actually used, is this the pin on J41?
please refer to NVIDIA Jetson Nano J41 Header Pinout - JetsonHacks as see-also.
thanks

Sorry, I did not descript my question clearly.
I want to read the signal from the POWER ON button.
In the document Jetson Nano Developer Kit User Guide , it is defined in the Button Header [J50] pins 11 and 12. When we connect the pins11 and 12, the Jetson Nano will start. I want to run a Python script to read the signal that the pins 11 and 12 is connected during the Jetson Nano runtime.

I think it may refer to your reply:

Thanks.

yes, please access [Jetson Nano Product Design Guide] for details. thanks

I want to know how to read the signal from POWER_EN pin. At first, I found your reply:

I spent some time on reading the document [Jetson Nano Product Design Guide]. But I could not find the pin number of the POWER_EN pin from that document. So I post this thread with the first words " Continuing the discussion from Power on signal from Jetson Nano :"

hello monchatparle,

could you please restate your actual use-case to read the signal from POWER_EN pin.
this is the carrier board receives the main power source (5V) and uses this to generate the enable (POWER_EN) to Jetson Nano.
besides, you’re using python library which running after Nano booting into linux kernel. which mean POWER_EN already on the high state once SHUTDOWN_REQ signal has triggered.

Hi JerryChang,

Thanks for your patience.
I connected a button to that pin, so I can start the Jetson Nano with a push on the button. And I need to shutdown the Jetson Nano gracefully after I push down the button again.
I have also some experience with C/C++, but I’m a beginner for Linux and hardware, sorry for that.

Best regards

hello monchatparle,

you don’t need to have implementation since there’s auto power-on option,
please also check [Sudden Power Loss] for the power-off sequence to protect your device.
for the details, please access Jetson Nano Developer Kit User Guide, you could disable auto power-on and use the pin to initiate power-on if auto power-on is disabled.
thanks

Hi JerryChange,
Thanks for your reply.
As the description of J50 in the document Jetson Nano Developer Kit User Guide,


I connected the Pins 5 and 6 with a jumper. And I also connected the Pins11 and 12 with a switch. If I push the switch, I can enable the Jetson Nano. And now I want to shutdown it gracefully, like sending a shutdown command in the terminal, when I push the switch again. So I need to read the signal of a push on that switch.
Thanks.

hello monchatparle,

there’s “gpio-timed-keys” for Nano’s power key functions.
it acts different behavior if you press the power key for 1, 3, or 5 seconds.
you should press the power key for 5 seconds, and it’ll sending power-off event to shutdown the board.
please also refer to device tree sources for details.
for example,
$L4T_Sources/r32.6.1/Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/porg-platforms/tegra210-porg-keys-p3448-0000-a00.dtsi

        gpio-timed-keys {
                compatible = "gpio-timed-keys";
                gpio-keys,name = "gpio-timed-keys"
                ...
                power {
                        linux,press-time-secs = <1 3 5>;
                        linux,key-codes = <KEY_DOWN KEY_DISPLAYTOGGLE KEY_ENTER>;

Hi JerryChange,

Thank you very much. You pointed a feasible path to solve my question. I will try it.