adafruit / Adafruit_AHTX0

Arduino library for AHT10 and AHT20 sensors!
Other
63 stars 11 forks source link

Add alternate address to begin() #8

Closed jbaumann closed 2 years ago

jbaumann commented 2 years ago

This patch adds an additional optional parameter to the begin() method, the i2c_address. This allows to switch from the default address of the sensor to the alternate address. Fixes issue "Add alternative I2C address as parameter for the begin() method #7"

ladyada commented 2 years ago

thanx ! how do you get the alternative address on the hardware?

ladyada commented 2 years ago

hiya! thanks so much for submitting a PR! we can review & merge PRs once they have passed continuous integration (CI). that means that code compiles cleanly for all tested platforms, is clang formatted so we maintain the same text formatting for all new code, and is doxygen documented. if your code isnt passing, check the CI output (click on the red X next to the PR to scroll through the log and find where the error is

here is a tutorial on doxygen: https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

and clang-format: https://learn.adafruit.com/the-well-automated-arduino-library/formatting-with-clang-format

and overall how to contribute PRs to libraries: https://learn.adafruit.com/contribute-to-arduino-with-git-and-github

once you get that green checkmark that indicates CI has passed, please comment reply to this post so we know its time for another review (we may not get notified on CI pass and miss that its time to look!)

bukwyrm commented 2 years ago

This is ready to be merged, mayhaps? - The 39 adress is the 'default-alternative' and can be produced by pulling ADR to Vcc

caternuson commented 2 years ago

Is there a different variant out there? Where is the ADR pin? aht20

jbaumann commented 2 years ago

The AHT10 has an additional ADR pin that is exposed on many boards.

caternuson commented 2 years ago

Ah, OK. It's for the AHT10: image

caternuson commented 2 years ago

@ladyada LGTM. The CP lib allows for this as well. I suggest we allow this to be a breaking change so the parameters can be in this order for the sake of consistency :

  bool begin(uint8_t i2c_address = AHTX0_I2CADDR_DEFAULT, TwoWire *wire = &Wire , int32_t sensor_id = 0);