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

Support for SHT40-B sensors with alternative i2c address #1

Closed
F-Schmidt99 opened this issue Nov 20, 2022 · 6 comments
Closed

Support for SHT40-B sensors with alternative i2c address #1

F-Schmidt99 opened this issue Nov 20, 2022 · 6 comments
Assignees

Comments

@F-Schmidt99
Copy link

Could you please add support for SHT40-B sensors that have the alternative i2c address 0x45?

Currently it is hardcoded in SensirionI2CSht4x.cpp, line 44:
#define SHT4X_I2C_ADDRESS 0x44

You could just add a uint8_t field to the sensor object and use either the constructor or begin(...) method with the current address as the default. This would even be backward compatible with the current library version.

@psachs
Copy link
Member

psachs commented Jan 18, 2023

Unfortunately we don't support to change I2C address on runtime.
You can simply modify the driver and change the I2C address

@F-Schmidt99
Copy link
Author

Maybe I explained the issue with too little details, so for now I will reformulate it as a question.

How could I communicate with a sensor of type SHT40-BD1B-R2 using this library? I can not set the i2c address anywhere and the default is not 0x44 but 0x45

@qfisch
Copy link

qfisch commented Sep 29, 2023

Hej @F-Schmidt99 ,

Not sure @psachs still has this old issue under the radar so I will jump in.
In the file https://github.com/Sensirion/arduino-i2c-sht4x/blob/master/src/SensirionI2CSht4x.cpp you can change the I2C address to 0x45 by setting SHT4X_I2C_ADDRESS

I hope it helps
Cheers

Edit: to be clear I am talking about directly editing the file. Which typically is easier when you cloned the repository and transferred the driver to your project (instead of installing it using the Arduino library manager)

@F-Schmidt99
Copy link
Author

Hello @qfisch,

thank you for the response.
I know how to control the sensor by editing the file. But keeping in mind, that this library is for the Arduino framework, and therefor also used by many beginners, I think, that you should provide either a constructor or a 'begin' method taking the i2c address as uint8_t address argument. Alternatively, you could also pass an enum value like this:

enum SHTSensorType {
A = 0x44,
B = 0x45
};

for better readable code.
See here for guidelines of Arduino: https://docs.arduino.cc/learn/contributions/arduino-creating-library-guide

Kind regards.

@qfisch
Copy link

qfisch commented Sep 29, 2023

Hej @F-Schmidt99 ,

I just saw your PR as well. As explained there, the feature is planned and should be rolled out soon through our typical generation process. I will keep this issue open to make sure to notify you once it is available.

Cheers
Q

@qfisch qfisch self-assigned this Sep 29, 2023
@qfisch
Copy link

qfisch commented Dec 15, 2023

Driver is now updated to included this feature

@qfisch qfisch closed this as completed Dec 15, 2023
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

3 participants