Closed pamribeirox closed 7 years ago
hiya we already have a BMP280 library https://github.com/adafruit/Adafruit_BMP280_Library so best to make any changes to that rather than trying to wedge it into this one :)
Hello, I would prefer to avoid using multiple libraries doing about the same thing with the same code. With multiple modules (BMP/BME) on the project, an unified library also has a small memory footprint. Some interesting features (eg. FILTERING & OVERSAMPLING) present in the BME library also apply to BMP280 modules and his library doesn't support them. I've seen a few people reporting troubles in some forums, troubles caused by using the incorrect address in some ebay modules that came with SDO pulldown, that's why I've added auto address detection. Your library, your option. Thanks anyway! regards from Pedro CT7ABP.
This changes allow the use of this library in modules based on BMP280 chip
In the .h file: Added a comment mentioning the update Added a comment explaining the use of the new #define BME280_NOINFO that allows the exclusion of a method that returns a string (pointer) saying the chip type "chipInfo()" Removed the #define with the default I2C address and added two with the alternative addresses Changed the standby_duration enum adding two values for BMP280 compatibility (see BME280 datasheet) The default value of the address in the begin() method changed to 0. If the called doesn't specify any parameter the method will try the default one and then the alternative. Added an enum with the possible values returned by the chip ID register for BMP280 and BME280 (based on datasheet) Added 3 methods, one returning the I2C address in use, other returning the detected chip ID, other returning a string describing the chip Added a new member variable (protected) holding the chipID
In the .cpp file: Added a comment mentioning the update Added the address autodetecting code in begin() based on the i2c_scan example Changed the chip validation to include the compatible variants In the method setSampling add the condition to only write the CONTROLHUMID register if the chip is BME280 In the method readCoefficients add the condition to only read the registers related to humidity if the chip is BME280 In the method readHumidity add the condition to always return NAN if the chip isn't BME280 Added the method chipInfo() returning the chip description
Hope to contribute to the excellent job from Adafruit to the Arduino community! regards.