SDA and SCL (I2C) in different pins


#1

Hi,

Is there any possibility to change SDA and SCL pins? Because i’m using already the SDA (D0) and SCL (D1) pins for Serial2.

I had tried to redefine the pins in spark_wiring without success. Should i need remap to other variables or simply is not possible?

I have some analog and digital pins available.


#2

There is a way to remap the pins to other pins on the STM32 package, but unfortunately they are not pinned out to the headers. See page 181 of the RM0008 Reference Manual:

These pins are used by the CC3000 and External Flash memory:

There is a second I2C bus that is on port pins PB10 and PB11. Unfortunately as you can see above those are taken as well.


#3

@aaraujo, I think @BDub is saying NO you cannot :stuck_out_tongue:

Note: @BDub’s brain is considered too big for his head and sometimes really good stuff spills out for all of us to greatly benefit from :wink:


#4

@peekay123 it is a nice way to @BDub say NO :P, just to convince me that is not possible :), thanks for clarify me. And since it´s not possible to change the SDA and SCL pins, is there a way to remap the Serial2 pins? It also solve my problem too :slight_smile: .


#5

@Could you give some more detail what kind of devices and communication you have in mind to maybe come up with some alternatives, you might not have thought of?

Possibly all the connections (e.g. is RX/TX already used?)


#6

Hi @ScruffR, basically in my setup i have 2 xbee modules that it can only be connect by Serial, so i’m using the Serial1 Tx/Rx pins, and the other module i’m using the Serial2 D0/D1 pins and the problem is that i have a monitor device that the only option to communicate is by I2C, So i’m a running out of options. I’m also using the SPI pins (A2,A3,A4,A5) to read data from and IMU.


#7

I thought of saying No, but honestly just wanted to leave it open to another way :wink:

You could multiplex two devices using Tri-state buffers between the D0,D1 pins and your Serial2 and I2C devices. Although it might be easier to manage this with 2 serial devices, especially if you didn’t need to respond to async receive events.


#8

@aaraujo, if full I2C bus speed is not required, you may be able to use a software I2C master implementation which you could allocate on alternate pins. I have seen a few libraries which could be ported for the Core. :smile:


#9

Hey everyone! Hope I’m not reviving an old answered question

Was this software I2C ever ported over to Particle devices? I’d like to give my devices some flexibility to use different pins for a BME280 (and other sensors using I2C) while using as few pins as possible, which is why I’d love to read that there is a way to use I2C communication on arbitrary pins on the Electron.

Thanks!


#10

@Felipe_Pardo, you can probably adapt one of the many Arduino libraries listed here:


#11

Or you an I2C multiplexor like the TCA9548A. You can take the single I2C bus on D0/D1 and break it out into 8 separate busses. And you can put 8 TCA9548As on D0/D1, so I think you can have 64 independent I2C busses off just D0/D1 that way.

https://docs.particle.io/faq/particle-devices/i2c-faq/electron/#multiplexer-tca9548a