I2C pins

systemsconnect
Posts: 11
Joined: Tue Jan 20, 2015 3:47 pm

I2C pins

Postby systemsconnect » Mon Jan 18, 2016 7:51 pm

Hi,

Is it possible to use GPIO13 and GPIO12 for I2C communications? I'm not sure if it's working on these pins.
I'm using a ESP12 board and SDK v1.5.1 .

I've changed the SDA pin to 13 and SCL to 12 in i2c_master.h file but no response is received.

Code: Select all

#define PERIPHS_IO_MUX_GPIO13_U          (PERIPHS_IO_MUX + 0x8)
#define PERIPHS_IO_MUX_GPIO12_U          (PERIPHS_IO_MUX + 0x4)

#define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO13_U
#define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_GPIO12_U
#define I2C_MASTER_SDA_GPIO 13
#define I2C_MASTER_SCL_GPIO 12
#define I2C_MASTER_SDA_FUNC FUNC_GPIO13
#define I2C_MASTER_SCL_FUNC FUNC_GPIO12


Sensor read code on i2c:

Code: Select all

i2c_master_start();
  i2c_master_writeByte(_i2caddr);
  uint8 ack = i2c_master_getAck();

  if (ack) {
    char info[50];
    os_sprintf(info, "addr %d not ack for reset\r\n", _i2caddr);
    uart0_sendStr(info); 
    i2c_master_stop();
    return ;
  }

ESP_Vincent
Posts: 8
Joined: Wed Apr 06, 2016 5:19 pm

Re: I2C pins

Postby ESP_Vincent » Fri May 13, 2016 3:11 pm

It is not possible to use GPIO13 and GPIO12 for I2C communications.
Just can use GPIO14 and GPIO2

gemborow
Posts: 1
Joined: Thu Sep 22, 2016 6:28 am

Re: I2C pins

Postby gemborow » Thu Sep 22, 2016 6:33 am

Why this is not possible? In "SDK" provided with PlatformIO/Arduino (https://github.com/esp8266/Arduino.git) this is possible, but the code there is very different from your SDK so copy&paste is quite impossible. I tried similar solution hacking i2c_master.h/.c but without any luck (GPIO 4 & 5 which is working with Arduino SDK). Isn't it just a matter of setting GPIO in open collector mode?

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: I2C pins

Postby eriksl » Mon Oct 10, 2016 9:37 pm

ESP_Vincent is talking nonsense.

The ESP8266 does NOT have any hardware for I2C communication. So you can implement it using software "bit banging" and when you're doing that, which I/O pin you use does not matter.

Who is online

Users browsing this forum: Bryantpoirm, HenryCot, Henryionic and 4 guests