-->
Page 1 of 1

Change I2C pins

PostPosted: Fri Dec 14, 2018 3:54 pm
by tschaboo
I've got this board and an I2C breakout board for a BME280 sensor. Unfortunately my board uses pin D2/GPIO4 (which is a standard Arduino pin for I2C) for the included OLED. So I want to move the I2C bus to different pins. I heard that the ESP8266 supports I2C on any pins.

Unfortunately I can't find out how to do that in Arduino. According to the Arduino documentation for the wire library, there is now method to set the pins.

Any hints?

Re: Change I2C pins

PostPosted: Sun Dec 16, 2018 4:46 am
by FreddyVictor
Arduino uses hardware i2c so must use specific pins so you won't get any help from that documentation

Just use the begin function and specify what pins you want to use - the function definition is:
void TwoWire::begin(int sda, int scl)

In future, look at the source files in the ESP8266 folder for help, though they may be hidden away on your pc...
I ended up creating separate installs for the ESP* boards using the portable (lookup as to how to do this) so the files are much easier to find

HTH
nb: I am a newbie so reserve the right to be totally wrong!

Re: Change I2C pins

PostPosted: Sun Dec 16, 2018 4:55 am
by schufti
in general i2c is a _bus_ so intended to serve more than one device.
As long as there is no addressconflict between i2c devices there is no need for two buses.

Re: Change I2C pins

PostPosted: Sun Dec 16, 2018 5:41 am
by Pablo2048