-->
Page 1 of 1

Wemos D1 mini pro - GPIO16 disabling I2C

PostPosted: Thu Mar 25, 2021 12:42 pm
by Herrero
Hi,

I have problem with using I2C on default pins (D1 and D2) when D0 (GPIO16) is set as output. To GPIO16 is connected mosfet transistor to drive two LEDs. Generally GPIO16 works well - I'm able to turn on and turn off LEDs. The problem is with I2C. When I set the D0(GPIO16) as output the I2C interface stops working. I'm not able to communicate with other sensors. If I again set D0 as INPUT, I2C is working again. Why GPIO16 interfere with I2C? How to workaround this problem? The schema of my device is in attachement.

Re: Wemos D1 mini pro - GPIO16 disabling I2C

PostPosted: Thu Mar 25, 2021 5:26 pm
by btidey
GPIO16 is different to the other GPIO as it is part of the RTC module where deep sleep uses it to wake up the cpu. It therefore uses calls to control it rather than being a directly accessible register and is significantly slower to read and write. See https://www.espressif.com/sites/default ... nce_en.pdf section 2.2.5

As I2C is implemented in software it might be that the GPIO16 operations could disrupt this for higher i2c speeds. Try lowering i2c speed if you can or avoid using the pin during i2c operations.

Re: Wemos D1 mini pro - GPIO16 disabling I2C

PostPosted: Thu Mar 25, 2021 5:50 pm
by AcmeUK
I was under the impression that you can manually assign pins for the I2C bus with:-
wire.begin(pin_sda, pin_scl)

Re: Wemos D1 mini pro - GPIO16 disabling I2C

PostPosted: Fri Mar 26, 2021 4:44 pm
by Herrero
Thank you! Is working for lower I2C bus speed.