-->
Page 1 of 2

Setting SDA and SCL pins for I2C

PostPosted: Sat May 23, 2015 11:26 am
by dayzman
Hi

I'm trying to drive a BMP180 using this driver https://github.com/reaper7/esp8266_i2c_bmp180 It defines SDA to be pin 2 and SCK to be pin 0 in i2c.h. Could these pins be changed to other pins arbitrarily? Are there limitations on what certain GPIO pins are allowed to do?

Thanks

Re: Setting SDA and SCL pins for I2C

PostPosted: Sat May 23, 2015 12:35 pm
by GeorgeIoak
Somebody can correct me if I'm wrong but I believe that the ESP8266 has hardware I2C defined as SCL on GPIO14 and SDA defined on GPIO2. That means that if you want to use the built-in I2C driver you must use those pins to communicate with I2C devices. BUT, it is easy to bit bang the I2C protocol and the link you provided appears to just use that method. You should be able to use any GPIO pins except GPIO15 since it needs to be low at boot and your I2C pullup will make it high.

Re: Setting SDA and SCL pins for I2C

PostPosted: Mon May 25, 2015 12:35 pm
by eriksl
No there is no hardware i2c support, so you can use any gpio you like, as long as you set it up to open collector drive.

Re: Setting SDA and SCL pins for I2C

PostPosted: Mon May 25, 2015 12:55 pm
by GeorgeIoak
That's what I thought but since the "datasheet" has section 3.4 dedicated to I2C and even "defining" 2 pins to use I thought maybe it did. But re-reading this section I find the following statement:

Both I2C-Master and I2C-Slave are supported. I2C interface functionality can be realized via software programming, the clock frequency can be up to around 100KHz at most. It should be noted that I2C clock frequency should be higher than the slowest clock frequency of the slave device.


So there's no way that a hardware implementation would only support less than 100kHz. But now that bothers me a bit because with a 80MHz CPU clock why would you be limited to "100kHz at most"?

To be honest, it seems to me that there is a lot of "marketing" type information entered into what should be a techincal document.