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

Custom PCB Set SDA & SCL #48

Open
digimatt22 opened this issue Jun 24, 2024 · 1 comment
Open

Custom PCB Set SDA & SCL #48

digimatt22 opened this issue Jun 24, 2024 · 1 comment
Labels
topic: documentation Related to documentation for the project type: imperfection Perceived defect in any part of project

Comments

@digimatt22
Copy link

Is there a method to set SDA and SCL pins for Wire to use in this library? I have a custom PCB and need to set the SDA and SCL pins to use on an ESP32.

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: documentation Related to documentation for the project labels Jun 25, 2024
@per1234
Copy link
Contributor

per1234 commented Jun 25, 2024

Hi @digimatt22. I see the relevant part of the library's API has not been documented.

The Arduino_LSM6DS3 library has a LSM6DS3Class constructor that takes a TwoWire class object:

LSM6DS3Class(TwoWire& wire, uint8_t slaveAddress);

The library defines a default global instance of this class named IMU_LSM6DS3:

extern LSM6DS3Class IMU_LSM6DS3;

LSM6DS3Class IMU_LSM6DS3(Wire, LSM6DS3_ADDRESS);

which is also usable via the IMU macro:

#define IMU IMU_LSM6DS3

The default instance uses the Wire instance of the TwoWire class. The TwoWire class is defined in the platform bundled Wire library (this one when using an ESP32 board).

So if you want to use an I2C interface other than the one provided by the Wire object then you can pass the TwoWire class object of the interface you do want to use to the library constructor.

You could instantiate another LSM6DS3Class object:

LSM6DS3Class MyCustomIMU(Wire1, LSM6DS3_ADDRESS);

(in this example, I am arbitrarily using the Wire1 TwoWire class object)

But it might be more efficient to reuse the existing instance created by the library:

void setup() {
  IMU = LSM6DS3Class(Wire1, LSM6DS3_ADDRESS);
  if (!IMU.begin()) {
    // ...

So, in answer to your question:

Is there a method to set SDA and SCL pins for Wire to use in this library?

No. This functionality would come from the Wire library. The Arduino_LSM6DS3 simply uses the standard interface of the Wire library for communication over the I2C bus to the LSM6DS3 chip.

So you should study the documentation for the ESP32 Wire library to learn what options you have for configuring the I2C interface:

https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2c.html

If you have any questions about doing that, you are welcome to post over on Arduino Forum:

https://forum.arduino.cc/c/using-arduino/microcontrollers/59

I'm sure we'll be able to help you over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Related to documentation for the project type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants