logo elektroda
logo elektroda
X
logo elektroda

Changing I2C pins in the Arduino Uno using the Wire.h library: are PC5 and PC4 free?

pier 3213 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19351767
    pier
    Level 24  
    Hi.

    Does the Wire.h library after changing the standard I2C pins to other pins mix anything else on these standard pins?
    Figuratively, let's take for example an Arduino Uno which has standard I2C on the PC5 PC4 pins I change them via Wire.begin(12,13); and I can already use the PC5 PC4 pins without problems?
  • ADVERTISEMENT
  • #2 19351827
    Anonymous
    Level 1  
  • #3 19351831
    GanzConrad
    Level 25  
    I don't play with arduino, but I would look at the library first: if it uses hardware I2C (TWI) then it won't work, but if it generates programmatically then there should be no problem.
  • #4 19351836
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #5 19351958
    pier
    Level 24  
    A little more detail.
    I am using the Esp8266 not the uno, the uno was given as an example.
    Without any problem I use Wire.begin(); so as to change the I2C pins from standard to others and it works.
    The problem is that under these standard I2C pins in my case I have a gps receiver plugged in.
    And yes, if I use only the gps it is ok and everything works but if I configure I2C with the wire.begin(12,14); command, i.e. on other pins, the gps stops working and I2C works. It's as if even after changing the pins the library still freaks something out on those standard I2C pins.
  • #6 19352303
    Anonymous
    Level 1  
  • #7 19352753
    krzysiek_krm
    Level 40  
    pier wrote:
    And yes, if I use only gps then it is ok and everything works but if I configure I2C with the wire.begin(12,14); command, i.e. on other pins then gps stops working and I2C works. It's as if even after changing the pins the library still freaks something out on those standard I2C pins.
    .
    You write slightly vaguely. However, I think that when you change the I2C pins it is the bus on those "original" pins that stops working. You need to create a second I2C bus (on those previous pins).
  • ADVERTISEMENT
  • #8 19353097
    pier
    Level 24  
    I don't know how to describe it better.
    I fired up a homemade board with esp8266 and oled on pins 14,12, to it I connected a gps receiver which is plugged into the standard pins used by esp for I2C. Don't ask why I2C on different pins than it should be. The library for the gps is tinyGPS++ and SoftwareSerial.

    If I fire the gps itself on pins 4,5 it is ok, everything works. If I run the bus to the oled on pins 14,12 the oled works but the gps does not. Why?
  • ADVERTISEMENT
  • #9 19353122
    Anonymous
    Level 1  
  • #10 19353133
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    The library for gps is tinyGPS++
    .
    Provide a link to this library that you used.

    Added after 1 [minute]: .

    pier wrote:
    If I fire up the bus to the oled on pins 14,12 then the oled works but the gps no longer.
    .
    And to this display too.



    TinyGPS++ .
    And the library for the oled is the one from Adafruit without any quirks. Adafruit_SSD1306.h
  • #11 19353151
    Anonymous
    Level 1  
  • #12 19353329
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    And the library for the oled is the one from Adafruit without any quirks.
    .
    That's great, now write how you specifically call the Adafruit_SSD1306::begin() command i.e. with all four parameters.
    .

    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  • #13 19353356
    Anonymous
    Level 1  
  • #14 19353741
    pier
    Level 24  
    The code is no secret:

    Code: C / C++
    Log in, to see the code
    .

    I can already see what this is about.
  • #15 19355707
    Anonymous
    Level 1  

Topic summary

The discussion revolves around the use of the Wire.h library for I2C communication on an Arduino Uno, specifically addressing the implications of changing the default I2C pins (PC4 and PC5) to other pins (e.g., 12 and 14). It is clarified that on the Arduino Uno, the I2C pins are hardware-assigned and cannot be changed, meaning that using Wire.begin(12, 13) does not free up PC4 and PC5 for other uses. Users are advised to consider software alternatives like SoftWire or SoftI2CMaster for I2C on different pins. A follow-up reveals that the original poster is using an ESP8266, where they successfully change I2C pins but encounter issues with a GPS receiver when I2C is configured on non-standard pins. The conversation highlights the need for careful management of I2C buses and the potential conflicts with other devices connected to the standard pins.
Summary generated by the language model.
ADVERTISEMENT