Search code examples
arduinoi2c

Changing Wire library's Hardware I2C pins for custom arduino


I am trying to change the wires i2c pins to 11,12 (SDA, SCL). I built my own PCB but do not have the i2c lines in the same location. I used adafruits feather52 bootloader.

I found online that changing the variant.h file changes the i2c lines, but I don't have that file on my computer (PC), although my mac does.

I have tried the Wire.begin(SDA, SCL) though that's for the esps

I also tried to edit the wire.h files in both the default wire under C/programs/Arduino and the one under user/AppData/Arduino/adafruit though I haven't found where the pins are set.


Solution

  • The hardware packages are istalled into the Arduino15 folder. The location of the folder on Windows is in users home directory in C:\Users\\AppData\Local\Arduino15\packages.

    The variant file is in variants/feather_nrf52832/variant.h

    The nRF52 MCU can use any pair of pins for I2C.

    So try to change in variant.h

    #define PIN_WIRE_SDA         (25u)
    #define PIN_WIRE_SCL         (26u)
    

    to pins you need.

    If it works, consider to define your own hardware definition instead of patching the variant.h.