Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure the pins for I2C #18

Open
rogeriopedroso opened this issue Jan 16, 2023 · 5 comments
Open

Configure the pins for I2C #18

rogeriopedroso opened this issue Jan 16, 2023 · 5 comments

Comments

@rogeriopedroso
Copy link

Hello everybody,
I need to configure I2C, and I can't do it using the wire.begin(26, 14) method. Can someone explain to me how I configure the pins for I2C

@trothe
Copy link

trothe commented Feb 17, 2023

I ran into the same issue and managed to make it work like this:

#include <Wire.h>

#define I2C_SDA 33
#define I2C_SCL 32

void setup() {
  Wire.begin(I2C_SDA, I2C_SCL);
}

Here the full example for reading a BME280:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define I2C_SDA 33
#define I2C_SCL 32


Adafruit_BME280 bme;

void setup() {

  Wire.begin(I2C_SDA, I2C_SCL);

  Serial.begin(9600);
  // while (!Serial);

  if (!bme.begin(0x76)) {
    Serial.println("Error, check I2c address and wiring!");
    while (1);
  }
}

void loop() {
  Serial.print("Temp:");
  Serial.print(bme.readTemperature());
  Serial.println("*C");

  Serial.print("Pressure:");
  Serial.print(bme.readPressure() / 100.0F);
  Serial.println("hPa");

  Serial.print("Humidity:");
  Serial.print(bme.readHumidity());
  Serial.println("%");

  Serial.println();
  delay(1000);
}

@supermarioprof
Copy link

supermarioprof commented Aug 3, 2023

How do you physically connect to pin 32 and 33? soldering directly to the ESP32 board on the T-relay board?
and, how can you use this pins for I2C whyle using for controlling relays?
on T-relay 8X pins 32 and 33 are connected to relays K1 and K2

I also tried to scan with common I2C scanner code, after connecting to pin 14 and 25, without success, no device found.

@supermarioprof
Copy link

How do you physically connect to pin 32 and 33? soldering directly to the ESP32 board on the T-relay board? and, how can you use this pins for I2C whyle using for controlling relays? on T-relay 8X pins 32 and 33 are connected to relays K1 and K2

I also tried to scan with common I2C scanner code, after connecting to pin 14 and 25, without success, no device found.

SOLVED for me!
in this comment the solution!

Wire.begin(26, 14);

so pinout for I2C on T-relay 8X is

SDA: pin 26
SCL: pin 14

@TAMILOLI
Copy link

TAMILOLI commented Feb 3, 2024

Hi, We are use it T_Relay4_ESP32 with I2C. In our development is IDF. we set it as pin into SDA - 26, SCL - 14. But Not Working as to LCD Display. Please Give me solution. In our code reference is https://esp32tutorials.com/i2c-lcd-esp32-esp-idf/

@trothe
Copy link

trothe commented Feb 3, 2024

Hi, We are use it T_Relay4_ESP32 with I2C. In our development is IDF. we set it as pin into SDA - 26, SCL - 14. But Not Working as to LCD Display. Please Give me solution. In our code reference is https://esp32tutorials.com/i2c-lcd-esp32-esp-idf/

In my case on the T_Relay4 it was SDA 33 SCL 32. Maybe the T-Relay 8x is using other pins. you should give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants