Unable to use pin 20 as SCL for I2C on ESP32.
I submitted the fix to #8393 to expose pin 20 on ESP32. On the Adafruit Feather ESP32 V2, SCL is pin 20. I loaded the latest nightly build onto my board. I am running into the following issues.
When trying to initalise I2C, it is not accepting pin 20 as a viable option for SCL.
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(20), sda=Pin(22))
E (2540280) i2c: /home/micropython/esp-idf-v4.2/components/driver/i2c.c:767 (i2c_set_pin):scl gpio number error
I2C set up works with pin 14 as SCL.
If I try to simply init pin 20 as an output, it also fails.
>>> from machine import Pin
>>> p20 = Pin(20, Pin.OUT)
E (19500) gpio: gpio_set_direction(263): GPIO number error
@jepler suggested that perhaps the issue is resolved in the ESP IDF v4.4, but an attempt to build MicroPython with that version resulted in a failure to fit in flash. So, I have not tested this possibility.
NodeMCU ARNICA
I bought a NodeMCU from AMAZON equiped with ESP8266. I tried to use https://docs.micropython.org/en/latest/esp8266/esp8266/quickref.html
with no success.
At the end, here is issue: NodeMCU bought from AMAZON designed by AI-Thinker (http://www.ai-thinker.com) comes with ESP8266-12F and not 12E as in the quick ref. There are pinout changes, i.e. the I2C: SDA is D4 and SCL is D5 of ESP-12E.
Correct instanciation must refer to ESP-12F GPIO number like this :
from machine import I2C, Pin
import time
i2c = I2C(scl=Pin(14), sda=Pin(2), freq=50000)
NodeMCU_ESP-12F.pdf
This works well.
Pull-up resistors are not necessary with this ESP-12F.
Last point: how to identify ESP-12F ? look at the antenna shape: it is different (see my pdf).
It should be great and usefull to update the quick reference with the above info.
I love micropython.
Regards,
Alain DUBREUIL