I'm a begginer with Arduino and this may be a basic question but I'm facing an issue.
I'm using a HTU21D sensor with an ESP32. This sensor use I2C communication. Inside the Arduino library, there is this function to start to collect data:
//Start I2C communication
void HTU21D::begin(TwoWire &wirePort)
{
_i2cPort = &wirePort; //Grab which port the user wants us to use
_i2cPort->begin();
}
As you can see, we can set in this function which port we want to use. Perfect. But my probleme is that I don't know how to use the type TwoWire. I checked some documentation but I was still unable to find a solution. I want to use GPIO_16 as SDA and GPIO_17 as SCL.
So I tried something like that without result: htu21d.begin(Wire(16, 17));
How to set SDA and SCL pin in TwoWire type ? (in my case GPIO_16 and GPIO_17)
htu21d.begin(Wire);
?Wire
is an object, an instance of TwoWire class. it is defined in Wire.h at the endvoid TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
here github.com/espressif/arduino-esp32/blob/master/libraries/Wire/…