Process of port mapping

kishan patel
Posts: 43
Joined: Wed Aug 30, 2017 4:56 am

Process of port mapping

Postby kishan patel » Thu Apr 19, 2018 2:06 pm

Actually,because of some reason i could not use ADC pin(GPIO4).
If i want to map GPIO34 to GPIO4,is it possible?.

If any one can know about it,Please guide me that how can do port-mapping.

Thanks in advance,
Kishan Patel.

User avatar
Posts: 1658
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Process of port mapping

Postby kolban » Thu Apr 19, 2018 2:43 pm

My loose thinking on this is that one should think of GPIO pins as immutable. GPIO pin X will ALWAYS be GPIO pin X. If your code is designed to access GPIO 4 ... think of that as accessing physical pin called GPIO 4 as opposed to any logical alternative. You can't "map" GPIO 5 (physical pin 5) to GPIO 4 (physical pin 4).

There are "logical" functions ... UART, SPI, I2C and others ... and some of them "can" be mapped to physical pins. For example ... if today you are using pin X for UART TX, then you can map UART TX to pin Y.

Going back to your question, I think what you are asking is "can I map the ADC logical channel found on GPIO4 to be accessed as the same logical channel on GPIO 34" ... and the answer to that appears to be no. While "some" functions can be mapped across different GPIO pins, this does not mean that ALL functions can be so mapped.

If we read here: ... s/adc.html

We find that there are two ADC controllers (ADC1 and ADC2) and a total of 18 ADC channels.

If we look here: ... /adc.h#L55

We find that GPIO4 is ... and always will be ... ADC2_CHANNEL_0. We can't map ADC2_CHANNEL_0 to a different pin. However, if we look further we see that ADC1_CHANNEL_6 is found on GPIO34. What this seems to tell me is that if you might be able to recode your application to work with ADC1_CHANNEL_6.
Free book on ESP32 available here:
Available for ESP32 consulting.

kishan patel
Posts: 43
Joined: Wed Aug 30, 2017 4:56 am

Re: Process of port mapping

Postby kishan patel » Fri Apr 20, 2018 4:46 am

Thanks for valuable answer.
I can recode for different ADC pin.But issue is about physical connection.
I have physical pin is IO4,and i found that there are some restriction to use this pin.
So,i was thinking that use IO34 functionality with physical pin IO4.

Again Thanks.

Who is online

Users browsing this forum: No registered users and 3 guests