Closed borlowsky closed 2 years ago
Hi there,
This is indeed possible, the init() function allows to use an optional TwoWire parameter: https://github.com/Sensirion/arduino-sht/blob/master/SHTSensor.cpp#L285.
At this point, the autodetect does not work on the second bus, but I just merged #23 which will address this. To make it work with the current version, you will have to create the SHTSensor with a sensor type, like so:
SHTSensor sht1(SHTSensor::SHT3X);
SHTSensor sht2(SHTSensor::SHT3X);
// ...
Wire.begin();
// ...
sht1.init(<insert bus 1 here>);
sht2.init(<insert bus 2 here>);
You can start with the multiple-sht-sensors.ino example as a starting point, change both sensors to be SHT3X (assuming they are), and then add the two busses as arguments to init(...)
I will close this, feel free to reopen if you run into any issues!
Best, Johannes
Thanks a lot for your quick reply! Don’t know why I did not get it to work yesterday, but now it’s fine! Cheers, Boris.
From: Johannes Winkelmann @.> Sent: Wednesday, April 20, 2022 8:04 PM To: Sensirion/arduino-sht @.> Cc: Boris Orlowsky @.>; Author @.> Subject: Re: [Sensirion/arduino-sht] connect sensor to 2nd I2C bus (Issue #24)
Hi there,
This is indeed possible, the init() function allows to use an optional TwoWire parameter: https://github.com/Sensirion/arduino-sht/blob/master/SHTSensor.cpp#L285.
At this point, the autodetect does not work on the second bus, but I just merged #23https://github.com/Sensirion/arduino-sht/pull/23 which will address this. To make it work with the current version, you will have to create the SHTSensor with a sensor type, like so:
SHTSensor sht1(SHTSensor::SHT3X);
SHTSensor sht2(SHTSensor::SHT3X);
// ...
Wire.begin();
// ...
sht1.init(<insert bus 1 here>);
sht2.init(<insert bus 2 here>);
You can start with the multiple-sht-sensors.ino example as a starting point, change both sensors to be SHT3X (assuming they are), and then add the two busses as arguments to init(...)
I will close this, feel free to reopen if you run into any issues!
Best, Johannes
— Reply to this email directly, view it on GitHubhttps://github.com/Sensirion/arduino-sht/issues/24#issuecomment-1104256587, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKTIOOEZ5DHDYMBNDRY6GOTVGBBJ5ANCNFSM5T3SPH7Q. You are receiving this because you authored the thread.Message ID: @.**@.>>
Thanks a lot for testing!
I just pushed a new release (1.2.2) which includes the fix for autodetect, so changes are the following will work too:
SHTSensor sht1, sht2; // autodetect
// ...
Wire.begin();
// ...
sht1.init(/* insert bus 1 here */;
sht2.init(/* insert bus 2 here */;
Nice, just upgraded it in my Arduino! I have used 2 TwoWires instead of the Wire.begin(), was a bit more transparent for me to specify both buses in the same way (snippet from the adapted autodetect example).
Cheers, Boris.
SHTSensor sht1(SHTSensor::SHT3X); SHTSensor sht2(SHTSensor::SHT3X);
TwoWire I2C1=TwoWire(0); TwoWire I2C2=TwoWire(1);
void setup() { // put your setup code here, to run once: I2C1.begin(I2C1_SDA, I2C1_SCL); I2C2.begin(I2C2_SDA, I2C2_SCL);
Serial.begin(115200); delay(1000); // let serial console settle
// init on a specific sensor type (i.e. without auto detecting), // does not check if the sensor is responding and will thus always succeed.
// initialize sensor on 1st bus sht1.init(I2C1);
// initialize sensor on 2nd bus sht2.init(I2C2); }
From: Johannes Winkelmann @.> Sent: Thursday, April 21, 2022 5:46 PM To: Sensirion/arduino-sht @.> Cc: Boris Orlowsky @.>; Author @.> Subject: Re: [Sensirion/arduino-sht] connect sensor to 2nd I2C bus (Issue #24)
Thanks a lot for testing!
I just pushed a new release (1.2.2) which includes the fix for autodetect, so changes are the following will work too:
SHTSensor sht1, sht2; // autodetect
// ...
Wire.begin();
// ...
sht1.init(/ insert bus 1 here /;
sht2.init(/ insert bus 2 here /;
— Reply to this email directly, view it on GitHubhttps://github.com/Sensirion/arduino-sht/issues/24#issuecomment-1105400392, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKTIOOH6ZT64YR3VG7CY37DVGFZ2BANCNFSM5T3SPH7Q. You are receiving this because you authored the thread.Message ID: @.**@.>>
Hi, thanks a lot for this excellent library. I have a project where I want to connect two SHT30-sensors to an ESP32 and wonder whether it's possible to connect an SHT30 to the 2nd I2C bus of the ESP32. Did not find out whether it's possible to pass the bus as an argument to init() or to the constructur... Thanks for any hint!