Port-to-number (so we can inspect a port to see what GPIO is actually being used)



convert a port value to a number that represents the GPIO defined by the port


  • PORT (PORT, default=D0) — The port number to be converted


  • OUT (number) — the GPIO number that the port number is mapped to

Extra info: in trying to determine why the first step of the introduction tutorial failed to work on a NodeMCU board I tried to see what value was being used by D1. I could find no way to convert a PORT value to something I could view. No port-to-number nor port-to-string nodes available to bring the actual GPIO value into something that could be inspected at run time.

The utility would mostly be for when debugging code that was written for one board and wont run on another, or written logically for a board that does not have default pin mappings.