Pin/port names on ESP32 and in general

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Ithuar
Posts: 2
Joined: Fri Jan 05, 2018 4:38 pm

Pin/port names on ESP32 and in general

Post by Ithuar » Fri Jan 05, 2018 5:02 pm

I need to measure delay time between to analog inputs.
For that reason I migrated from the ESP8266 (Having only one ADC) to a n ESP32 (ESP-WROM-32).
Flashing works fine but I am not able to find the Pin/Port names and their correspondence in
Micropython. (And I am not ready for the trial and error yet ;-) ) For the ESP8266 the website
https://micropython-on-wemos-d1-mini.re ... setup.html
was of great help.

Is there a general naming scheme in MicroPython for pin numbers counted on the chip or the names printed on the boards
like D1, D2, D18 etc?

If not, is there a list like the one for the WEMOS-D1?

Thanks!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pin/port names on ESP32 and in general

Post by pythoncoder » Sat Jan 06, 2018 7:19 am

I don't know if this is any help - it's for a different board but it might give some clues.
Peter Hinch
Index to my micropython libraries.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: Pin/port names on ESP32 and in general

Post by loboris » Sat Jan 06, 2018 9:50 am

When you use machine.Pin(n), n must be the ESP32 GPIO number (GPIOn) entered as integer.
The numbers printed on ESP32 board/module (possible prefixed by IO or some other text) coresponds to ESP32 GPIO numbers.
If only the text is printed on the board (like ADC1), you must cunsult the board documentation to see to which GPIO it is connected.

Ithuar
Posts: 2
Joined: Fri Jan 05, 2018 4:38 pm

Re: Pin/port names on ESP32 and in general

Post by Ithuar » Sat Jan 06, 2018 10:23 am

File Edit Options Buffers Tools Markdown Text Help
Thank you very much! Alas it is only close. My board is slightly different and the Ports I checked do not correspond to the Pins.
I guess I have to count Pins and measure connectivities.
In [here](https://github.com/micropython/micropyt ... hine_adc.c)[^1]

[^1]: https://github.com/micropython/micropyt ... hine_adc.c

I found the channels and GPIO as follows:

STATIC const madc_obj_t madc_obj[] = {
{{&machine_adc_type}, GPIO_NUM_36, ADC1_CHANNEL_0},
{{&machine_adc_type}, GPIO_NUM_37, ADC1_CHANNEL_1},
{{&machine_adc_type}, GPIO_NUM_38, ADC1_CHANNEL_2},
{{&machine_adc_type}, GPIO_NUM_39, ADC1_CHANNEL_3},
{{&machine_adc_type}, GPIO_NUM_32, ADC1_CHANNEL_4},
{{&machine_adc_type}, GPIO_NUM_33, ADC1_CHANNEL_5},
{{&machine_adc_type}, GPIO_NUM_34, ADC1_CHANNEL_6},
{{&machine_adc_type}, GPIO_NUM_35, ADC1_CHANNEL_7},
};

According to the [data sheet](http://espressif.com/sites/default/file ... eet_en.pdf)[^2]

[^2]: http://espressif.com/sites/default/file ... eet_en.pdf

I come up with the following table


---- ---- --- --- --- --- --- --- ---
Chan 0 1 2 3 4 5 6 7
GPIO 36 37 38 39 32 33 34 35
Pin 05 06 07 08 12 13 10 11
Port 03 04 05 06 10 11 08 09
Name VN D34 D35 D32 D27 D14 D25 D26
ADC 1673 962 624 302 38 160 0 68
---- ---- --- --- --- --- --- --- ---

Readings of the empty adc using e.g

machine.ADC(machine.Pin(38)).read()

are reported in the last row.
That means at least they all do something ...

For testing I attached two piezzos to Channel 6 and 7 and they respond to a knock, with different characteristics however.
Channel 6 pops up and relaxes during 100ms back to 0 whereas Channel 7 gives a single reading of approx 1000 and then
returns to approx 70.

Post Reply