Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By bkenobi
#72106 As I said, my project requires 3 identical sensors so using I2C on its own isn't an option. If I can't get SPI to work, I may consider changing the project to make it work (2 fan controllers rather than 1, each controlling it's own space).

For reference, I've primarily been using the Adafruit library but have attempted a couple others. I don't beleive the issue is necessarily the library so much as how I'm using it. I'm getting resets every few seconds when I have the sensor hooked up per the library, so it appears it may be related to using a hardware variant that might vary somewhat from what the library expects.

I'm using a Wemos D1 from 2015 and a GY-BME280 (standard 6-pin purple board seen on ebay). I don't think this is an alien configuration.
User avatar
By bkenobi
#72114 Perhaps this is a simple question, but I'm not sure how to add the second bus. My found code is basically just the Adafruit library example:

Code: Select all//based on:
// Adafruit Adafruit_BME280_Library
// https://github.com/adafruit/Adafruit_BME280_Library
//and
// Astuder BMP085-template-library-Energia
// https://github.com/astuder/BMP085-template-library-Energia
//plus code for altitude and relative pressure
//by r7

#include <Wire.h>                                                       // required by BME280 library
#include <BME280_t.h>                                                   // import BME280 template library

#define ASCII_ESC 27

#define MYALTITUDE  150.50

char bufout[10];

BME280<> BMESensor;                                                     // instantiate sensor

void setup()
{
  Serial.begin(115200);                                                 // initialize serial
//  Wire.begin(D8,D9);                                                  // initialize I2C that connects to sensor
  Wire.begin(D3,D4);                                                    // initialize I2C that connects to sensor
  BMESensor.begin();                                                    // initalize bme280 sensor
}

void loop() {
  BMESensor.refresh();                                                  // read current sensor data
  //sprintf(bufout,"%c[1;0H",ASCII_ESC);
  //Serial.print(bufout);

  Serial.print("Temperature: ");
  Serial.print(BMESensor.temperature);                                  // display temperature in Celsius
  Serial.println("C");

  Serial.print("Humidity:    ");
  Serial.print(BMESensor.humidity);                                     // display humidity in %   
  Serial.println("%");

  Serial.print("Pressure:    ");
  Serial.print(BMESensor.pressure  / 100.0F);                           // display pressure in hPa
  Serial.println("hPa");

  float relativepressure = BMESensor.seaLevelForAltitude(MYALTITUDE);
  Serial.print("RelPress:    ");
  Serial.print(relativepressure  / 100.0F);                             // display relative pressure in hPa for given altitude
  Serial.println("hPa");   

  Serial.print("Altitude:    ");
  Serial.print(BMESensor.pressureToAltitude(relativepressure));         // display altitude in m for given pressure
  Serial.println("m");
  Serial.println();

  delay(1000);                                                          // wait a while before next loop
}


I can switch between D3,D4 and D8,D9 by recompiling. So, I know both sets of hardware should work fine on their own. Now I just need to get a second wire library defined I guess.