← index #7831Issue #2612
Duplicate · high · value 2.303
QUERY · ISSUE

ESP8266 Pin Get Physical Address

openby PsuFanopened 2021-09-21updated 2022-03-30
port-esp8266

Is there a way to get the physical address of a pin class? For example a IRQ pin handler, determine which pin has tripped?

from machine import Pin

def handle(p):
	print(int(str(p)[4:-1])) # Better way to get pin number 5?

pin = Pin(5, Pin.IN, Pin.PULL_UP)
pin.irq(trigger=Pin.IRQ_FALLING, handler=handle)
CANDIDATE · ISSUE

ESP8266 get pin id once set

closedby spac3-monk3yopened 2016-11-08updated 2023-03-14
port-esp8266

Is there a clean way to access the pin id having a Pin object?

>>> from machine import Pin
>>> p = Pin(4)
>>> p.id()  # Something like this
4

Thanks

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied