Git Product home page Git Product logo

adafruit_bme280_library's Introduction

Adafruit BME280 Library Build StatusDocumentation

This is a library for the Adafruit BME280 Humidity, Barometric Pressure + Temp sensor

Designed specifically to work with the Adafruit BME280 Breakout

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Installation

To install, use the Arduino Library Manager and search for "Adafruit BME280" and install the library.

Dependencies

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation and doxygen

Documentation is produced by doxygen. Contributions should include documentation for any new code added.

Some examples of how to use doxygen can be found in these guide pages:

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips

Formatting and clang-format

This library uses clang-format to standardize the formatting of .cpp and .h files. Contributions should be formatted using clang-format:

The -i flag will make the changes to the file.

clang-format -i *.cpp *.h

If you prefer to make the changes yourself, running clang-format without the -i flag will print out a formatted version of the file. You can save this to a file and diff it against the original to see the changes.

Note that the formatting output by clang-format is what the automated formatting checker will expect. Any diffs from this formatting will result in a failed build until they are addressed. Using the -i flag is highly recommended.

clang-format resources

About this Driver

Written by Ladyada for Adafruit Industries.

BSD license, check license.txt for more information

All text above must be included in any redistribution

adafruit_bme280_library's People

Contributors

andydoro avatar caternuson avatar danbaker-projects avatar deanm1278 avatar dhalbert avatar dirkmueller avatar el-han avatar esphorst avatar evaherrada avatar frankleonrose avatar hathach avatar herm avatar hhk7734 avatar hoffmannjan avatar jasonmf avatar kankaristo avatar kimi1991 avatar ladyada avatar marcmerlin avatar microbuilder avatar moikorg avatar mozzbozz avatar pm73 avatar sellensr avatar siddacious avatar slav-at-attachix avatar tdicola avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_bme280_library's Issues

Isn't while(1); dangerous ?

Sorry if this is a noob question, just started with tinkering, but I think in the example the while(1); loop is quite problematic:

It happened to me that when I tried it with a Wemos LOLIN32 Pro board (an old one, from two years ago), that the board started smoking after some time got very hot when running this example and it didn't detect an I2C device. First I thought that this is common idiom in ESP32 or Arduino coding so that it indeed is translated in a kind of sleep. But now it looks for me that it really just burns CPU cycle, like in any other programming language.

I killed 3 boards that way until I replaced that line with a delay(verylongtimeout).
What's your take on that while(1); idiom, which, btw, I have seen several times in various examples (so I'm really curious what's the reasoning behind this loop).

Sorry again if this is a noob question, feel free to close the issue any time.

  • Arduino board: Wemo Lolin32 Pro (ESP32)

  • Arduino IDE version (found in Arduino -> About Arduino menu): Using plattform.io

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): Upload BME280 example with the sensor being not detected.

register struct issues

Refer to this code inside the *.h file:

unsigned int get() { return (t_sb << 5) | (filter << 3) | spi3w_en;}

unsigned int get() { return (osrs_t << 5) | (osrs_p << 3) | mode; }

I'm sure the bit shift 3 for "filter" and "osrs_p" should be 2, otherwise, it will overlap the t_sb and osrs_t bits values.

multiple sensors

I suggest to make the static member bme280_calib_data bme280_calib an object variable. Otherwise, running multiple sensors in one project returns incorrect data except for the one that wrote it's calibration data in to the static last.

I2C address for BME280 GYBMEP 0x76

Thanks for awesome library. However I had some hard time to make my sensor working.
The default I2C address is set to 0x77 - (which is also default for BMP180)
I have noticed there are several variants of the sensor

Mine however is running on 0x76 address (many thanks to I2C scanner)

BME280

Means that this library works fine when changing the default I2C address
I have also found this reference in bosch library https://github.com/BoschSensortec/BMP280_driver/blob/master/bmp280.h
as BMP280_I2C_ADDRESS1

Perhaps I would create PR which allows to set I2C address in constructor ( with commented macro i.e. BME280_ADDRESS_GYBMEP )

not sure how common issue is it but I believe someone else may appreciate it

I2C to USB

Question:

How can i read out the bme280 with i2c-->usb on a raspy?

image

Missing feature, sleep mode.

Hi,
Can you please implement a way to send the BME to sleep mode?
Something like:

void Adafruit_BME280::stop() {
write8(BME280_REGISTER_CONTROL, 0);
}

Thank you,
Itai.

Commented out code: Purpose of Adafruit_BME280_Unified?

The header file contains some commented out code which is there since the initial commit - there's no comment or whatsoever explaining the purpose of it. Is is just a TODO?

This is the code:

/*
class Adafruit_BME280_Unified : public Adafruit_Sensor
{
  public:
    Adafruit_BME280_Unified(int32_t sensorID = -1);
    bool  begin(uint8_t addr = BME280_ADDRESS);
    void  getTemperature(float *temp);
    void  getPressure(float *pressure);
    float pressureToAltitude(float seaLevel, float atmospheric, float temp);
    float seaLevelForAltitude(float altitude, float atmospheric, float temp);
    void  getEvent(sensors_event_t*);
    void  getSensor(sensor_t*);
  private:
    uint8_t   _i2c_addr;
    int32_t   _sensorID;
};
*/

As the "unified" stuff seems to be just some mocking, there doesn't seem to be any need for the #include <Adafruit_Sensor.h> either? At least removing it from both the Adafruit_BME280.h-file and the bme280test.ino example sketch gets rid of the following warning at compile time:

warning: unused parameter 'enabled' in virtual void enableAutoRange(bool enabled) {};

and at least for me it doesn't seem to break anything. But I think the code author will know better than me about the reasons for this code segment...

More helpful docs for esp32 and i2c

Hi, In trying to use this library with a new esp32 dev board, I'm unable to read a connected bme280. This library says i2c just works, but nothing about which pins to use, and maybe this is my issue.

I'd like to be able to use the example to know if I can read the data from the sensor.

I'm currently using Wire 22 and Wire 21 from this diagram. Is this correct? Icant get the code past the wiring check. Please advise.

https://github.com/espressif/arduino-esp32/blob/master/docs/esp32_pinmap.png

Cheers.

BME280.begin() for I2C allways calls BME280.begin() resetting the I2C interface to default state

BME280.begin() for I2C allways calls TwoWire.begin() without parameters, which resets the I2C interface to its default state.

This occurs even if an already initialized TwoWire object is passed to BME280.begin() as input parameter. The Wire interface is a shared object that may have been explicitly configured by the application already, different from its default state. Resetting it then causes problems.
(The bus may have been configured for a different speed, or on ESP32 for using custom I2C pins. ESP32 supports 2 hardware I2C interfaces).

Please do not call Wire.begin() in BME280.begin(), at least not when a TwoWire object is passed as input parameter.

Error while compiling

Arduino: 1.6.9 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (3M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

WARNING: Spurious .github folder in 'Adafruit BME280 Library' library
WARNING: Spurious .github folder in 'ArduinoJson' library
C:\Users\Lenovo\AppData\Local\Temp\arduino_modified_sketch_467989\bme280test.ino:20:29: fatal error: Adafruit_Sensor.h: No such file or directory

#include <Adafruit_Sensor.h>

                         ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

have 2 BME280 by 0x76 and 0x77 simultaneously side by side on same i2c Bus?

how is it possible to have 2 BME280 by bus addresses 0x76 and 0x77 simultaneously side by side on same i2c Bus?
For that purpose the ability to create instances by passing the bus address would be helpful and then wiring CS to GND or Vc accordingly:

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

Adafruit_BME280 bme1(0x76);  
Adafruit_BME280 bme2(0x77);  

will that be provided?

Handling BMP280?

Dear Friends,
Is there any chance to enhance this library to handle BMP280 sensor (without humidity measuring) too? If you think I can offer my contribution in this enhancement.
Zoltan

protected instead of private

Dear all,
would it be an option to change the private methods and variables to protected?
I would like to access the private methods in an inherited class.
Best regards,
espHorst

Example sketch will not compile - SPI Class missing member

  • Arduino board: Uno

  • Arduino IDE version: Arduino 2:1.0.5+dfsg2-4

  • Issue: The example sketch bme280test will not compile, the compiler complains...

/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp: In member function ‘void Adafruit_BME280::write8(byte, byte)’:
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:158:17: error: ‘class SPIClass’ has no member named ‘beginTransaction’
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:158:73: error: ‘SPISettings’ was not declared in this scope
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:164:13: error: ‘class SPIClass’ has no member named ‘endTransaction’
SPI.endTransaction(); // release the SPI bus
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp: In member function ‘uint8_t Adafruit_BME280::read8(byte)’:
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:185:17: error: ‘class SPIClass’ has no member named ‘beginTransaction’
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:185:73: error: ‘SPISettings’ was not declared in this scope
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:191:17: error: ‘class SPIClass’ has no member named ‘endTransaction’
SPI.endTransaction(); // release the SPI bus
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp: In member function ‘uint16_t Adafruit_BME280::read16(byte)’:
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:214:17: error: ‘class SPIClass’ has no member named ‘beginTransaction’
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:214:73: error: ‘SPISettings’ was not declared in this scope
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:220:17: error: ‘class SPIClass’ has no member named ‘endTransaction’
SPI.endTransaction(); // release the SPI bus
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp: In member function ‘uint32_t Adafruit_BME280::read24(byte)’:
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:282:17: error: ‘class SPIClass’ has no member named ‘beginTransaction’
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:282:73: error: ‘SPISettings’ was not declared in this scope
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
^
/home/xeuari/sketchbook/libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp:294:17: error: ‘class SPIClass’ has no member named ‘endTransaction’
SPI.endTransaction(); // release the SPI bus
^

My core libraries are up to date. Does the bme280 library use a previous SPI library release?

Thanks --Xeuari--

BME280_ADDRESS_ALTERNATE does nothing

I had to change the address from 0x77 to 0x76 and I found an interesting constant BME280_ADDRESS_ALTERNATE.
But I can't find any usage of it in code

I suppose, it either must be removed totally or implemented as in (#68)

ESP32 hangs after loading the lib

The current version no longer works on an ESP32 board.

The code compiles without errors, the ESP hangs after the lib is loaded.
version = 1.0.5 runs without problems.

Error: 'Wire1' was not declared in this scope in "advancedsettings" example from the Adafruit BME280 library

  • Arduino board: UNO

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.5

The "advancedsettings" example from the Adafruit BME280 library gives the following error:
/----------------------------------
exit status 1
'Wire1' was not declared in this scope
/----------------------------------
Removing 'Wire1' ie bme.begin(&Wire1) -> bme.begin(), fixes the error and the example compiles OK.

Missing feature - Oversampling, Sensor Mode, Standby Time, IIR Filter

Is it possible to add the ability to adjust the following settings:

  • Sensor mode (Sleep, Forced, Normal)
  • Standby time (0.5ms - 1000ms)
  • Humidity Oversampling (x1 to x16)
  • Pressure Oversampling (x1 to x16)
  • Temperature Oversampling (x1 to x16)
  • IIR Filter (off, 2, 4, 8, 16)

From what I can tell, it is currently set for Normal mode with 0.05ms standby, and x16 oversampling for humidity, pressure, and temperature. This is overkill for use as a weather sensor (which Bosch recommends settings of (Forced, 1 sample, x1 oversampling [hum,pres,temp], IIR filter off)

Thanks.

BME280.begin() does not support specifying custom I2C pins

Adafruit BME280.begin() does not support specifying custom pins for I2C.
(While for SPI specifying custom pins is supported.)

ESP32 supports 2 hardware I2C interfaces but BME280 library can only be used for the default I2C pins because custom I2C pins cannot be specified.

Please add an option for specifying custom I2C pins when calling BME280.begin().

Temperature conversion functions

Is it possible to get functions to convert Celsius to Fahrenheit and back to the ADAFRUIT_BME280 lib? I can provide the code but not sure of the best place to insert it in the .h and .cpp .

thanks,
tjm

Compensation algorithm causes high spikes in measures

The compensation algorithm in this library uses shift operations in order to efficiently achieve a division by powers of 2. However, these two operations are not guaranteed to be equivalent when applied to signed integers.

When using this library on an atmega328p, I often get high spikes in the resulting temperature and humidity readings. These spikes disappear when I use divisions instead of bit shifts.

I will propose a PR which uses the reference implementation of the compensation algorithm from Bosch. This implementation uses division operations. Could you have a look at it and maybe test it on different platforms?

Error running example

Hi,

I have Arduino Nano (ATMega 328P) and sensor BME/BMP280.

I try to run example advancedsettings.ino and got this error (I am using Arduino IDE):

/home/matej/Arduino/Adafruit_BME280_Library/advancedsettings/advancedsettings.ino:21:29: fatal error: Adafruit_BME280.h: No such file or directory
 #include <Adafruit_BME280.h>
                             ^
compilation terminated.
exit status 1
Error compiling for board Arduino Nano.

So I replaced (in file advancedsettings.ino) this line:
#include <Adafruit_BME280.h>
With this line:
#include </home/matej/Arduino/Adafruit_BME280_Library/Adafruit_BME280.h>

Now I get this error:

/home/matej/Arduino/Adafruit_BME280_Library/advancedsettings/advancedsettings.ino: In function 'void setup()':
advancedsettings:40: error: 'Wire1' was not declared in this scope
     if (! bme.begin(&Wire1)) {
                      ^
exit status 1
'Wire1' was not declared in this scope

Any idea what could be wrong?

Custom Temperature Adjustments

Preemptive grain of salt: I'm pretty new to electronics so if anything I say here doesn't quite make sense, that's why.

I have a handful of Chinese white-label BME280 boards all of which report a temperature that's slightly off, one as much as +3C. I understand that the temperature reading is intended as an estimate and not a true value.

In my own code I can adjust the temperature I report by the required amount. However, the incorrect temperature is being used in pressure and humidity calculations, making them less accurate.

Would it be reasonable to specify a temperature adjustment for the sensor object or to be supplied to the humidity and pressure calculation functions to account for the discrepancy? Should I just commit the grossly incorrect sensors to the e-waste bin?

Problem with ESP8266

The new version of the library (1.0.5) does not work with my Chinese BME280 on ESP8266. Whereas 1.0.4 works without problems. I change the address 0x76 only.
In indications i see zeros only.

Switch control register setting order?

I was reading the BME280 datasheet, and it claims

Changes to this register [ctrl_hum] only become effective after a write operation to “ctrl_meas”.

(§5.4.4, page 25)

However, in the initialization code in this library, the following two lines are present:

  write8(BME280_REGISTER_CONTROL, 0x3F);
  write8(BME280_REGISTER_CONTROLHUMID, 0x03);

It would appear to me that those two lines should be switched, in order to first write the humidity options and then set the other options + confirm the humidity options.

I've attempted to test this locally, and it did appear to change the results; I don't have a great secondary humidity sensor to test it against, though.

using in Jetson Nano

can I use this Library on Jetson Nano to integrate with the sensor ?
I have Jetson nano that have I2C pins and want to connect to the sensor and read temperature and pressure value.
how can I do that ?

License?

The repository doesn't have a LICENSE or COPYING file, which license is the library distributed under?

If it's up for a vote, I'd suggest MIT or some other permissive license.

config register writes in "Normal" mode may be ignored

I had the issue that changing the standby duration with setSampling apparently had no effect. Looking at the data sheet, section 7.4.6 says: "Writes to the “config” register in normal mode may be ignored. In sleep mode writes are not ignored.".
The current version of setSampling does not honor this.
Since after begin() we are in normal mode, this will be an issue for basically every use of setSampling that changes the filter or standby duration settings - i.e. it may work but it it will be unreliable.

So we need to insert another write that resets the mode to "Sleep" before the actual values are written:

void Adafruit_BME280::setSampling(sensor_mode       mode,
		 sensor_sampling   tempSampling,
		 sensor_sampling   pressSampling,
		 sensor_sampling   humSampling,
		 sensor_filter     filter,
		 standby_duration  duration) {
    _measReg.mode     = mode;
    _measReg.osrs_t   = tempSampling;
    _measReg.osrs_p   = pressSampling;
        
    
    _humReg.osrs_h    = humSampling;
    _configReg.filter = filter;
    _configReg.t_sb   = duration;

    // "Writes to the “config” register in normal mode may be ignored.
    // In sleep mode writes are not ignored." (DS 7.4.6)
    write8(BME280_REGISTER_CONTROL, 0);  //temporarily change to sleep mode
    
    // you must make sure to also set REGISTER_CONTROL after setting the
    // CONTROLHUMID register, otherwise the values won't be applied (see DS 5.4.3)
    write8(BME280_REGISTER_CONTROLHUMID, _humReg.get());
    write8(BME280_REGISTER_CONFIG, _configReg.get());
    write8(BME280_REGISTER_CONTROL, _measReg.get());
}

Adafruit BME280 library does not work on Raspberry Pi Pico - runtime crashes

  • Arduino board: Raspberry Pi Pico

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.3

  • Steps to reproduce:

  1. make some kind of meteosensor board attaching BME280 via I2C level shifter to Raspberry Pi Pico pins 6 and 7;
  2. install Arduino IDE from official site;
  3. install Raspberry Pi Pico runtime environment from boards manager;
  4. install Adafruit BME280 library with its dependencies via library manager;
  5. install DFRobot BME280 library with its dependencies via library manager;
  6. compile and upload official demo sketch from Adafruit (f.e, bme280_unified);
  7. compile and upload official demo sketch from DFRobot (f.e, raedDataI2C).

If you make board correctly (I did :), both sketches, in theory, should work. Really, Adafruit's just crashes immediately signalling SOS via built-in LED while DFRobot's work like a charm.

Possible hang when using Adafruit_BME280::takeForcedMeasurement()

When sensor BME280 gets disconnected or is damaged calling Adafruit_BME280::takeForcedMeasurement() can results in hanging. Reason is in loop

while (read8(BME280_REGISTER_STATUS) & 0x08)

On ESP8266 this loop won't trigger WDT, since it is using delay.

To reproduce - connect BME280 sensor to ESP, initialize it in forced mode and read in some intervals (10s). Then disconnect sensor from I2C bus, or power it off. ESP will hang.

Sorry, if this is obvious, but I can't locate the doxygen documentation and theres no link to it in the readme as in other libs

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

Wire.endTransmission after Wire.requestFrom is not okay.

There is a Wire.endTransmission after a Wire.requestFrom.
The Wire.requestFrom is a complete I2C transmission on its own, it should not be followed by a Wire.endTransmission.
The Wire.endTransmission transmits the bytes in the buffer that are written with Wire.write and waits until the I2C transmission (to write date) has finished.

constructor should take a connection object instead of pinout list

The Adafruit_BME280 constructor take pins (SPI) or nothing (I2C/Wire) where it should take a full Wire object that could be use for connection with the BME (unsure about SPI) AND the adress 0x76 or 0x77 of the sensor.
This would enable usage of the librarie with different flavour of "SoftwareWire" (bitbanging I2C) and enable multiple I2C on one board (when you need more than 2 BME)

Inaccessible class member functions

  • Arduino board: board independent software bug

  • Arduino IDE version (found in Arduino -> About Arduino menu): Windows 1.8.13

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):
    the two class member functions

  • float Adafruit_BME280::getTemperatureCompensation(vid){}

  • void Adafruit_BME280::setTemperatureCompensation(float adjustment){}

are not accessable from a Sketch and generate a compiler error:
'class Adafruit BME280' has no member named 'getTemperatureCompensation'
Despite the fact, that this member is explicitely specified in Adafruit_BME280.cpp and referenced in the public section of Adafruit_BME280.h

Maybe the compiled library code is not identical to the documented code.

Software Wire / I2C

Hi, is there any plan (or guides) on adding support for software wire so other Arduino pins can be used for I2C connection? I see we can pass our on Wire object into constructor, but this is not compatible with software wire. Looks like I could fork and hack it in but just checking this isn't already supported or something? Many thanks.

Missing Adafruit_Sensor.h

I downloaded the library and found it missing Adafruit_Sensor.h included in the example and the main library header. Since I did not find any hints and it seems not needed I removed the include statements. To resolve the issue I would like to have either the include statements removed or a link to the file provided in the readme file.

Is it possible to return absolute humidity instead of relative?

I was looking at the code for readHumidity, and it looks like it first takes a temperature reading then implements this into the humidity reading formula. Does this mean the BME280 is actually outputting absolute humidity, and the code is converting that to relative?

Because I much prefer absolute humidity, and in my code I am taking this relative humidity value, and the temperature value, and converting it to absolute. But if the BME280 sensor itself can output absolute in the first place, I wouldn't need to do this inaccurate equation.

Parsing H4/H5 humidity calibration data

According to the datasheet, dig_H4 and dig_H5 are signed integers on 12 bits

The following code handles these as pure 16bits signed, which will never be negative...

_bme280_calib.dig_H4 = (read8(BME280_REGISTER_DIG_H4) << 4) | (read8(BME280_REGISTER_DIG_H4+1) & 0xF);
_bme280_calib.dig_H5 = (read8(BME280_REGISTER_DIG_H5+1) << 4) | (read8(BME280_REGISTER_DIG_H5) >> 4);

The datasheet is ambiguous as it refers to these 12 bits values as signed short, but the BoschSensortec reference code definitely handles the values as 12 bits signed integer -- the (int8_t)cast on the msb ensures the sign is propagated

bme280test example typo errors

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: all boards

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.19

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

in code starting lines:
46 // You can also pass in a Wire library object like &Wire2
47 // status = bme.begin(0x76, &Wire2)

line 47 missing semicolon end of line.
line 47 also "&wire2" has extra character "2" in parameter.

Version 2.0.1: Examples do not work any more (i2c)

Recent changes in the initialization of the sensor object results in non working examples:

If I get it right, the latest changed in the begin() method make the I2C addr and the wire object mandatory. As the examples do not provide them the connection to the BME280 will not get set up without further modification of the example.

bool Adafruit_BME280::begin(uint8_t addr, TwoWire *theWire)

BR,
Volker

begin() Method Corrupts Sensor ID If Not Valid

Hello,

First post so please forgive posting guideline deviations :)

I had unknowingly received a BMP280 board instead of the BME280 board I ordered and tried to use it with this library. When I called the begin() method using I2C and passing the correct address, it returned false and a subsequent call to the sensorID() method returned 0xFF. After much troubleshooting, I wrote code to read the chip's ID register directly and found that it was 0x58, indicating that it was the wrong board (BMP280). Based on this, the begin() method correctly returned false, but it corrupted the _sensorID value.

The way that the begin() methods are implemented, if the return from init() is false for whatever reason, it will try to use the other I2C address. If the original problem was just that the chip ID was not valid, using the other I2C address will cause the chip ID to be set to 0xFF, indicating a possible address problem.

I would recommend changing the begin() methods so that if the I2C address is passed, only that address is read. If it's not passed, both addresses are attempted. This can be accomplished I believe without affecting existing users by making the following changes to two of the begin() methods:

bool Adafruit_BME280::begin(uint8_t addr, TwoWire *theWire) {
  _i2caddr = addr;
  _wire = theWire;
  return init();
}

bool Adafruit_BME280::begin(TwoWire *theWire) {
  bool status = false;
  status = begin(BME280_ADDRESS, theWire);
  if (!status) {
    status = begin(BME280_ADDRESS_ALTERNATE, theWire);
  }
  return status;
}

Please let me know if there is a better/correct way to submit this type of report, or if you need any additional info regarding this.

For completeness, here are my specifics:

  • Arduino board: NodeMCU-32S
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.10

Thank you,
Greg Thielen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.