Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By mahdinga
#69487 Hi guys!!!
i got some issues about how to use esp8266's i2c.
i've heard from someone that this module has i2c communication. He told me that scl is GPIO5 and sda is GPIO4.
i want to use a gyroscope module(MPU6050 and it use i2c protocol) interfaced with this esp8266 and read and send the data to PC.And i am using Arduino application to program the esp8266.
i have connected it to esp but there is no logical answer. the numbers just get bigger and bigger. like a timer. i think it depends on i2c because the codes that i used has been tested on Arduino and worked great.

my BIG problem is that i can't use any other platforms(Because of their size!) so i need a way to connect the mpu6050 to esp8266 directly.

Eventually if you have any idea about this... Thank you if you share it with me :) :) :) :)
User avatar
By rudy
#69492
i've heard from someone that this module has i2c communication. He told me that scl is GPIO5 and sda is GPIO4.


It does not have I2C hardware but it does implement it in software. And it can be on different port pins compared to the fixed pins on the ATmega328P processor. I use I2C for connecting character LCDs. I use GPIO0 and GPIO2 since they need pull up resistors on boot up. Whatever pins you use the important thing is that you should be stating what pins you will be using for the SDA and SCL functions.

For the LCD library I use I use the following to state the pins used.

Code: Select all  lcd.begin(0, 2);        // In ESP8266, SDA=0, SCL=2


Or this might be what you need.
Code: Select all  Wire.begin(4, 5);                 // SCL <==> D1 , SDA <==> D2


Have a look at the library you are using and see if it has something similar. It may have some defaults. If it does make sure they are what you are using. Otherwise change them, or change the pins to match them.

Also have a look at how it was done by others.
https://github.com/emanbuc/ESP8266_MPU6050

https://github.com/benjenq/ESP8266_MPU6050_OLED_SSD1306

https://olivertechnologydevelopment.wor ... mu-part-1/

Note that some examples refer to the port pins as D0, D2, etc. and this is not the same as 0 (GPIO0), 2 (GPIO2).